It segfaults because it attempts to access the buffer of an mmap that has been closed. It would be certainly be more friendly if it checked whether the mmap was still open and, if not, raised an exception instead.
In the function "getstring" in _sre.c, the code obtains a pointer to the characters of the buffer and then releases the buffer. There's a comment before the release: /* Release the buffer immediately --- possibly dangerous but doing something else would require some re-factoring */ PyBuffer_Release(&view); What's happening is that after the mmap is closed the pointer is no longer valid.