Crash at THFSPlusStore::LessThan(HFSUniStr255 const&)

  • Hello:

    I have a microscopy program that displays and acquire images, and
    saves processed images. I keep getting crashes in my program in a
    function that is called from [ NSSavePanel
    runModalForDirectory:file:types ]
    The program crashes very often (every 20 calls roughly) at
    THFSPlusStore::LessThan(HFSUniStr255 const&). I have tried many things
    (including passing empty strings or nil strings for all parameters to
    runModalForDirectory:file:types etc...) and I can't see what is wrong.
    I may have some corrupted memory somewhere because of another thread
    (?), but I can't come up with a good strategy to find it. In another
    issue, I often get the message "CGImageSourceCreateWithData data
    parameter is nil" in my logs but I have been absolutely unable to
    track down what Cocoa function calls that function.

    Any help would be greatly appreciated.

    Daniel

    Exception:  EXC_BAD_ACCESS (0x0001)
    Codes:      KERN_INVALID_ADDRESS (0x0001) at 0x20536f72

    Thread 0 Crashed:
    0  com.apple.DesktopServices         0x92afc500
    THFSPlusStore::LessThan(HFSUniStr255 const&) const + 72
    1  com.apple.DesktopServices         0x92af93cc
    TChildrenList::Find(HFSUniStr255 const&) + 136
    2  com.apple.DesktopServices         0x92af9190
    TNode::FindChild(HFSUniStr255 const&) const + 184
    3  com.apple.DesktopServices         0x92af8ff4
    TNode::GetNodeFromPathName(TPathName const&, TNodePtr&) const + 220
    4  com.apple.DesktopServices         0x92af8554
    TNode::GetNodeFromURL(__CFURL const* const&, TNodePtr&) + 184
    5  com.apple.DesktopServices         0x92afaf38 GetURLAsNode + 68
    6  com.apple.AppKit                   0x9393938c NSFBEAllocNodeFromPath
    + 104
    7  com.apple.AppKit                   0x93939050 -[NSNavFBENode
    initWithPath:logonOK:] + 60
    8  com.apple.AppKit                   0x93938d70 -
    [NSSavePanel(NSSavePanelRuntime) _configureForDirectory:name:] + 404
    9  com.apple.AppKit                   0x93938a58 -
    [NSSavePanel(NSSavePanelRuntime) runModalForDirectory:file:types:] + 56
    10  com.wellman.dccote.iphoton         0x00016038 -[AppController
    saveWithCurrentUserSettings:] + 448
    11  com.apple.Foundation               0x92beda0c
    __NSFireMainThreadPerform + 276
    12  com.apple.CoreFoundation           0x9080eae0
    __CFRunLoopPerformPerform + 104
    13  com.apple.CoreFoundation           0x907de4fc __CFRunLoopDoSources0 +
    384
    14  com.apple.CoreFoundation           0x907dda2c __CFRunLoopRun + 452
    15  com.apple.CoreFoundation           0x907dd4ac CFRunLoopRunSpecific +
    268
    16  com.apple.HIToolbox               0x93297b20
    RunCurrentEventLoopInMode + 264
    17  com.apple.HIToolbox               0x932971b4 ReceiveNextEventCommon
    + 380
    18  com.apple.HIToolbox               0x93297020
    BlockUntilNextEventMatchingListInMode + 96
    19  com.apple.AppKit                   0x9379cae4 _DPSNextEvent + 384
    20  com.apple.AppKit                   0x9379c7a8 -[NSApplication
    nextEventMatchingMask:untilDate:inMode:dequeue:] + 116
    21  com.apple.AppKit                   0x93798cec -[NSApplication run] +
    472
    22  com.apple.AppKit                   0x9388987c NSApplicationMain + 452
    23  com.wellman.dccote.iphoton         0x00002b78 _start + 760
    24  com.wellman.dccote.iphoton         0x0000287c start + 48

    ---------------------
    Daniel Côté, Ph.D.
    Assistant Professor/Professeur Adjoint
    Departement de Physique
    Centre de Recherche Université Laval Robert Giffard
    2601 Ch. de la Canardiere, F-6500
    Québec QC G1J2G3
    Canada

    <Daniel.Cote...>
    Office (418) 663-5747  x6875
    Cell (418) 559-4620
  • These kinds of memory smashers can be hard to track down. I would
    start by setting the environment variable MallocScribble to 1. This
    will overwrite freed blocks with a repeating 0x55 pattern, which will
    help flush out places where something is reading from a freed block.
    (It's cheap enough that I always set it up in my executable settings
    in Xcode, and in my .gdbinit.)

    The heavy-duty tool for detecting smashers is libgmalloc. I've
    actually never used it, but I believe there is documentation in the
    system. It vastly increases memory usage and slows your code to a
    crawl, though, so it might take hours to get to the point of the
    crash...

    —Jens