I'm in the process of tracking down a weird behavioral difference between the
way Blocks work on Mac OS X and the way they work with GNUstep + libobjc2.


Unfortunately I haven't yet distilled the problem I'm seeing, but I may have
stumbled on a different one.


Env: 64 bit Debian, GNstep + libobjc2 compiled with llvm+clang 2.9. 
(example compiled with llvm+clang 2.9 as well).


On Mac it runs correctly (maybe it shouldn't?):


2011-06-27 20:32:49.233 a.out[16772:903] 0
2011-06-27 20:32:49.236 a.out[16772:903] 1 0x7fff5fbff828
2011-06-27 20:32:49.236 a.out[16772:903] 2 0x100110628
2011-06-27 20:32:49.237 a.out[16772:903] 1
2011-06-27 20:32:49.237 a.out[16772:903] a 0x100110628
2011-06-27 20:32:49.238 a.out[16772:903] b 0x100110628
2011-06-27 20:32:49.238 a.out[16772:903] 2


On Linux I get a SIGSEGV in _Block_object_assign


Before I go diving into the blocks runtime I figured it couldn't hurt to
share here, hopefully someone smarter than me might know what's going on (or
why my contrived example shouldn't have worked at all).


Thanks,

Loren



#import <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
        __block void(^a)(void) = NULL;
        __block void(^b)(void) = NULL;
        
        void (^master)(int) = Block_copy(^(int n){
                
                __block id x = nil;
                
                if(n == 0) {
                        NSLog(@"0");
                        
                        NSLog(@"1 %p", &x);
                        a = Block_copy(^{
                                NSLog(@"a %p", &x);
                        });

                        NSLog(@"2 %p", &x);
                        b = Block_copy(^{
                                NSLog(@"b %p", &x);
                        });
                } else if(n == 1) {
                        NSLog(@"1");
                        
                        a();
                        b();
                } else if(n == 2) {
                        NSLog(@"2");
                        
                        Block_release(a);
                        Block_release(b);
                }
        });
        
        master(0);
        master(1);
        master(2);
        
        Block_release(master);
        
        return 0;
}


-- 
View this message in context: 
http://old.nabble.com/_Block_object_assign-crash-tp31942617p31942617.html
Sent from the GNUstep - Dev mailing list archive at Nabble.com.
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to