-
Notifications
You must be signed in to change notification settings - Fork 69
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
[sigc++ 3] Use after free with signal::make_slot() #80
Comments
For the following piece of code
valgrind complains that memory is accessed after being freed. I tested the above code with sigc++ 2 and valgrind didn't complain. After some digging, I found out that this seems to be caused by the commit: a3e2fe66 which made If I revert the change, the above code won't have valgrind error. |
It's even worse than just valgrind complaining. When I run your code without Obviously it was a mistake not to derive The only solution I can think of right now that would not break ABI is:
I don't like it. I hope there is a better solution. |
If this can't be fixed directly, can it be avoided by adding some code to the above sample? Like:
Is there a better way other than disconnecting all slots created using |
Manual disconnection solves the problem. A class that derives both from sigc::signal and sigc::trackable is an alternative.
MySignal must define its own make_slot(), because |
I'll try the second way. |
…able and therefore the made slot must be manually disconnected if the signal is deleted. See #80
Here's the solution: Derive sigc::signal_with_accumulator from sigc::trackable. This fix is not automatically available just by linking to an updated library file. |
Sorry if it may seem a stupid question but why is this not an ABI change? |
Since sigc::signal is a class template, the generated code is stored in the user's Your question makes me uncertain again. I didn't think of two related sigc::signal It's definitely safer to leave sigc::signal unchanged, and add sigc::trackable_signal Today's change hasn't been released. It can still be reverted. Have you got an opinion? |
I did a quick test:
When The crash won't happen if And using old or new |
Thanks for the test. But the result does not really tell us if there is a Still I've a feeling that it's not safe to implement the new sigc::signal_with_accumulator, I'm inclined to revert the fix that changes sigc::signal_with_accumulator, and add |
I did some more tests. |
It looks like you've found a real problem with my "fix". I suppose that |
I think it is indeed a problem, although not a common way of using the type. I think |
No description provided.
The text was updated successfully, but these errors were encountered: