Crazy bus errors inside HP shared libraries

Crazy bus errors inside HP shared libraries

Post by Ben Ellist » Sat, 23 Nov 1996 04:00:00



Hi all,

I am experiencing a difficult problem on HP-UX 10.10 that I am hoping
someone might have seen before.

I have compiled a shared library (using HP's C++) that, amongst other
things, creates some threads using the libcma library.  Soon after
thread creation (although I can't tell if it is this which is causing
the problem), a call to "new" to allocate a char [] fails with a bus
error.

According to the de*, libC's new routine calls malloc in libC and
subsequently malloc in libc.  It seems that malloc in libc is wrapped by
mutex locks, as the call stack indicates this.

I have a very simple program which uses shl_load() to load the library
and can jump into a library entry point.  The bus errors still occur
when loading the shared library from this simple program.

So, has anyone ever seen bus errors from malloc before?  Is there
anything special I should be doing when linking shared libraries that
use pthreads (or the programs that load them)?  I have _REENTRANT
defined by the compiler at compile time.

Any suggestions would be much appreciated, as this has me totally baffled.

Thanks!

Ben

 
 
 

Crazy bus errors inside HP shared libraries

Post by Doug Siebe » Sat, 23 Nov 1996 04:00:00



>So, has anyone ever seen bus errors from malloc before?  Is there
>anything special I should be doing when linking shared libraries that
>use pthreads (or the programs that load them)?  I have _REENTRANT
>defined by the compiler at compile time.

Happens all the time when your program is passing bad pointers around or
writing out of array bounds, past malloced areas, etc.  If you happen to
*with malloc's internal data structures it will core dump quite nicely.

In other words, look for the bug in your code, not HP's malloc library.

--
Douglas Siebert                Director of Computing Facilities

Ack!  My reality check just bounced!!

 
 
 

Crazy bus errors inside HP shared libraries

Post by Mike Stroy » Sun, 24 Nov 1996 04:00:00


|I am experiencing a difficult problem on HP-UX 10.10 that I am hoping
|someone might have seen before.
|  
|I have compiled a shared library (using HP's C++) that, amongst other
|things, creates some threads using the libcma library.  Soon after
|thread creation (although I can't tell if it is this which is causing
|the problem), a call to "new" to allocate a char [] fails with a bus
|error.
|  
|According to the de*, libC's new routine calls malloc in libC and
|subsequently malloc in libc.  It seems that malloc in libc is wrapped by
|mutex locks, as the call stack indicates this.
|  
|I have a very simple program which uses shl_load() to load the library
|and can jump into a library entry point.  The bus errors still occur
|when loading the shared library from this simple program.

  Note that HP-UX C++ shared libraries should be created with "CC -b"
and loaded with cxxshl_load().  These are discussed in the online help
volume for C++.  Look in particlar at the headings "Creating and Using
Shared Libraries" and "Advanced Shared Library Features".  These may
not be causing the problem that you are currently seeing.  They are
certainly worth correcting.

--

 
 
 

Crazy bus errors inside HP shared libraries

Post by Dennis Hand » Sun, 24 Nov 1996 04:00:00


: I have compiled a shared library (using HP's C++) that
: I have a very simple program which uses shl_load() to load the library

In addition to the things Mike Stroyan mentioned:

You must call cxxshl_load.  Your "program" must be C++, or pretend to
be C++ by calling _main() and being linked with the CC driver.

: So, has anyone ever seen bus errors from malloc before?

You could be corrupting the heap.