discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Infinite loop in objc_storeWeak


From: Thomas Davie
Subject: Re: Infinite loop in objc_storeWeak
Date: Mon, 18 Jun 2012 10:43:08 +0100

On 15 Jun 2012, at 14:50, David Chisnall wrote:

> Can you try to produce a reduced test case?  I've tried a few things and I 
> can't make it not work.  For example, this code:
> 
> int main(void)
> {
>    BBWeakRef *o = [BBWeakRef refWithTarget: [NSObject new]];
>    NSLog(@"%@", o.target);
> }
> 
> Logs (null) as expected.  A backtrace might help.  As would compiling 
> libobjc2 without optimisations (you can't actually be infinite looping in a 
> loop that counts from 0 to 3, you must be looping in the outer loop for some 
> reason).  The most likely cause of this is that you're trying to create a 
> weak reference to an object that's already been deallocated.  Perhaps you 
> could try GSZombieEnabled=YES as well?

Hi David,

Sorry for the delayed response, I wanted to make sure I had something 100% 
reproducible.  Unfortunately, I wasn't able to reproduce the exact bug – it 
appears to be something deeply embedded in my code, but I have been able to 
reproduce something I believe is strongly related:

Description:
Weak references are not zeroed when ARC code is linked with non-ARC code.

Steps to Reproduce
1) Unzip the attached source folders.  You should find:
BBWeakRef – a directory containing a simple weak reference wrapper, set to 
compile using ARC
WeakRefTest – a directory containing a simple test program that links against 
BBWeakRef, but is not compiled using ARC
WeakRefTest2 – a directory containing a similar test program that uses ARC, and 
includes BBWeakRef's source.
2) make & make install BBWeakRef
3) make WeakRefTest and run it.
4) make WeakRefTest2 and run it.

Expected Results:
From WeakRefTest:
2012-06-18 10:32:47.445 test[18025] 0xdeadbeef - <NSObject: 0xdeadbeef >
2012-06-18 10:32:47.448 test[18025] (null) - (null)
2012-06-18 10:32:47.448 test[18025] (null) - (null)

From WeakRefTest2:
2012-06-18 10:36:28.615 test[18117] 0x11012c8 - <NSObject: 0x11012c8>
2012-06-18 10:36:28.618 test[18117] (null) - (null)


Actual Results:
From WeakRefTest:
2012-06-18 10:32:47.445 test[18025] 0x11f82c8 - <NSObject: 0x11f82c8>
2012-06-18 10:32:47.448 test[18025] 0x11f82c8 - <NSObject: 0x11f82c8>
2012-06-18 10:32:47.448 test[18025] 0x11f82c8 - <NSObject: 0x11f82c8>
Segmentation fault

Thanks

Tom Davie

Attachment: Archive.zip
Description: Zip archive


reply via email to

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