Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__allocations_mutex can get deadlocked if an allocation happens in an allocation #11

Open
thegrb93 opened this issue Jun 14, 2019 · 5 comments

Comments

@thegrb93
Copy link

thegrb93 commented Jun 14, 2019

This happened while using log4cxx. I worked-around the issue by just turning off log4cxx. It was on an old version of LeakTracer too so maybe it's been fixed since then. Maybe a recursive mutex or semaphore would fix the issue if not.

@thegrb93
Copy link
Author

thegrb93 commented Jun 14, 2019

Looks like someone already had the same idea
https://github.com/fredericgermain/LeakTracer/blob/master/libleaktracer/include/Mutex.hpp#L44

I'll try uncommenting that and see if it works.

@thegrb93
Copy link
Author

Worked. Might not for all cases, but for mine it stopped the deadlocking.

@fredericgermain
Copy link
Owner

Hi!
Thanks for reporting. Yes, this was quite a common problem when I started to use the lib. I tried to make it so to avoid that recursive mutex, as I don't like it by principle and would have rather it cleaner by having the init clearly ordered. But well, I can imagine some use cases are too difficult to deal with. I'm not sure I just write a small something about it in the README and make it easily activable with an environment variable, or I just make it the default. Or maybe there is another clever way.
It would depend on the performance of recursive vs simple mutex to make it the default. And I have no idea.

Could you just explain quickly what was your problem in your case? Or provide a little sample code?

@fredericgermain
Copy link
Owner

Also, I'm not sure recursive mutex would be available in all libc. glibc has it of course, but this tool targets all kind of embedded system.

@thegrb93
Copy link
Author

thegrb93 commented Jun 23, 2019

Yeah it's probably situational. If I have time tomorrow I can make a short reproduction code. I'll have to look at the stack trace and see what log4cxx is doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants