Fix possible use-after-free on reference count and some minor CI changes#130
Fix possible use-after-free on reference count and some minor CI changes#130leonardoheld wants to merge 3 commits into
Conversation
Signed-off-by: Leonardo Held <leonardoheld@protonmail.com>
…g build This change is specifically done so that the main build action on bullseye doesn't fail on forks. Signed-off-by: Leonardo Held <leonardoheld@protonmail.com>
This fixes a warning with GCC 12 on Bookworm by using the atomics library to increment/decrement the reference counter instead of relying on raw pointer arithmetic. Signed-off-by: Leonardo Held <leonardoheld@protonmail.com>
Awesome. I'd love to break the dependency on oldstable too and get the full set of CI tests running under Bookworm (aka Debian Stable) as a first step to dropping support for Bullseye.
Are you sure the use-after-free is caused by a thread race condition, and not that the static analyser in GCC can only spot the problem when the refcount is a simple int? Perhaps std::atomic is just confusing the analyser and not fixing a logic bug. I'm keen to be convinced: I've seen the warning before, but I can't figure out why the current code is wrong.
Yes we should drop Bullseye support eventually, but I think we need a migration path rather than a hard cutover. I'd suggest that we should support Boost etc versions back to whatever is in either:
What were the Boost things that are broken? I also had some problems getting the PKCS#11 and OSTree tests to working, but in the end all we can go is to chip away at it and slowly get more and more of the CI tests running on Debian stable. |
Oh, I think it's 100% caused by the compiler being too clever; a toy example doesn't trigger the behaviour https://godbolt.org/z/zPPr9cfWb. I searched the web and everyone seems to have come up with funny solutions for this exact specific shared_ptr case: scylladb/seastar#1037 (comment). I'll try some others to see if I can prevent from relying on atomics.
Makes sense. Those versions would be 1.78 for Yocto and 1.74 for Debian. The good news is that both will go EOL by 2026, so there's a target: might be Scarthgap with 1.84.0 and Debian Bookworm with who knows what but > 1.83. An integration branch might work, perhaps?
Errm, I wasn't very clear in the MR description in hindsight: I wanted to get a MacOS build going, because that's what I use daily and I'm salty the |
|
Shall we continue the Boost / brew building topic on a separate PR / issue? I want those things too, but I don't want to let figuring out a solution get in the way of this PR.
The That link above is just an (untested) idea. I'm cool with other solutions that give gcc more information or disable the warning, or even the std::atomic solution if we leave a comment why it is there. The rest of the PR is a +1 from me. Thank you! |
We get the so we'd probably have to sprinkle the I can either do the abive or explain better the why/how regarding the atomic operations. Whatever you think is best is probably more important.
Sure! I'll open up a detailed issue as soon as I have the time because I think this will probably span more than one PR. |
Yuk. Let's not do that :) How this? It fixes the issue on my Debian bookworm box: (Note to self: you need to disable ccache when doing these tests...) |
gcc 12 reports a use-after-free warning for this code. We believe it is a FP. More details are in #130
|
I created #131 for the asn1_message.h fix |
gcc 12 reports a use-after-free warning for this code. We believe it is a FP. More details are in uptane/aktualizr#130
There was a problem hiding this comment.
@leonardoheld I imagine you'll drop the changes to this file since the actual issue in completely unrelated to multi-threading, right?
Hi there! I have several commits that I want to try to get feedback on and I'm slowly working them upstream, mainly about getting Aktualizr to build with newer dependencies because Debian Bullseye is getting EOL'd quite soon (2026-08-31) and I'd like to have a working MacOS build with what's available on brew.
Thus this is the first commit that fixes a possible use-after-free that GCC 12+ (on Bookworm, brew) yells about.
The other major fixes I'm working with are related to Boost: a ton of stuff changed from Bullseye. Do you explicitly want to keep compatibility with the older releases? Are there plans to drop bullseye eventually so I can focus my efforts on just bringing the build up to the latest ones?
Thanks!