auto malloc[27012]: attempted to remove unregistered weak referrer

  • I've done some searches and haven't found anything regarding this
    in my situation.  An appropriate RTFM pointer would be appreciated.

    I'm running a *garbage collected* application in Lion (10.7.2) that was
    most recently compiled using Xcode 4.2.1.  I'm getting these messages
    logged: auto malloc[27012]: attempted to remove unregistered weak referrer 0xblahblah
    multiple times. What is most interesting is that it only happens when
    selecting multiple items by dragging.  I first noticed it in this code:

    - (IBAction) showOpenPanel: (id) sender
    {
        BOOL reloadNeeded = NO;
        BOOL showWarning = NO;

        NSOpenPanel *panel = [NSOpenPanel openPanel];
        CFArrayRef types = CGImageSourceCopyTypeIdentifiers();
        CFMakeCollectable(types);
        [panel setAllowedFileTypes: (NSArray*) types];
        [panel setAllowsMultipleSelection: YES];
        [panel setCanChooseFiles: YES];
        [panel setCanChooseDirectories: NO];
        NSInteger result = [panel runModal];
        if (result == NSOKButton) {
    // this may take a while, let the user know we're busy
    [self showProgressIndicator];
    NSArray *urls = [panel URLs];
    for (NSURL *url in urls) {
            NSString *path = [url path];
           if (! [self isDuplicatePath: path]) {
      [imageInfos addObject: [ImageInfo imageInfoWithPath: path]];
      reloadNeeded = YES;
           } else
      showWarning = YES;
    }
    [self hideProgressIndicator];

    if (reloadNeeded)
           [tableView reloadData];
    if (showWarning) {
           NSAlert *alert = [[NSAlert alloc] init];
           [alert addButtonWithTitle: NSLocalizedString(@"CLOSE", @"Close")];
           [alert setMessageText: NSLocalizedString(@"WARN_TITLE", @"Files not opened")];
           [alert setInformativeText: NSLocalizedString(@"WARN_DESC", @"Files not opened")];
           [alert runModal];
    }
        }
    }

    In the open panel I can click, move the mouse, then shift-click and all is OK.
    If instead I click and drag I get the error multiple times.  So where did I
    go wrong?

    Thanks,

    Marc
  • On Wed, 18 Jan 2012 15:47:47 -0800, Marco S Hyman said:

    > I've done some searches and haven't found anything regarding this
    > in my situation.  An appropriate RTFM pointer would be appreciated.
    >
    > I'm running a *garbage collected* application in Lion (10.7.2) that was
    > most recently compiled using Xcode 4.2.1.  I'm getting these messages
    > logged: auto malloc[27012]: attempted to remove unregistered weak
    > referrer 0xblahblah

    Have you tried the various debugging environment variables?

    > NSOpenPanel *panel = [NSOpenPanel openPanel];
    > CFArrayRef types = CGImageSourceCopyTypeIdentifiers();
    > CFMakeCollectable(types);
    > [panel setAllowedFileTypes: (NSArray*) types];

    You can avoid the cast using NSMakeCollectable (which also handles nil better).

    > In the open panel I can click, move the mouse, then shift-click and all is OK.
    > If instead I click and drag I get the error multiple times.  So where did I
    > go wrong?

    In my GC app, I haven't seen this, but am having various problems with NSOpenPanel... half the time, it shows nothing.

    --
  • On Jan 18, 2012, at 3:47 PM, Marco S Hyman wrote:

    > I've done some searches and haven't found anything regarding this
    > in my situation.  An appropriate RTFM pointer would be appreciated.

    Update... sometimes I'm getting this error, too...

    malloc: reference count underflow for 0x40048fb00, ....

    Garbage collected app, Xcode 4.2.1, Lion 10.7.2.

    The breakpoint is inside of NSOpenPanel -runModal but ONLY occurs when
    dragging to select multiple files.  cmd-click or shift-click work fine.
    Running with malloc guards and other tests for trashed memory haven't
    shown anything obvious.  And why only when dragging?

    Anyone else have some hints?  I did make one slight modification to
    my code in that I now CFRelease the array ref I got from
    CGImageSourceCopyTypeIdentifiers() instead of making it collectable.
    No change in operation.  Didn't expect any.

    The code that is giving me a headache:

        NSOpenPanel *panel = [NSOpenPanel openPanel];
        CFArrayRef types = CGImageSourceCopyTypeIdentifiers();
        [panel setAllowedFileTypes: (NSArray*) types];
        [panel setAllowsMultipleSelection: YES];
        [panel setCanChooseFiles: YES];
        [panel setCanChooseDirectories: NO];
        NSInteger result = [panel runModal];      <==== error displayed in runModal
        CFRelease(types);
        if (result == NSOKButton) {
    ...
        }

    Marc
  • On Jan 18, 2012, at 3:47 PM, Marco S Hyman wrote:

    > I've done some searches and haven't found anything regarding this
    > in my situation.  An appropriate RTFM pointer would be appreciated.
    >
    > I'm running a *garbage collected* application in Lion (10.7.2) that was
    > most recently compiled using Xcode 4.2.1.  I'm getting these messages
    > logged: auto malloc[27012]: attempted to remove unregistered weak referrer 0xblahblah
    > multiple times. What is most interesting is that it only happens when
    > selecting multiple items by dragging.  I first noticed it in this code:
    >
    > - (IBAction) showOpenPanel: (id) sender
    > {
    > BOOL reloadNeeded = NO;
    > BOOL showWarning = NO;
    >
    > NSOpenPanel *panel = [NSOpenPanel openPanel];
    > CFArrayRef types = CGImageSourceCopyTypeIdentifiers();
    > CFMakeCollectable(types);
    > [panel setAllowedFileTypes: (NSArray*) types];
    > [panel setAllowsMultipleSelection: YES];
    > [panel setCanChooseFiles: YES];
    > [panel setCanChooseDirectories: NO];
    > NSInteger result = [panel runModal];
    > if (result == NSOKButton) {
    > // this may take a while, let the user know we're busy
    > [self showProgressIndicator];
    > NSArray *urls = [panel URLs];
    > for (NSURL *url in urls) {
    > NSString *path = [url path];
    > if (! [self isDuplicatePath: path]) {
    > [imageInfos addObject: [ImageInfo imageInfoWithPath: path]];
    > reloadNeeded = YES;
    > } else
    > showWarning = YES;
    > }
    > [self hideProgressIndicator];
    >
    > if (reloadNeeded)
    > [tableView reloadData];
    > if (showWarning) {
    > NSAlert *alert = [[NSAlert alloc] init];
    > [alert addButtonWithTitle: NSLocalizedString(@"CLOSE", @"Close")];
    > [alert setMessageText: NSLocalizedString(@"WARN_TITLE", @"Files not opened")];
    > [alert setInformativeText: NSLocalizedString(@"WARN_DESC", @"Files not opened")];
    > [alert runModal];
    > }
    > }
    > }
    >
    > In the open panel I can click, move the mouse, then shift-click and all is OK.
    > If instead I click and drag I get the error multiple times.

    Get the error...what error?

    > So where did I
    > go wrong?

    Depends on what your code does in various things, ie: isDuplicatePath:

    :)

    .corbin

    >
    > Thanks,
    >
    > Marc
  • On Jan 20, 2012, at 7:07 AM, Sean McBride wrote:

    > On Wed, 18 Jan 2012 15:47:47 -0800, Marco S Hyman said:
    >
    >> I've done some searches and haven't found anything regarding this
    >> in my situation.  An appropriate RTFM pointer would be appreciated.
    >>
    >> I'm running a *garbage collected* application in Lion (10.7.2) that was
    >> most recently compiled using Xcode 4.2.1.  I'm getting these messages
    >> logged: auto malloc[27012]: attempted to remove unregistered weak
    >> referrer 0xblahblah
    >
    > Have you tried the various debugging environment variables?
    >
    >> NSOpenPanel *panel = [NSOpenPanel openPanel];
    >> CFArrayRef types = CGImageSourceCopyTypeIdentifiers();
    >> CFMakeCollectable(types);
    >> [panel setAllowedFileTypes: (NSArray*) types];
    >
    > You can avoid the cast using NSMakeCollectable (which also handles nil better).
    >
    >> In the open panel I can click, move the mouse, then shift-click and all is OK.
    >> If instead I click and drag I get the error multiple times.  So where did I
    >> go wrong?
    >
    > In my GC app, I haven't seen this, but am having various problems with NSOpenPanel... half the time, it shows nothing.

    I don't know if I saw a report on this come through. Did you log a bug on it?

    You could try calling validateVisibleColumns after it is visible as a hack/workaround.

    corbin
  • On Jan 20, 2012, at 2:18 PM, Marco S Hyman <marc...> wrote:

    > On Jan 18, 2012, at 3:47 PM, Marco S Hyman wrote:
    >
    >> I've done some searches and haven't found anything regarding this
    >> in my situation.  An appropriate RTFM pointer would be appreciated.
    >
    > Update... sometimes I'm getting this error, too...
    >
    > malloc: reference count underflow for 0x40048fb00, ....
    >
    > Garbage collected app, Xcode 4.2.1, Lion 10.7.2.
    >
    > The breakpoint is inside of NSOpenPanel -runModal but ONLY occurs when
    > dragging to select multiple files.  cmd-click or shift-click work fine.
    > Running with malloc guards and other tests for trashed memory haven't
    > shown anything obvious.  And why only when dragging?

    1. Are you sandboxed?

    2. Does malloc_stack_logging yield any useful info for that address? I must confess I don't know much at all about GC.

    --Kyle Sluder
  • On Jan 20, 2012, at 8:59 PM, Kyle Sluder wrote:

    >> Update... sometimes I'm getting this error, too...
    >>
    >> malloc: reference count underflow for 0x40048fb00, ....
    >>
    >> Garbage collected app, Xcode 4.2.1, Lion 10.7.2.
    >>
    >> The breakpoint is inside of NSOpenPanel -runModal but ONLY occurs when
    >> dragging to select multiple files.  cmd-click or shift-click work fine.
    >> Running with malloc guards and other tests for trashed memory haven't
    >> shown anything obvious.  And why only when dragging?
    >
    > 1. Are you sandboxed?

    Nope.

    > 2. Does malloc_stack_logging yield any useful info for that address? I must confess I don't know much at all about GC.

    None of the malloc debug options I've tried (and I think I've played
    with most of them in one combination or another) have made any difference.

    The application is small, so I think my next step will be to convert it
    to ARC.  If nothing else it will give me a chance to play with ARC, something
    I've not done, yet.  I'm curious as to what I'll find (if anything).

    Marc
  • On Fri, 20 Jan 2012 15:41:59 -0800, Corbin Dunn said:

    >> In my GC app, I haven't seen this, but am having various problems with
    >> NSOpenPanel... half the time, it shows nothing.
    >
    > I don't know if I saw a report on this come through. Did you log a bug on it?

    Corbin,

    <rdar://10614610>
    10.7: NSOpenPanel is often hopelessly unresponsive

    Cheers,

    --
previous month january 2012 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 31          
Go to today