#Stack based UAF
23 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
shared_ptr 😄
Looking to solve without allocating on the heap
Object B is stack allocated
heritance ?
so maybe you could try this #cpp-help-text message
mostly to figure out if that is indeed the problem
because normally, if the local variable engine gets constructed after the local variable physicsEngine, then it should get destroyed first
Now no segfault on exit, but what I had to do to get it to compile this way made sure the rest of the program didn't run
how so?
the entire update loop and rendering expects engine to be present
ah, but couldn't you move that into this new function too?
like, all I wanted to do was to make sure that engine gets destructed before physicsEngine, such that you can clearly see in a debugger when each step happens
Oh wait, know I know what you mean, I just put the engine creation and loop in a scope
yeah
I added that it still crashed, I noticed null checks were missing, I added those and now it works without scope. But for anyone trying to read this in the future. The scope can work to fix this.
but so the problem wasn't actually related to scoped or order of destruction, but to missing null checks?
yeah. but the debugger decided to not show me that.
yeah I figured
but after scope, it showed me everything