Hello,
I am currently implementing a little project using the sdl2_nim wrapper for SDL2. To handle the sound output I use the openAudio function, which takes an AudioSpec-pointer. A member of this type is a callback function, which is regularly called by SDL2 to obtain more audio. SDL2 does this is by creating a separate thread.
My callback function tries to create an internal seq, using the newSeq function, which crashes the program. Using lldb, I could identify the source being a call to collectCT of gc.nim (line 784), causing a SIGSEGV: invalid address (fault address: 0x50). I also tried manually allocating, using the alloc function, which crashes with SIGSEGV: invalid address (fault address: 0x10d8) when calling findSuitableBlock of alloc.nim (line 180).
I can not think of any other reason for this to fail, other than it being called in separate thread? Are there special considerations to be taken into account when creating a callback function for C-code creating an extra thread where the function will be used?
Informations:
Try calling
setupForeignThreadGC() at the start of that callback or use --gc:arc or --gc:orc :)
Thank you, this seems to work, but I have to also add --tlsEmulation:off.
However I can't try the other gc algorithms, as I am restricted to 1.0 releases. Reason for this is listed in opening post.