Python source sensitive to PyObject_HEAD layout?

P

Petter Haggholm

For academic reasons, I'm hacking on the Python source trying to add
some new capabilities. At present, I'm making minor changes mostly to
familiarise myself with the code and gain awareness of what issues I
may encounter, with the result that I encountered a fairly strange one
(to me, anyway).

As I wanted to add new fields to all Python objects, it seemed to make
the most sense to add them to PyObject_HEAD. When I added an int field
to the end of PyObject_HEAD, however, the make process failed (see
below). This was on a Pentium-M running GCC 3.4.6 under Gentoo Linux. I
switched to my other computer, and Athlon 64 running GCC 4.1.0 under
Gentoo Linux, and it compiled; I dismissed the earlier failure as an
irritating but fixed GCC bug, and went on---until I added another int
field and ran into a failure at exactly the same place.

The error looks fairly uninformative, as such:

/bin/sh: line 1: 6926 Segmentation fault CC='gcc -pthread'
LDSHARED='gcc -pthread -shared' OPT='-DNDEBUG -g -O3 -Wall
-Wstrict-prototypes' ./python -E ./setup.py build
make: *** [sharedmods] Error 139

I can supply more information if desired (I ran a GDB backtrace), but
it really didn't tell me very much. None of the functions on the stack
were ones I had modified, so the only factor is the presence of that
second additional field in PyObject_HEAD (I can make it build by simply
commenting out that field and its initialiser in PyObject_HEAD_INIT).

My question is therefore a vague, nebulous, open, and at least mildly
desperate one: What is the problem? The only notion that occurs to me
is that some part of the Python source is somehow upset by alignment
issues (or padding of some sort); if so then I have no clue where that
might be. If not, then I have no idea what's causing the errors at all.

Any help, thoughts, or advice would be vastly appreciated.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Petter said:
Any help, thoughts, or advice would be vastly appreciated.

After changing PyObject_HEAD, I would run "make distclean".
Most likely, some object files were not recompiled and still
using the old layout.

Regards,
Martin
 
P

Petter Haggholm

Boy, do I feel foolish! I hang my head in shame and thank you for your
assistance---that solved it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top