Modify

Ticket #1018 (closed Bugs: invalid)

Opened 7 years ago

Last modified 7 years ago

Boost.Python library that is linked to OpenGL results in segfault upon output to std::cerr

Reported by: alanic@… Owned by: dave
Milestone: Component: Python
Version: Boost 1.34.0 Severity: Showstopper
Keywords: python cerr OpenGL Cc:

Description

Hello,

When I write anything to std::cerr in my library that's written using Boost.Python and linked to OpenGL (-lGL), a segfault occurs. This even occurs when you have no OpenGL usage, but link OpenGL to your simplest "hello world" library. Here is the discussion on gmane.comp.python.c++ with additional information:

 http://thread.gmane.org/gmane.comp.python.c++/11443/

And here are two other occurrences of this exact problem in similar situations, which pin this problem to the Boost.Python, OpenGL and std::cerr combination:

 http://mail.datenhain.de/pipermail/libavg-users/2007-March/000085.html  http://vdrift.net/Forum/viewtopic.php?t=528&postdays=0&postorder=asc&start=30

There is no problem in fprintf(stderr, ). I would be happy to assist fixing this bug. I'm attaching the modified libs/python/example/quickstart/extending.cpp from the boost 1.34.0 source tree. This is how I linked it:

"g++" -o "bin/gcc-4.1.2/debug/extending.so" -Wl,-h -Wl,extending.so -shared -Wl,--start-group "bin/gcc-4.1.2/debug/extending.o" "../../../../bin.v2/libs/python/build/gcc-4.1.2/debug/libboost_python-gcc41-d-1_34.so.1.34.0" -L/usr/local/lib -lGL -lutil -lpthread -ldl -Wl,--end-group -g

I got this using bjam -ofile and added -lGL to it. The order of -l flags did not make a difference.

-Gazi

Attachments

extending.cpp Download (1.3 KB) - added by alanic@… 7 years ago.
the simple cpp file
extending.2.cpp Download (1.3 KB) - added by alanic@… 7 years ago.
the simple cpp file
extending.3.cpp Download (1.3 KB) - added by alanic@… 7 years ago.
the simple cpp file
extending.4.cpp Download (1.3 KB) - added by alanic@… 7 years ago.
the simple cpp file

Change History

Changed 7 years ago by alanic@…

the simple cpp file

Changed 7 years ago by alanic@…

the simple cpp file

Changed 7 years ago by alanic@…

the simple cpp file

Changed 7 years ago by alanic@…

the simple cpp file

comment:1 in reply to: ↑ description Changed 7 years ago by alanic@…

Sorry for the many copies of the attachment, boost.org keeps giving HTTP 500.

-Gazi

comment:2 Changed 7 years ago by dave

  • Status changed from new to closed
  • Resolution set to invalid

I tested this and couldn't reproduce it. I was unable to make the link line as shown succeed (I got:

/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status

), so I used this:

"g++" -o "/tmp/bb/boost-python-quickstart/gcc-4.1.2/debug/extending.so" -Wl,-h -Wl,extending.so -shared -Wl,--start-group "/tmp/bb/boost-python-quickstart/gcc-4.1.2/debug/extending.o" "/tmp/bb/boost/bin.v2/libs/python/build/gcc-4.1.2/debug/libboost_python-gcc41-d-1_34_1.so.1.34.1" /usr/lib/libGL.so.1 -lutil -lpthread -ldl -Wl,--end-group -g

which worked (obviously I still don't understand linking well enough). The test ran as follows:

python "test_extending.py"
cerr
cerr
cerr
cerr
cerr
Trying:
    from extending import *
Expecting nothing
ok
Trying:
    hi = hello('California')
Expecting nothing
ok
Trying:
    hi.greet()
Expecting:
    'Hello from California'
cout0 0 0 0
ok
Trying:
    invite(hi)
Expecting:
    'Hello from California! Please come soon!'
cout0 0 0 0
ok
Trying:
    hi.invite()
Expecting:
    'Hello from California! Please come soon!'
cout0 0 0 0
ok
Trying:
    class wordy(hello):
        def greet(self):
            return hello.greet(self) + ', where the weather is fine'
Expecting nothing
ok
Trying:
    hi2 = wordy('Florida')
Expecting nothing
ok
Trying:
    hi2.greet()
Expecting:
    'Hello from Florida, where the weather is fine'
cout0 0 0 0
ok
Trying:
    invite(hi2)
Expecting:
    'Hello from Florida! Please come soon!'
cout0 0 0 0
ok
1 items had no tests:
    test_extending.run
1 items passed all tests:
   9 tests in test_extending
9 tests in 2 items.
9 passed and 0 failed.
Test passed.

EXIT STATUS: 0

If someone can tell me what packages to install on ubuntu in order to reproduce this, I'll be happy to take a look (though I can't imagine what relationship we might have to OpenGL). I seem to have /usr/lib/libGL.so.1 symlinked to /usr/lib/libGL.so.1.2 already on the system. Until then I'm closing the ticket as nonreproducible. Please feel free to reopen.

comment:3 Changed 7 years ago by alanic@…

This turned out to be something related to Python, not Boost.Python. Mesa and Python don't get along well when Mesa is built with NPTL support.

 http://article.gmane.org/gmane.comp.python.c++/11470

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.