[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] bug (and fix?) in mixer.c



Hi,

with SolarWolf 1.0 (great game!) I am
getting the following messages when quiting the game :

On Windows 95 (only after running the other pygame demos)
"PYTHON caused an invalid page fault in
module MSVCRT.DLL at 0157:7800d269."
etc.

On Windows 2000 (pretty much everytime)
"The instruction at "0x77fcb892" referenced memory at 
"0x00007fc0". The memory could not be written."
etc.

I am using :
PyGame 1.1 from CVS (28th July 2001).
The prebuilt, win32-dependencies, for SDL.
Python 2.0.1 Final.


After struggling for a bit (new to SDL, PyGame, and
Python extensions) I think I have found the problem:

File:    "pygame/src/mixer.c"

In function initmixer(void), line 1142

 music = PyImport_ImportModule("pygame.mixer_music");
 if(music) 
 {
  PyObject* ptr, *dict;
  PyModule_AddObject(module, "music", music);
  dict = PyModule_GetDict(music);
  ptr = PyDict_GetItemString(dict, "_MUSIC_POINTER");
  current_music = (Mix_Music**)PyCObject_AsVoidPtr(ptr);
  /***** Py_DECREF(music);   I believe this line needs removing *****/
 } 


As I understand it, PyImport_ImportModule(...) returns a new
reference, PyModule_AddObject(...) *steals a reference* and
Py_DECREF(...) is freeing up memory that is actually in use!

Let me know if this is correct as I would like
to get on with using PyGame for something fun,

cheers,
John.



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org