NSCell copyWithZone producing EXC_BAD_ACCESS

  • My application worked without problems in Tiger but crashes in Leopard
    as follows...

    I am using an NSBrowser for which I am supplying a custom cell class
    called SelectionCell (inherits from NSBrowserCell).
    I set the prototype in the browser's matrix as follows:

    [matrix setPrototype:[SelectionCell alloc]];

    and this is where I get the crash, with the following stack trace:

    #0    0x9006c9a7 in -[NSCell copyWithZone:]
    #1    0x9025da12 in -[NSMatrix setPrototype:]
    #2    0x00008074 in -[BrowserDelegate
    browser:createRowsForColumn:inMatrix:] at BrowserDelegate.m:262
    #3    0x903fc24c in -[NSBrowser _sendDelegateCreateRowsForColumn:inMatrix:]
    #4    0x902724b7 in -[NSBrowser addColumn]
    #5    0x90271725 in -[NSBrowser loadColumnZero]
    #6    0x000056a0 in -[Controller startup] at Controller.m:417
    #7    0x000041f9 in -[Controller getToken] at Controller.m:236
    #8    0x000046ed in -[Controller carryOn:] at Controller.m:280
    #9    0x90114f94 in -[NSApplication sendAction:to:from:]
    #10    0x90114ed4 in -[NSControl sendAction:to:]
    #11    0x90114d5a in -[NSCell _sendActionFrom:]
    #12    0x901143bb in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
    #13    0x90113c12 in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
    #14    0x901134cc in -[NSControl mouseDown:]
    #15    0x90111d9b in -[NSWindow sendEvent:]
    #16    0x900dea2c in -[NSApplication sendEvent:]
    #17    0x9003c705 in -[NSApplication run]
    #18    0x900099ba in NSApplicationMain
    #19    0x00002638 in main at main.m:6

    The setPrototype immediately causes the copyWithZone message to the
    underlying NSCell and this causes a EXC_BAD_ACCESS signal for some
    reason.

    Any ideas as to the problem would be appreciated.
  • On Nov 11, 2007, at 3:21 PM, Graham wrote:

    > My application worked without problems in Tiger but crashes in
    > Leopard as follows...
    >
    > I am using an NSBrowser for which I am supplying a custom cell class
    > called SelectionCell (inherits from NSBrowserCell).
    > I set the prototype in the browser's matrix as follows:
    >
    > [matrix setPrototype:[SelectionCell alloc]];

    You're not calling an init method here.

    > and this is where I get the crash, with the following stack trace:
    >
    > #0    0x9006c9a7 in -[NSCell copyWithZone:]
    > #1    0x9025da12 in -[NSMatrix setPrototype:]
    > #2    0x00008074 in -[BrowserDelegate
    > browser:createRowsForColumn:inMatrix:] at BrowserDelegate.m:262
    > #3    0x903fc24c in -[NSBrowser
    > _sendDelegateCreateRowsForColumn:inMatrix:]
    > #4    0x902724b7 in -[NSBrowser addColumn]
    > #5    0x90271725 in -[NSBrowser loadColumnZero]
    > #6    0x000056a0 in -[Controller startup] at Controller.m:417
    > #7    0x000041f9 in -[Controller getToken] at Controller.m:236
    > #8    0x000046ed in -[Controller carryOn:] at Controller.m:280
    > #9    0x90114f94 in -[NSApplication sendAction:to:from:]
    > #10    0x90114ed4 in -[NSControl sendAction:to:]
    > #11    0x90114d5a in -[NSCell _sendActionFrom:]
    > #12    0x901143bb in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
    > #13    0x90113c12 in -[NSButtonCell
    > trackMouse:inRect:ofView:untilMouseUp:]
    > #14    0x901134cc in -[NSControl mouseDown:]
    > #15    0x90111d9b in -[NSWindow sendEvent:]
    > #16    0x900dea2c in -[NSApplication sendEvent:]
    > #17    0x9003c705 in -[NSApplication run]
    > #18    0x900099ba in NSApplicationMain
    > #19    0x00002638 in main at main.m:6

    BTW, I'm quite surprised this didn't cause an issue under Tiger.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
  • Thanks Ricky, that was it.

    As you can tell, I'm still a bit of a newbie at OCJ-C, and yes, how on
    earth has this been working for over a year pre-Leopard??

    On Nov 11, 2007, at 4:51 PM, Ricky Sharp wrote:

    On Nov 11, 2007, at 3:21 PM, Graham wrote:

    > My application worked without problems in Tiger but crashes in
    > Leopard as follows...
    >
    > I am using an NSBrowser for which I am supplying a custom cell class
    > called SelectionCell (inherits from NSBrowserCell).
    > I set the prototype in the browser's matrix as follows:
    >
    > [matrix setPrototype:[SelectionCell alloc]];

    You're not calling an init method here.

    > and this is where I get the crash, with the following stack trace:
    >
    > #0    0x9006c9a7 in -[NSCell copyWithZone:]
    > #1    0x9025da12 in -[NSMatrix setPrototype:]
    > #2    0x00008074 in -[BrowserDelegate
    > browser:createRowsForColumn:inMatrix:] at BrowserDelegate.m:262
    > #3    0x903fc24c in -[NSBrowser
    > _sendDelegateCreateRowsForColumn:inMatrix:]
    > #4    0x902724b7 in -[NSBrowser addColumn]
    > #5    0x90271725 in -[NSBrowser loadColumnZero]
    > #6    0x000056a0 in -[Controller startup] at Controller.m:417
    > #7    0x000041f9 in -[Controller getToken] at Controller.m:236
    > #8    0x000046ed in -[Controller carryOn:] at Controller.m:280
    > #9    0x90114f94 in -[NSApplication sendAction:to:from:]
    > #10    0x90114ed4 in -[NSControl sendAction:to:]
    > #11    0x90114d5a in -[NSCell _sendActionFrom:]
    > #12    0x901143bb in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
    > #13    0x90113c12 in -[NSButtonCell
    > trackMouse:inRect:ofView:untilMouseUp:]
    > #14    0x901134cc in -[NSControl mouseDown:]
    > #15    0x90111d9b in -[NSWindow sendEvent:]
    > #16    0x900dea2c in -[NSApplication sendEvent:]
    > #17    0x9003c705 in -[NSApplication run]
    > #18    0x900099ba in NSApplicationMain
    > #19    0x00002638 in main at main.m:6

    BTW, I'm quite surprised this didn't cause an issue under Tiger.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today