Malloc-related error detected with code N / NSHangOnMallocError?
Malloc-related error detected with code N / NSHangOnMallocError?
- Subject: Malloc-related error detected with code N / NSHangOnMallocError?
- From: Piers Uso Walter <email@hidden>
- Date: Mon, 25 Mar 2002 01:52:22 +0100
[Repost to meet the 8 kB limit of this list. Advance apologies if the
longer version will eventually get through as well]
I'm trying to find a memory related bug that eventually causes the
program to crash. Before the tool crashes, many lines of "Malloc-related
error detected with code 5" are being written to stdout.
Looking at NSDebug.h, I found that I can set the environment variable
NSHangOnMallocError to make the process hang after it has written the
first of these lines. And sure enough, it hangs and I can break
execution in the debugger.
At this point, strange things are going on (see below), none of which so
far has led me to the bug.
In an attempt to understand the kind of memory problem that I'm dealing
with, I wonder if anybody knows where to look for explanations of the
code numbers that are being reported by the error message (code 5 in my
case)?
Oh, and since the program crashes after having accumulated lots of
virtual memory (due to NSDeallocateZombies=NO), with the swapfile having
grown to 1.9 GB (under Mac OS X Server 1.2), I wonder if I may be
getting close to some system limit, e.g. maximum memory per process.
So I'd be very grateful if somebody could give me some pointers
regarding maximum VM per process, maximum size of the swapfile, etc.
(again: this is under Mac OS X Server 1.2).
With kind regards
Piers Uso Walter <email@hidden>
ilink Kommunikationssysteme GmbH
PS. two examples of what I'm dealing with in the debugger
Sometimes, NSString's stringByAppendingPathComponent: method returns an
invalid object, even though it has been called on two seemingly fine
objects (check out the address of c after the following call):
c = [a stringByAppendingPathComponent:b];
(gdb) p a
$41 = (class NSString *) 0x7ff887b8
(gdb) po a
/private/export/hd1a/Library_WebObjects_macosxserver/Releases/4.0.1p3/System/
Library/WebObjects/Applications/PlaybackManager.woa/Resources/PlaybackManager.
db/index
(gdb) p [a retainCount]
$43 = (void *) 0x2
(gdb) po [a class]
NSPathStore2
(gdb) po [a superclass]
NSString
(gdb) p b
$39 = (class NSString *) 0x7ff8ca48
(gdb) po b
TEST_SEQ.ID_TPB.index
(gdb) p [b retainCount]
$42 = (void *) 0x3
(gdb) po [b class]
NSInlineCString
(gdb) po [b superclass]
NSString
(gdb) p c
$40 = (class NSString *) 0x3e
(gdb) po c
<not an object>
During another debug session, the address of c looked much better, but I
could not print the description of this string object. After playing
around with this a little bit in the debugger, suddenly I was able to do
"po c". Very strange. The only thing that I can see which might have had
an effect is the additional retain that I called in order to understand
how NSPathStore2 stores both the length and the retain count in a single
int. Still I don't understand, why I initially cannot call "po c" and
afterwards can do so.
(gdb) p c
$1 = (class NSString *) 0x80005258
(gdb) po c
Program received signal SIGILL, Illegal instruction.
<function called from gdb>
The program being debugged stopped while in a function called from GDB.
When the function (_NSPrintForDebugger) is done executing, GDB will
silently
stop (instead of continuing to evaluate the expression containing
the function call).
(gdb) up 11
(gdb) po b
HOST_TPB._rowid.index
(gdb) po a
/private/export/hd1a/Library_WebObjects_macosxserver/Releases/4.0.1p3/System/
Library/WebObjects/Applications/PlaybackManager.woa/Resources/PlaybackManager.
db/index
(gdb) p c.isa
$2 = (struct objc_class *) 0x4263133c
(gdb) po 0x4263133c
NSPathStore2
(gdb) p (int)[c retainCount]
$3 = 1
(gdb) p (int)[c cStringLength]
$4 = 185
(gdb) p (char *)[c cString]
$5 = 0x8000a3e8
"/private/export/hd1a/Library_WebObjects_macosxserver/Releases/4.0.1p3/System/
Library/WebObjects/Applications/PlaybackManager.woa/Resources/PlaybackManager.
db/index/HOST_TPB._rowid.index"
(gdb) p c
$6 = (class NSString *) 0x80005258
(gdb) x/2 0x80005258
0x80005258: 0x4263133c 0x0b900000
(gdb) p (int)[0x80005258 length]
$9 = 185
(gdb) p (int)[0x80005258 retainCount]
$10 = 1
(gdb) p (int)[0x80005258 retain]
$11 = -2147462568
(gdb) x/2x 0x80005258
0x80005258: 0x4263133c 0x0b900001
(gdb) x/375cb 0x80005260
0x80005260: 0 '\000' 47 '/' 0 '\000' 112 'p' 0
'\000' 114 'r' 0 '\000' 105 'i'
0x80005268: 0 '\000' 118 'v' 0 '\000' 97 'a' 0
'\000' 116 't' 0 '\000' 101 'e'
0x80005270: 0 '\000' 47 '/' 0 '\000' 101 'e' 0
'\000' 120 'x' 0 '\000' 112 'p'
0x80005278: 0 '\000' 111 'o' 0 '\000' 114 'r' 0
'\000' 116 't' 0 '\000' 47 '/'
...
0x800053b8: 0 '\000' 46 '.' 0 '\000' 95 '_' 0
'\000' 114 'r' 0 '\000' 111 'o'
0x800053c0: 0 '\000' 119 'w' 0 '\000' 105 'i' 0
'\000' 100 'd' 0 '\000' 46 '.'
0x800053c8: 0 '\000' 105 'i' 0 '\000' 110 'n' 0
'\000' 100 'd' 0 '\000' 101 'e'
0x800053d0: 0 '\000' 120 'x' 0 '\000' 0 '\000' 0
'\000' 0 '\000' 0 '\000'
(gdb) po c
/private/export/hd1a/Library_WebObjects_macosxserver/Releases/4.0.1p3/System/
Library/WebObjects/Applications/PlaybackManager.woa/Resources/PlaybackManager.
db/index/HOST_TPB._rowid.index
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.