Repository navigation
fix: possible double free due to multithreading with Contour - #3496
Conversation
|
Thank you for contributing! 🐞 Bug Fixes
|
|
Maybe change class Contour: public etl::shared_object
{
public:
typedef etl::handle<Contour> Handle;to class Contour
{
public:
typedef std::shared_ptr<Contour> Handle;? |
|
|
||
| public: | ||
| Contour::Handle contour; | ||
| std::shared_ptr<Contour> contour; |
There was a problem hiding this comment.
I tried to use std::unique_ptr, but couldn't compile because some Task copy calls... I didn't investigate it though
There was a problem hiding this comment.
I didn't remember, but maybe you know - Task is always unique, or copies are possible?
There was a problem hiding this comment.
Hm... They can be set as sub_task of one or more tasks...
There was a problem hiding this comment.
But contour itself I don't know if it is shared to other stuff besides the task.
I tried, but it affects other parts of the code. You can try too, maybe you'll have a better luck. |
Random crashes :'( fix synfig#3493
Better use safer std::shared_ptr class from standard library.
|
I didn't merge because Synfig is still crashing. I'm currently looking into why this is happening. |
|
Still due to double free problem? |
…more Better use safer std::shared_ptr class from standard library.
2064155 to
dc31e9d
Compare
|
I particularly do not agree with this: synfig/synfig-core/src/synfig/rendering/primitive/contour.cpp Lines 476 to 479 in dc31e9d The code is assigning a Contour to another Contour object, but ties the Intersector, instead of copying it. |
|
Hm... I believe it is due to double free too... |
|
What if this code of Lines 100 to 105 in 5184864 was like this: virtual void unref() const
{
if (--refcount == 0)
delete this;
} |
Nice catch! |
I agree :) |
Avoid this situation: refcount = 2 Thread 1: decrement -> refcount = 1 Thread 2: decrement -> refcount = 0 Thread 1: compare (true) -> self delete Thread 2: compare (true) -> self delete double free or segfault
|
Done the unref() stuff :) |
|
Merged. Thank you! |

Random crashes :'(
fix #3493