[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#365245: strange crash when linked with nvidia GL libraries



Package: libstdc++6
Version: 4.1.0-1+b1
Severity: normal

I came across a strange bug which I'm utterly unable to reproduce on
anything but Debian unstable (including testing on Fedora Core 5).

Basically, I've worked out (through using valgrind and gdb) that calling
ifstream::read() causes a crash because an ios exception destructor calls
free() with an invalid pointer.  The crash only happens when a library that
links against nvidia''s GL libraries is dynamically loaded.  It also only
happens when the library links with the gcc 4.1 standard C++ library.

Below is a testcase.

--
// testmod.cpp
#include <python2.4/Python.h>
#include <iostream>
#include <fstream>
using namespace std;

static PyObject *
testmod_foo(PyObject * /*self*/, PyObject * /*args*/)
{
    ifstream file("/tmp");
    char buffer[5];
    file.read(buffer, 4);

    return Py_None;
}

static PyMethodDef TestmodMethods[] = {
    {"foo",  testmod_foo, METH_VARARGS, "crash."},
    {NULL, NULL, 0, NULL}
};

PyMODINIT_FUNC
inittestmod(void)
{
    Py_InitModule("testmod", TestmodMethods);
}

---

To run this, you need python2.3-dev and nvidia-glx-dev 1.0.8756 installed.
(I haven't actually verified that version 1.0.8756 is required, but this
crash doesn't happen if you're using a different GL driver, like ATI's or
mesa. It also doesn't happen if you don't link against the GL library.)

Run:
g++ -Wall -W -g -shared -o testmod.so -lGL testmod.cpp
echo -e "import testmod\\ntestmod.foo()" | python2.3

What should happen is a simple exit. What does happen:

$ echo -e "import testmod\\ntestmod.foo()" | python2.3
*** glibc detected *** free(): invalid pointer: 0xa7d7aa58 ***
Aborted

It's easy to work around in Debian: install libstdc++6-4.0-dbg, and then
set LD_LIBRARY_PATH to have /usr/lib/debug first. That libstdc++
library, which comes from gcc 4.0, doesn't exhibit the problem.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-1-686-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages libstdc++6 depends on:
ii  gcc-4.1-base                4.1.0-1+b1   The GNU Compiler Collection (base 
ii  libc6                       2.3.6-7      GNU C Library: Shared libraries
ii  libgcc1                     1:4.1.0-1+b1 GCC support library

libstdc++6 recommends no packages.

-- no debconf information



Reply to: