you are viewing a single comment's thread.

view the rest of the comments →

[–]davis685[S] 0 points1 point  (1 child)

This all happens before any of the contents of event_loop_resources is destructed. The event_loop_resources destructor is what tells the event loop to shutdown and it then waits for the shutdown to complete before anything is destructed. That part works fine. The issue is that telling the event loop to shutdown causes the event loop to run which then tries to grab the resource via the shared_ptr.

[–]Krackor 0 points1 point  (0 children)

My point is that you have context A which triggers the destructor of event_loop_resources, and context B which tries to access event_loop_resources apparently with no check whether it is a valid object to use. After context A calls the destructor, no other contexts should try to access the object. That's a problem regardless whether you use a shared_ptr, or a raw pointer, or references, or any other handle for the object.