-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add library attribute for no-failure allocators #7390
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
Conversation
For example GLib and GTK abort on most allocation failures, making the nullPointerOutOfMemory check produce lots of false positives. To fix this, introduce a new allocator attribute "no-fail" to notify that this allocator cannot fail and that this check is thus irrelevant for it.
There probably are other options for tagging the library functions, I can update if wanted. |
This also needs to be added in the Library Editor in the GUI (see |
Could you also provide a link to documentation that supports this behavior? |
e.g. https://docs.gtk.org/glib/func.malloc.html:
The idea behind this is that allocation failure for most trivial allocations are hard to handle well, and likely will end up terminating the program anyway. More classic allocation is available with e.g. |
Thanks.
That indicates that some code still needs the check afterwards. So it might be worth reviewing the calls anyways.
Yes, OOM handling/recovery is very hard to impossible. |
Yes, in some cases The cases of e.g. As things are right now, most GLib-using code will just produce gazillion false-positives (see e.g. geany/geany-plugins#1417): even the few checks in |
Please also add an entry with the new attribute to the GUI test data. |
@firewave you mean setting it to |
Yes. I think that would be an additional entry in |
518a421
to
068929a
Compare
This produces too many false-positives with GLib code. See danmar/cppcheck#7068 and danmar/cppcheck#7390. Closes geany#1417.
@b4n thanks for your contribution. |
The name "no-fail" is not ideal. But I don't have better suggestion directly. Something like |
We should still file a ticket about the false positive so this is documented. I also think it might be missing in the library data editor (but that should have failed a test!?). |
@danmar it isn't, but |
@firewave didn't I fix that in the latest revision? There's no UI for it sure, but it's not the only option that is not available there I believe, and it should be loaded/saved properly now. |
Ah, it is being loaded but not displayed. The latter can obviously not being tested easily. Guess we need to review the UI and file a ticket about it. |
Oops!! I will create a ticket! I really shouldn't have merged this without a ticket :-(
I am not against it however.. |
It happens.
It beats editing a raw XML file.
I assume a few people actually use - otherwise we wouldn't have gotten several PRs extending it in the past. I think we can keep it because it is very static in nature so there is not much in terms of support. |
The memory functions have no UI mask at all so there was nothing to add here. Having support for that is covered by https://trac.cppcheck.net/ticket/10688. |
For example GLib and GTK abort on most allocation failures, making the nullPointerOutOfMemory check produce lots of false positives.
To fix this, introduce a new allocator attribute "no-fail" to notify that this allocator cannot fail and that this check is thus irrelevant for it.