Author vstinner
Recipients martin.panter, serhiy.storchaka, vstinner
Date 2015-11-30.08:18:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Assertion failed: !PyErr_Occurred(), file Objects/abstract.c, line 2158

Quick reminder: it's not a major bug if PyObject_Call() is called with an exception set. The exception will be kept in some cases. But I added the assertion because the exception is lost in some other cases. Example: calling hasattr(obj, name) replaces the current exception with an AttributeError and then clears the AttributeError exception if the object doesn't have the attribute.

> My guess is that fork() has failed,

Oh good job, it's exactly that: I'm able to reproduce the bug with your unit test (from your attached patch).

If I recall correctly, there is no overallocation on Solaris (OpenIndiana), and this buildbot is running low memory (MemoryError is very common). fork() can likely fail under low memory.

> and because preexec_fn is in use, the code tries to call gc.enable() with the fork() exception already set. My patch adds a test and fixes that.

Hum, I think that your patch can be simplified. Replace:

    if (pid == -1) {
    if (need_to_reenable_gc && _enable_gc(gc_module)) ...


    if (need_to_reenable_gc && _enable_gc(gc_module)) ...
    if (pid == -1) {

What do you think?

> Victor already fixed a similar error for the cleanup branch of subprocess_fork_exec() in Issue 22290.

I reproduced the issue on Linux with pyfailmalloc.

You can play with pyfailmalloc to try to find similar bugs. The Bitbucket repository contains the latest debug_cpython.patch which adds some more checks to make the analysis faster and more effective, and debug_cpython.gdb contains commands to run it.
Date User Action Args
2015-11-30 08:18:40vstinnersetrecipients: + vstinner, martin.panter, serhiy.storchaka
2015-11-30 08:18:40vstinnersetmessageid: <>
2015-11-30 08:18:40vstinnerlinkissue25764 messages
2015-11-30 08:18:39vstinnercreate