Physac icon indicating copy to clipboard operation
Physac copied to clipboard

Heap use after free in examples

Open raysan5 opened this issue 6 years ago • 0 comments

Related issues: https://github.com/raysan5/raylib/issues/485 and https://github.com/raysan5/raylib/issues/486

As stated by another user by mail, those issues seem related to:

...when you call reset the code is still running in the thread... so while it iterating over the items, suddenly they are removed and of course you will get floating point errors and access violations. Also destroying and item while iterating over the list, will cause these problems too.

...basically in a thread environment, you have to project critical sections with semaphores.... I basically flatten the PhysicsLoop into a routine called PhysicsThread... and then have my own loop that calls PhysicsThread and I wrap this in critical sections (pseudocode:

procedure physics_loop
begin
    repeat 
        lock.enter;
        PhysicsThread;
        lock.leave
    until done = true;
end;

raysan5 avatar Apr 29 '18 16:04 raysan5