Segmentation fault with register_quit

Issue #20 resolved
René Dudfield created an issue

== Markos Gogoulos, 2008-08-06 23:57:53 -0700

{{{ register_quit results in segfault, check the following:

import pygame

def foo(): pass

pygame.register_quit(foo) exit() Segmentation fault

[784.028418] python[14917]: segfault at 00000008 eip 0811270c esp bf899310 error 4

Tested on Ubuntu hardy with python 2.5.2. I was unable to run pygame 1.8 properly on my system to test is as well.

Best regards, Markos Gogoulos }}}

== Lenard Lindstrom, 2009-01-29 18:47:39 -0800

{{{ Python 2.5.4, Windows 98, Pygame 1.9.0.

This is also a Windows bug. The example code causes a page fault.

PYTHON caused an invalid page fault in module PYTHON25.DLL at 015f:1e0711a9.

A Windows related register_quit crash was also noted by Brian Fisher at the automated build site when the Pygame unit test suite was run as a single process. The crash involved PYGAMEinit in registering pygame_quit for every pygame.init() call after the tests ran. The automated builds started crashing after I added a pygame.init() to without a corresponding pygame.quit() call. I found the same problem on my machine, with the error dialog appearing at program completion. The crashes stopped when I pairing every pygame.init() with a pygame.quit() in (rev 1874). }}}

== Lenard Lindstrom, 2009-02-06 21:49:29 -0800

{{{ Quoted directly from the Python 2.5.4 Python/C API Reference Manual

"5.2 Process Control


int Py_AtExit( void (*func) ())

Register a cleanup function to be called by Py_Finalize(). The cleanup function will be called with no arguments and should return no value. At most 32 cleanup functions can be registered. When the registration is successful, Py_AtExit() returns 0; on failure, it returns -1. The cleanup function registered last is called first. Each cleanup function will be called at most once. Since Python's internal finalization will have completed before the cleanup function, no Python APIs should be called by func."

And that is exactly what the Pygame exit function, registered in base.c, does, it makes Python API calls. }}}

== Lenard Lindstrom, 2009-02-08 11:16:55 -0800

{{{ Fixed in revision 1916

Note: Pygame's quit mechanism could stand some reworking at a future date. }}}

Comments (0)

  1. Log in to comment