Bugs item #1419652, was opened at 2006-01-31 04:19
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1419652&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: coder_5 (coder_5)
>Assigned to: Martin v. Löwis (loewis)
Summary: PyImport_AppendInittab stores pointer to parameter

Initial Comment:
signature is:

int PyImport_AppendInittab(char *name, void
(*initfunc)(void))

if the 'name' pointer is freed or overwritten directly
after the call to PyImport_AppendInittab, this call
returns true but fails making the module known, and the
interpreter crashes on PyFinalize();
this suggests that PyImport_AppendInittab stores the
name pointer and uses it later, after leaving this
function. this is undocumented and leads to crashes if
name is freed in the meantime. (a typical c problem)

this function is important to boost::python library to
extend python with c++.

workaround for c/c++ users:
-malloc a char* for the name,
-copy the modulename to name
-call PyImport_AppendInittab with this name
-DONT free name. (leaving a memory-leak)


btw, 'char *' should be 'const char*', but this applies
to most other Python API functions.

----------------------------------------------------------------------

>Comment By: Georg Brandl (birkenfeld)
Date: 2006-02-17 19:47

Message:
Logged In: YES 
user_id=1188172

Should AppendInittab() itself malloc a char buffer?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1419652&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to