bomb type not initialized, NULL pointer access on MemoryError #146
Description
Since Stackless 3.2, the module _stackless
is initialized late. Part of this initialization is the call of slp_init_bombtype()
.
If a tasklet (including the main-tasklet) ends with an exception, a bomb is created, that encapsulates the exception (function PyObject * slp_curexc_to_bomb(void) in Stackless/module/scheduling.c). If the exception is a MemoryError, slp_curexc_to_bomb()
does not allocate the bomb-object, but uses a static bomb object, that was allocated during the initialization of the bomb-type in slp_init_bombtype()
. Now, if module _stackless
hasn't been initialized, the out-of-memory-bomb hasn't been allocated and a NULL-pointer access happens.
I discovered the problem, because the newly introduced (d5d7954) test case test.test_exceptions.ExceptionTests.test_memory_error_in_PyErr_PrintEx
failed.
Fix: always initialize the bomb type. And add an assertion to make sure, that the type got initialized.