-
Notifications
You must be signed in to change notification settings - Fork 923
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
Clang reports use after free when deleting all hashmap contents #128
Comments
Seems similar to the false positive in #111. Can you find out for me whether this is a true positive or not? One way to do that would be to If this is a false positive in the static analyzer, then we can't really do anything about it — unless you have a patch that fixes it, and the patch doesn't hurt the performance or clarity of the code, and you don't mind it bit-rotting. I mean, Clang could start complaining about ten new things tomorrow; uthash has no control over that. |
... or compile with clang -fsanitize=address and run the code, and see if the sanitizer runtime catches the same problem. If it does, then uthash needs changing. If it does not, that is more ammunition for reporting the false positive to clang. |
It is false positive. Valgrind and sanitizer doesn't see the problem. Redefining uthash_free also didn't segfault. |
Fixes troydhanson#128. Clang static analyzer was thinking that it's possible to free() list head without updating head pointer. This assert assures static analyzer that branch without head pointer update could be taken only when we are freeing non-head element.
Hello, I am a developer of gcc plugins and I came across uthash and wanted to test it. I do see use-after-free for the last element deleted. My testcase was add 3 entries and delete them like this
where The trace from the instrumented code is
Further, if I comment out the |
@acbits: That doesn't seem related to this issue about a Clang-static-analyzer false positive. In fact, we can already tell that the output you pasted doesn't come from the loop you pasted. In the loop, you do
Your program might secretly be doing something with multiple threads. Make sure every thread is done using the hash table before you try to destroy it. |
The reason I didn't post the code is because it uses a gcc attribute that is not available to public yet.(Might change in future)
That is correct. The log inbetween BTW, I don't use uthash. I just selected uthash as test case for the gcc plugin and encountered the same issue as reported here. I provided the trace so that it would be helpful to investigate. |
The clang reports "use after free" when analyzing the following piece of code:
Clang report:
The text was updated successfully, but these errors were encountered: