Segmentation fault from inside transforms

I'm trying to build matplotlib and I'm getting a segmentation

    > fault when I do: from matplotlib import *

    > I've traced the fault down to the transforms module.

    > My first attempt used: gcc 3.3.2 Python 2.3.3 numarray 1.1
    > gdmodule 0.52 gd 2.0.28 freetype 2.1.9 agg 22 matplotlib
    > 0.63.4

Standard issue stuff - very close to what most people are using w/o
incident. Hmmmm....

    > In this version _na_transform segementation faults at this
    > line: static _transforms_module* _transforms = new
    > _transforms_module;

    > I traced the fault down to the ExtensionModuleBaseClass where
    > it attempts to call: __Py_PackageContext()

    > It looks to me like this function is trying to access the
    > variable (which it dereferences WITHOUT checking for a null
    > pointer). static char **ptr__Py_PackageContext = NULL;

Could you try editing it an adding the NULL test; if this works can
you submit a patch pack to be and a bug report to the pycxx sf site?

    > This ptr gets init'ed in the function
    > InitialisePythonIndirectInterface() but I can't find anywhere
    > that function is being called.

    > FYI: I also tried matplotlib 0.62.4 and I get the same error.

It couldn't be the exact same error, because _na_transforms did not
exist in 0.62.4. Do you mean that you got a segfault on the same line
in _transform?

Thanks,
JDH

It couldn't be the exact same error, because _na_transforms did not
exist in 0.62.4. Do you mean that you got a segfault on the same line
in _transform?

Sorry - that's what I meant. It looks like I was a little mistaken. I didn't realize that there are 2 versions of __Py_PackageContext() in the same file. I was orginally looking at the Windows version (I'm building on linux).

However, if the linux version looks like this (unmodified):

char *__Py_PackageContext() { return _Py_PackageContext; }

I get a segmentation fault at the return line.

I then added a print statement to it:

char *__Py_PackageContext()
{
    std::cerr << "context 0\n";
    return _Py_PackageContext;
}

and then everything works! Off the top of my head, it might be a case of C++ static object initialization problems but I can't find any obvious places that might be happening.

Ted

···

At 01:00 PM 10/21/2004, John Hunter wrote:

    > I'm trying to build matplotlib and I'm getting a segmentation
    > fault when I do: from matplotlib import *

    > I've traced the fault down to the transforms module.

    > My first attempt used: gcc 3.3.2 Python 2.3.3 numarray 1.1
    > gdmodule 0.52 gd 2.0.28 freetype 2.1.9 agg 22 matplotlib
    > 0.63.4

Standard issue stuff - very close to what most people are using w/o
incident. Hmmmm....

    > In this version _na_transform segementation faults at this
    > line: static _transforms_module* _transforms = new
    > _transforms_module;

    > I traced the fault down to the ExtensionModuleBaseClass where
    > it attempts to call: __Py_PackageContext()

    > It looks to me like this function is trying to access the
    > variable (which it dereferences WITHOUT checking for a null
    > pointer). static char **ptr__Py_PackageContext = NULL;

Could you try editing it an adding the NULL test; if this works can
you submit a patch pack to be and a bug report to the pycxx sf site?

    > This ptr gets init'ed in the function
    > InitialisePythonIndirectInterface() but I can't find anywhere
    > that function is being called.

    > FYI: I also tried matplotlib 0.62.4 and I get the same error.

It couldn't be the exact same error, because _na_transforms did not
exist in 0.62.4. Do you mean that you got a segfault on the same line
in _transform?

Thanks,
JDH

Check for matplotlib/_transforms.so left over from prior installations
and blow away your old matplotlib and re-install if you find it. Before
you re-install, also blow away matplotlib/build.

Todd

···

On Thu, 2004-10-21 at 16:00, John Hunter wrote:

    > I'm trying to build matplotlib and I'm getting a segmentation
    > fault when I do: from matplotlib import *

    > I've traced the fault down to the transforms module.

    > My first attempt used: gcc 3.3.2 Python 2.3.3 numarray 1.1
    > gdmodule 0.52 gd 2.0.28 freetype 2.1.9 agg 22 matplotlib
    > 0.63.4

Standard issue stuff - very close to what most people are using w/o
incident. Hmmmm....

    > In this version _na_transform segementation faults at this
    > line: static _transforms_module* _transforms = new
    > _transforms_module;

    > I traced the fault down to the ExtensionModuleBaseClass where
    > it attempts to call: __Py_PackageContext()

    > It looks to me like this function is trying to access the
    > variable (which it dereferences WITHOUT checking for a null
    > pointer). static char **ptr__Py_PackageContext = NULL;

Could you try editing it an adding the NULL test; if this works can
you submit a patch pack to be and a bug report to the pycxx sf site?

    > This ptr gets init'ed in the function
    > InitialisePythonIndirectInterface() but I can't find anywhere
    > that function is being called.

    > FYI: I also tried matplotlib 0.62.4 and I get the same error.

It couldn't be the exact same error, because _na_transforms did not
exist in 0.62.4. Do you mean that you got a segfault on the same line
in _transform?

Well I have somewhat good news. I was using an older machine (RedHat7) when I had these problems. I went to a much newer redhat machine and everything works fine. Same version of Python, gcc, etc - just a newer operating system.

I guess I'll just ignore this problem and stick with the newer machine.

Ted

···

At 01:47 PM 10/21/2004, Todd Miller wrote:

On Thu, 2004-10-21 at 16:00, John Hunter wrote:

>
> > I'm trying to build matplotlib and I'm getting a segmentation
> > fault when I do: from matplotlib import *
>
> > I've traced the fault down to the transforms module.
>
> > My first attempt used: gcc 3.3.2 Python 2.3.3 numarray 1.1
> > gdmodule 0.52 gd 2.0.28 freetype 2.1.9 agg 22 matplotlib
> > 0.63.4
>
> Standard issue stuff - very close to what most people are using w/o
> incident. Hmmmm....
>
> > In this version _na_transform segementation faults at this
> > line: static _transforms_module* _transforms = new
> > _transforms_module;
>
> > I traced the fault down to the ExtensionModuleBaseClass where
> > it attempts to call: __Py_PackageContext()
>
> > It looks to me like this function is trying to access the
> > variable (which it dereferences WITHOUT checking for a null
> > pointer). static char **ptr__Py_PackageContext = NULL;
>
> Could you try editing it an adding the NULL test; if this works can
> you submit a patch pack to be and a bug report to the pycxx sf site?
>
> > This ptr gets init'ed in the function
> > InitialisePythonIndirectInterface() but I can't find anywhere
> > that function is being called.
>
> > FYI: I also tried matplotlib 0.62.4 and I get the same error.
>
> It couldn't be the exact same error, because _na_transforms did not
> exist in 0.62.4. Do you mean that you got a segfault on the same line
> in _transform?

Check for matplotlib/_transforms.so left over from prior installations
and blow away your old matplotlib and re-install if you find it. Before
you re-install, also blow away matplotlib/build.

Todd