A couple of replies with respect to a "segfault" problem on Debian
(and also on my highly non-standard Caldera) mentioned problems
with passing const char * pointers. Those points may be valid,
but consider the original method causing the problem:
void PythonType::name( const char* nam )
{
table->tp_name = const_cast<char *>( name );
}
I bet that line should be:
table->tp_name = const_cast<char *>( nam );
Otherwise, the code is storing a pointer to the method
and not the string -- a simple typo.
Changing it this way fixes the segfault on my Caldera system.
Cheers, and thanks for making it easy for me to fix
the problem get VPython to run ..
neal
FROM: Bruce Sherwood
DATE: 04/26/2002 06:40:58
SUBJECT: [Visualpython-users] Trouble installing on Debian
> Here is some nice detective work by Yves Bailly in France. I should
> incorporate his change, but in the meantime here is what he found. I'm
> puzzled that others running on Debian did not run into this problem.
>
> Bruce Sherwood
>
> --On Friday, April 26, 2002 1:57 AM +0200 Yves BAILLY
> <<EMAIL: PROTECTED>> wrote:
>
> > Hello,
> >
> > First of all, I have to say : contragulation for your great work !
> >
> > Now, my problem :
> > I tried to install VPython on a Debian "sid", using :
> > - Python 2.2.1
> > - Numeric 21.0
> > - GtkGlArea 1.2.3
> > - Mesa which comes with XFree86 4.1.0
> >
> > Everything compiles fine, but when running
> > from visual import *
> > ...I was always getting a segfault.
> >
> > I dig a little bit, and found this in cvisual/CXX/Src/cxx_extensions.cxx :
> > void PythonType::name( const char* nam )
> > {
> > table->tp_name = const_cast<char *>( name );
> > }
> > The segfault seemed to occure during this method.
> >
> > Considering the char* is a rather strange thing, that should always be
> > used with care, moreover when you give a litteral string to a function,
> > I just modified this method a little, to allocate and duplicate the
> > string :
> > void PythonType::name( const char* nam )
> > {
> > char* str = new char[strlen(nam)+1] ;
> > strcpy(str, nam) ;
> > table->tp_name = const_cast<char *>( str );
> > }
> >
> > ...and now it works fine, I can even use the KineticsKit !
> >
> > Just a quick hack, for sure there should something better (nicer).
> >
> > Best regards,
> >
> > --
> > ( | Yves Bailly : http://kafka-fr.net | -
> > //\ | Linux Dijon : http://www.coagul.org | //\
> > \_/ | Don d'organe : http://adot21.free.fr | \_/`
>
--
Neal Holtz http://www.docuweb.ca/~nholtz
Dept. of Civil and Environmental Engineering, Carleton University,
Ottawa, Ontario, Canada K1S 5B6. nh...@do...
|