1833759 Members
2134 Online
110063 Solutions
New Discussion

Unwind library.

 
Amrith Anandan
New Member

Unwind library.


I am getting a problem with the unwind library. We are porting a new memory allocator with our own "new" operator. But while testing, the test executable's stack trace is showing the "operator new" in libunwind get referred rather than the new in custom code. This is happening in the IA-64 11.23. I am using the aCC compiler.

There is no explicit reference on the libunwind anywhere.


Stack Trace:-
#0 getMainHoardHeap () at libhoard.cpp:139
#1 0x2000000067867810:0 in initializeCustomHeap () at userealtls.cpp:46
#2 0x2000000067867ab0:0 in getCustomHeap () at userealtls.cpp:55
#3 0x2000000067868680:0 in malloc () at ../../heaplayers/wrapper.cpp:93
#4 0x200000006736a9a0:0 in _Unwind_MemPool::operator new(unsigned long)
+0x40 () from /usr/lib/hpux32/libunwind.so.1
#5 0x2000000067357170:0 in __sinit_com_util_C_+0x30 ()
from /usr/lib/hpux32/libunwind.so.1
#6 0x20000000678b95a0:0 in EM_mark_BOS+0x50 () from /usr/lib/hpux32/dld.so

Because of this the newly defined new operator is not getting invoked and the executable is crashing.

while on PA-RISC this unwind library is not coming in the stack trace. But it is happening in IA-64.
Please let me know, How to resolve this.

Thanks Amrith

1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Unwind library.

>I am getting a problem with the unwind library.

It looks like your bug. You must be prepared to honor malloc requests before you are initialized.

Both libCsup and libunwind must allocate an emergency pool for Exception Handling. (Throwing bad_alloc.) It is libunwind's shared lib init function that is calling your malloc to allocate that space.

>stack trace is showing the "operator new" in libunwind get referred rather than the new in custom code.

Yes, the class operator new is calling malloc directly. It won't call the global operator new.

>while on PA-RISC this unwind library is not coming in the stack trace.

On PA, the exception object is allocated in the stack so an emergency pool isn't needed.