1832346 Members
2293 Online
110041 Solutions
New Discussion

Re: malloc in thread

 
Ye Liu
New Member

malloc in thread

Hi.

I hit a code dump problem in one of my running thread. In that thread function, I call some odbc function and hit the core dump when the odbc function try to allocate memory by using malloc. The stacktrace is sth. like:

#0 0x75f450c8 in mallinfo () from /usr/lib/libc.2
#1 0x75f41ccc in malloc () from /usr/lib/libc.2
#2 0x75f29c7c in calloc () from /usr/lib/libc.2
#3 0x74b6c5f4 in nsbal ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#4 0x74b2e018 in nsprecv ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#5 0x74bad560 in nscon ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#6 0x74b6f1b0 in nsdo () from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#7 0x74bac90c in nscall3 ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#8 0x74babb10 in nscall ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#9 0x74b7fe8c in niotns ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#10 0x74b351e0 in nigcall ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#11 0x74b15338 in osncon ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#12 0x74a57190 in upiini ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#13 0x74a46b98 in upiah0 ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#14 0x74a20554 in kpuatch ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#15 0x74a3a1f8 in OCIServerAttach ()
from /local/app/oracle/product/8.1.5/lib/libclntsh.sl
#16 0x75028120 in ?? () from /local1/odbc/3.60/lib/ivor815.sl
#17 0x7471776c in ?? () from /local1/odbc/3.60/lib/libivbas15.sl
#18 0x74714c3c in ?? () from /local1/odbc/3.60/lib/libivbas15.sl
Error accessing memory address 0x0: Invalid argument.

My explanation is that: the malloc() call in the working thread is not allocating memory from heap instead from the thread stack?
Can you HP-UX expert explan to me?

Thanks a lot!

--ye
2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: malloc in thread

A signal in malloc is usually an indication of heap corruption.

>in the working thread

The stack trace didn't go all the way back but if this is in a thread, it could be a thread stack overflow.
Laurent Menase
Honored Contributor

Re: malloc in thread

Hi,

In more than 99% of cases you corrupted the heap head.
in 50% of the case it is when you malloc() a string of 1 byte less what it is needed, usually malloc(strlen(mystring)) when it should be malloc(strlen(mystring)+1)