Re: Memory fault when i am using a shared object



"Aneesh E Warrier" <vinuwarrier@xxxxxxxxx> writes:

Have you considered the possibility that there is a bug in your code?

I tried that; if I am not invoking any of the functions from the
library still I am getting the memory fault.

That doesn't mean the code from it isn't invoked: shared libraries
have initializers and finalizers, and in fact your crash comes
from finalizer.

In my application there is only one cout statement and return
statement.

It is printing the comment in cout then it is giving memory fault.

No, it isn't. According to your stack trace, main() has *aready*
returned (and printed whatever it was going to print).

You are now beginning the unload process on the shared library. The
first step -- calling finalizer -- is where the crash happens.

#0 0x00a08b22 in std::_Rb_tree<char*, char*, std::_Identity<char*>,
std::less<char*>, std::allocator<char*> >::_S_right (__x=0x3) at

__x is supposed to be a pointer; 0x3 is certainly a bad value.

#1 0x00a08791 in std::_Rb_tree<char*, char*, std::_Identity<char*>,
std::less<char*>, std::allocator<char*> >::_M_erase (this=0x8abbd20, __x=0x3) at
#2 0x00a0879d in std::_Rb_tree<char*, char*, std::_Identity<char*>,
std::less<char*>, std::allocator<char*> >::_M_erase (this=0x8abbd20, __x=0x8abc768)

The bad value came from the frame #2, which is internal to the _Rb_tree.
This means that the "set" sub-object of the BufMgr object has
been corrupted (likely by a bug in BufMgr constructor, or a
constructor for some other global object).

Run your program under valgrind, and fix any errors it finds.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.



Relevant Pages

  • Re: My first .a file, but linker cant resolve references
    ... The order of sources and libraries on the ... > In addition to checking the original source and generating a new set ... "strings" is the wrong tool for examining objects or libraries. ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.programmer)
  • Re: Application cannot find shared object
    ... > BTW, is there a way to add ... > /usr/lib to the list of the search paths that the system looks for ... are a lot of 32-bit libraries there, and every 64-bit process on the ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.programmer)
  • Re: segmentation fault when using shared library
    ... > The old version had static libraries, but the new version has shared. ... How do you know this happened before entering main? ... or with the way your program calls into the "driver" ... In order to understand recursion you must first understand recursion. ...
    (comp.os.linux.development.apps)
  • Re: symbol name corresponding to a address
    ... > addresses for different executables(I discovered it using gdb). ... The libraries are usually loaded into the first ... int main ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.programmer)
  • Re: Overview of Dynamic Linking?
    ... a.out may end up depending on 'libfoo.so', or 'libfoo.so.1', or even ... compiler driver could be adding all kinds of libraries besides glibc. ... In order to understand recursion you must first understand recursion. ...
    (comp.os.linux.development.apps)