error handling not thread safe

Issue #18 resolved
William Roberts created an issue

miniat_error.c does not support thread local storage, thus the interrupt handler mechanism is not thread safe.

Either we could: 1. Use pthread 2. Use C11 thread_local: https://en.wikipedia.org/wiki/Thread-local_storage#C_and_C.2B.2B 3. Go back to return codes... since their are some corner cases in the error handling

Comments (5)

  1. William "Amos" Confer

    I don't believe pthread is supported on windows except in cygwin's posix emulation.

    An SDL dependency could be added to provide portable threads and useful system development resources.

  2. William Roberts reporter

    We've needed sdl before... but im more ok with systems have deps on sdl then the core machine itself. Plus, their oddities in the try catch that are difficult to debug, for instance:

    This psuedo code:

    void *foo = NULL;
    TRY {
    
        foo = malloc(128);
        THROW(5);
    } CATCH(5) {
       if (foo) free(foo);
    }
    

    The state snapshot by the TRY includes *foo being NULL. So when we longjmp back, we throw away the value of foo from the malloc and orphan the pointer. You cannot change state in the TRY and expect it on an exception handler....

  3. Log in to comment