discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libdispatch problem


From: David Chisnall
Subject: Re: libdispatch problem
Date: Fri, 26 Jun 2015 12:27:47 +0100

I suspect that this is a bug in GNUstep where a +initialize method invoked by 
the NSLog() is creating an autoreleased object that is then destroyed 
prematurely.  You could try with NSZombieEnabled and see if that produces more 
useful debugging info.

David

> On 24 Jun 2015, at 21:08, allynm <mark.allyn@verizon.net> wrote:
> 
> Hello everyone,
> 
> This is probably more a libobjc2 type question.  Hopefully, not.
> 
> I have the following program, based off an original work by Tobias Lensing.
> 
> 
>> #import 
>> &lt;
>> Foundation/Foundation.h
>> &gt;
>> #import 
>> &lt;
>> AppKit/AppKit.h
>> &gt;
>> #import 
>> &lt;
>> dispatch/dispatch.h
>> &gt;
>> int main (int argc, const char * argv[])
>> {
>> @autoreleasepool{
>>  int multiplier = 7;
>>  int (^myBlock)(int) = ^(int num){
>>    return num *multiplier;
>>   };
>> 
>> NSLog(@"%d", myBlock(3));
>> 
>> dispatch_queue_t queue = dispatch_queue_create("Example.one",NULL);
>> 
>>  dispatch_sync(queue, ^{printf("Hello, world from a dispatch queue!\n");
>>   });
>> NSLog(@"got past the dispatch queue, on to the pic ...");
>> //}
>> 
>> //@autoreleasepool{
>>  [NSApplication sharedApplication];
>>  //cd ~/
>> NSAlert * alert = [[NSAlert alloc] init];  //alerWithE(@"TEST", @"Wow it
>> works!", @"OK", nil, nil);
>> [alert addButtonWithTitle:@"OK"];
>> [alert addButtonWithTitle:@"Cancel"];
>> [alert setMessageText:@"Delete the record?"];
>> [alert setInformativeText:@"Deleted records cannot be restored!"];
>> 
>> [alert setAlertStyle:NSWarningAlertStyle];
>> if ([alert runModal] == NSAlertFirstButtonReturn){
>> return 0;
>> }
>> 
>> }
>> 
>>  return 0;
>> }
> 
> If I remove the comments around the "}"  and the following
> "@autoreleasepool" directive the program crashes with a seg fault before it
> runs the little NSAlert window enclosed by the second @autoreleasepool.  If
> there is only a single @autoreleasepool directive and closing "}" the
> program runs just fine.  I'm a novice on this stuff.  Could someone with a
> better knowledge of GCD and ARC explain what's happening?
> 
> Thanks,
> Mark Allyn
> 
> 
> 
> 
> --
> View this message in context: 
> http://gnustep.8.n7.nabble.com/libdispatch-problem-tp39436.html
> Sent from the GNUstep - General mailing list archive at Nabble.com.
> 
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep




-- Sent from my brain




reply via email to

[Prev in Thread] Current Thread [Next in Thread]