Search code examples
cmallocdynamic-library

Problems with memory allocation in dynamic modules


My programm successfully load a library (dlopen(..., RTLD_GLOBAL | RTLD_NOW);). Inside library I have a one function which calls malloc() function. When I try to allocate a small piece of memory (for example, 120 bytes), the function works well. But if I try to get more (for example, 1024 bytes), my application will die with a long report like:

*** glibc detected *** /home/darkamateur/NetBeansProjects/PureServer/dist/Debug/GNU-Linux-x86/pureserver: corrupted double-linked list: 0x00000000006267d0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x731fd)[0x7ffff76d81fd]
/lib64/libc.so.6(+0x7363d)[0x7ffff76d863d]
/lib64/libc.so.6(+0x75994)[0x7ffff76da994]
/lib64/libc.so.6(__libc_malloc+0x62)[0x7ffff76dcfc2]
./libs/omps.blob(systemRun+0x12)[0x7ffff71cd9be]
/home/darkamateur/NetBeansProjects/PureServer/dist/Debug/GNU-Linux-x86/pureserver[0x401f48]
/lib64/libc.so.6(__libc_start_main+0xec)[0x7ffff7683d4c]
/home/darkamateur/NetBeansProjects/PureServer/dist/Debug/GNU-Linux-x86/pureserver[0x400fa9]

There is no any data exchange, shared variables, threads and so on.

Are there some differents between memory allocation in main application and it's dynamic libraries?


Solution

  • Probably has nothing to do with the dynamic libraries -- you're corrupting memory somewhere. valgrind is your friend