[C++-sig] Boost.Python std::cerr segfault when built with -lGL

Gazihan Alankus gazihan at cse.wustl.edu
Wed May 30 10:28:28 CEST 2007

Gazihan Alankus wrote:

> Stefan Seefeld wrote:
>> Have you tried reducing your test case to the point where boost.python
>> isn't part of the setup any more ? It doesn't sound as if your problem is
>> related to neither Python nor boost, in any case.
> Yes, apparently I wasn't right about that -lGL causing that, althought it
> looked like that for the last hour before posting that message. Now it's
> almost randomly based on my build parameters. I'll post later when I
> figure things out. Thanks for the reply.

My doubts were on that I'm not using bjam and I thought my build parameters
could be the cause, but I just disproved it. I edited the sample
libs/python/example/quickstart/extending.cpp to write something to
std::cerr and compiled it using what bjam -o tells me and it ran fine. When
I added -lGL to that and it created the segfault again. So I'm pretty sure
that when I link a Boost.Python library to OpenGL, usage of std::cerr gives
a segfault. gdb tells me it's being encountered in operator<<().
fprintf(stderr, "something") works fine however. And yes, I have no
problems with cerr and OpenGL when Boost.Python is not around. Btw, I
recompiled my gcc (libstdc++ and everything), python, boost and mesa in
case there was some kind of corruption before. 

So I'm not sure how to track this down right now. I have no other problem in
my system, it's obvious to me that the problem must be in Boost.Python or
something related to OpenGL. Since I have no other OpenGL problems, my bets
are on Boost.Python. I modified the simple example in
libs/python/example/quickstart/extending.cpp of the boost 1.34 source to
get this error behavior. Here is the hello class:

  class hello
      hello(const std::string& country) { this->country = country; }
      std::string greet() const {
      std::cout << "cout" << std::cerr.eof() << " " << std::cerr.fail()
<< " " << std::cerr.bad() << " " << std::cerr.exceptions() << "\n";
      std::cerr << "cerr" << "\n";
      return "Hello from " + country;
      std::string country;

And this is what I do in python:

import extending; a = extending.hello('aoeu'); a.greet()

The eof, fail, etc are 0 in both, but I get the segfault when -lGL is there. 

I found out that I'm actually not the only one:

So, any idea how to track this problem down would be appreciated. I hope
this can result in a meaningful bug report in the end. 


More information about the Cplusplus-sig mailing list