Aix xlc interesting SEGV on exit

Hello all,

One of the application we port to Aix from linux Segmentation faults when it exits. Here is part of backtrace of SEGV:
(dbx) where
splay(??, ??, ??) at
free_y(??, ??) at
free_common(??) at
....
exit(??) at
...

Application seem to perform everything expected well and while exiting it SEGV. By doing lot of googling learnt this could be due to heap corruption.

Tried the following:

  1. setenv MALLOCDEBUG verbose

Result:
Malloc Report: The address passed to free, <x>, is
outside the valid range of addresses allocated by malloc (errno = 2).

  1. setenv MALLOCTYPE debug
    Run the application no SEGV at all. It exits normally.

  2. setenv MALLOCTYPE watson
    setenv MALLOCDEBUG catch_overflow

Run the application no SEGV at all. It exits normally.

Tried running same application same way with valgrind, totalview, MEMORY_CHECK_2 in linux to find potential coding error but found none.

Queries:

  1. How can I find what is happening in memory address "x"? Who changes/disturbs it? Tried setting a watchpoint for that location but the error was:
    Unreadable instruction at address 0x10000000
    What else can i do? How can I find what happens in this location?

  2. What difference does malloctype debug/watson does compared to default(yoktown)? Why isn't there a SEGV at that time?

  3. Is there any tool to watch/examine heap?

  4. Is there any other tool/option which could be used to debug this problem further?

Any pointers/suggestions/help is most welcome

Thanks in advance.

While i can't help you directly with your problem (stopped programming way too long ago and never did it under AIX) here are some general pointers which might help you:

Try the AIX programmers reference offered at the Max Planck Institute for Solid State Research, Stuttgart:

AIX Documentation: Programmer's Reference

It is for AIX 5.2, which might not be the release you are using, but maybe the problem is not version-dependent.

You may know the standard debugger "dbx", but you might not know the kernel debugger "kdb". Beware, though! This is a quite dangerous tool, you could easily crash the machine.

Lastly, we have a special forum for High-Level Programming in Unix environments. You might want to pass this thread over to there. Give me (any mod) a short note if you want to do this.

I hope this helps.

bakunin