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:33:00 +0100
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 '/'
0x80005280: 0 '\000' 104 'h' 0 '\000' 100 'd' 0
'\000' 49 '1' 0 '\000' 97 'a'
0x80005288: 0 '\000' 47 '/' 0 '\000' 76 'L' 0
'\000' 105 'i' 0 '\000' 98 'b'
0x80005290: 0 '\000' 114 'r' 0 '\000' 97 'a' 0
'\000' 114 'r' 0 '\000' 121 'y'
0x80005298: 0 '\000' 95 '_' 0 '\000' 87 'W' 0
'\000' 101 'e' 0 '\000' 98 'b'
0x800052a0: 0 '\000' 79 'O' 0 '\000' 98 'b' 0
'\000' 106 'j' 0 '\000' 101 'e'
0x800052a8: 0 '\000' 99 'c' 0 '\000' 116 't' 0
'\000' 115 's' 0 '\000' 95 '_'
0x800052b0: 0 '\000' 109 'm' 0 '\000' 97 'a' 0
'\000' 99 'c' 0 '\000' 111 'o'
0x800052b8: 0 '\000' 115 's' 0 '\000' 120 'x' 0
'\000' 115 's' 0 '\000' 101 'e'
0x800052c0: 0 '\000' 114 'r' 0 '\000' 118 'v' 0
'\000' 101 'e' 0 '\000' 114 'r'
0x800052c8: 0 '\000' 47 '/' 0 '\000' 82 'R' 0
'\000' 101 'e' 0 '\000' 108 'l'
0x800052d0: 0 '\000' 101 'e' 0 '\000' 97 'a' 0
'\000' 115 's' 0 '\000' 101 'e'
0x800052d8: 0 '\000' 115 's' 0 '\000' 47 '/' 0
'\000' 52 '4' 0 '\000' 46 '.'
0x800052e0: 0 '\000' 48 '0' 0 '\000' 46 '.' 0
'\000' 49 '1' 0 '\000' 112 'p'
0x800052e8: 0 '\000' 51 '3' 0 '\000' 47 '/' 0
'\000' 83 'S' 0 '\000' 121 'y'
0x800052f0: 0 '\000' 115 's' 0 '\000' 116 't' 0
'\000' 101 'e' 0 '\000' 109 'm'
0x800052f8: 0 '\000' 47 '/' 0 '\000' 76 'L' 0
'\000' 105 'i' 0 '\000' 98 'b'
0x80005300: 0 '\000' 114 'r' 0 '\000' 97 'a' 0
'\000' 114 'r' 0 '\000' 121 'y'
0x80005308: 0 '\000' 47 '/' 0 '\000' 87 'W' 0
'\000' 101 'e' 0 '\000' 98 'b'
0x80005310: 0 '\000' 79 'O' 0 '\000' 98 'b' 0
'\000' 106 'j' 0 '\000' 101 'e'
0x80005318: 0 '\000' 99 'c' 0 '\000' 116 't' 0
'\000' 115 's' 0 '\000' 47 '/'
0x80005320: 0 '\000' 65 'A' 0 '\000' 112 'p' 0
'\000' 112 'p' 0 '\000' 108 'l'
0x80005328: 0 '\000' 105 'i' 0 '\000' 99 'c' 0
'\000' 97 'a' 0 '\000' 116 't'
0x80005330: 0 '\000' 105 'i' 0 '\000' 111 'o' 0
'\000' 110 'n' 0 '\000' 115 's'
0x80005338: 0 '\000' 47 '/' 0 '\000' 80 'P' 0
'\000' 108 'l' 0 '\000' 97 'a'
0x80005340: 0 '\000' 121 'y' 0 '\000' 98 'b' 0
'\000' 97 'a' 0 '\000' 99 'c'
0x80005348: 0 '\000' 107 'k' 0 '\000' 77 'M' 0
'\000' 97 'a' 0 '\000' 110 'n'
0x80005350: 0 '\000' 97 'a' 0 '\000' 103 'g' 0
'\000' 101 'e' 0 '\000' 114 'r'
0x80005358: 0 '\000' 46 '.' 0 '\000' 119 'w' 0
'\000' 111 'o' 0 '\000' 97 'a'
0x80005360: 0 '\000' 47 '/' 0 '\000' 82 'R' 0
'\000' 101 'e' 0 '\000' 115 's'
0x80005368: 0 '\000' 111 'o' 0 '\000' 117 'u' 0
'\000' 114 'r' 0 '\000' 99 'c'
0x80005370: 0 '\000' 101 'e' 0 '\000' 115 's' 0
'\000' 47 '/' 0 '\000' 80 'P'
0x80005378: 0 '\000' 108 'l' 0 '\000' 97 'a' 0
'\000' 121 'y' 0 '\000' 98 'b'
0x80005380: 0 '\000' 97 'a' 0 '\000' 99 'c' 0
'\000' 107 'k' 0 '\000' 77 'M'
0x80005388: 0 '\000' 97 'a' 0 '\000' 110 'n' 0
'\000' 97 'a' 0 '\000' 103 'g'
0x80005390: 0 '\000' 101 'e' 0 '\000' 114 'r' 0
'\000' 46 '.' 0 '\000' 100 'd'
0x80005398: 0 '\000' 98 'b' 0 '\000' 47 '/' 0
'\000' 105 'i' 0 '\000' 110 'n'
0x800053a0: 0 '\000' 100 'd' 0 '\000' 101 'e' 0
'\000' 120 'x' 0 '\000' 47 '/'
0x800053a8: 0 '\000' 72 'H' 0 '\000' 79 'O' 0
'\000' 83 'S' 0 '\000' 84 'T'
0x800053b0: 0 '\000' 95 '_' 0 '\000' 84 'T' 0
'\000' 80 'P' 0 '\000' 66 'B'
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.