I am new to libffi, so forgive me for my ignorance.
I have a python crash involving ctypes and functions callbacks (read
closures) and fork. The crash happens when process is forked, some
callbacks are modified and a function callback is made. I suspect that
the problem could be related to libffi closures and fork.
dlmmap() at libffi/closures.c allocates memory block that has to be
both read-write and read-execute. To achieve that, libffi creates a
temp file and performs two mmap-s to the that file, the first
read-write and the 2nd read-execute.
The thing is that those maps are marked as shared. Hence when the
process is forked the allocated(mapped) memory block is *shared*
between the processes (and not copied-on-write). So, when father
process changes something in that memory block, the child process will
be affected as well, creating unplanned shared-memory block between
the two processes. I suspect that this is not the intended behavior
and that it leads to the crash.