Hi Banlu,

I think the problem here is that performSelector: is declared as returning an 
object, so LK is attempting to return the result.  printSomething, however, 
returns void and so some random value will be left in the return register and, 
when LK tries to retain this, it will break.  

To avoid this, don't use performSelector: on things that don't take and return 
an object.  You'll need to construct an NSInvocation, which is a little harder 
in LK.

For this specific use-case, however, you can simply do:

doc ifResponds printSomething.

David

On 22 Aug 2012, at 08:38, Bluna Ratimonkey wrote:

> Hello,
> I got a crash in returning from a void method that was called within 
> Smalltalk.
> 
> #0  0xb6cba4c7 in SparseArrayLookup (sarray=0x31, index=5) at ./sarray2.h:71
> #1  0xb6cb9bfb in objc_msg_lookup_internal (receiver=0xbfffe764, 
> selector=0xb6cca808, sender=0x0)
>     at sendmsg2.c:66
> #2  objc_msg_lookup_sender (receiver=0xbfffe764, selector=0xb6cca808, 
> sender=0x0) at sendmsg2.c:171
> #3  0xb6cbd12c in retain (obj=0x8209250) at arc.m:182
> #4  0xb6cbd024 in objc_retain (obj=0x8209250) at arc.m:411
> #5  0xb6cbd2af in objc_storeStrong (addr=0xbfffe7e0, value=0x8209250) at 
> arc.m:439
> #6  0xb0f3b7c8 in ?? ()
> 
> It was triggered after
> 
>         (doc respondsToSelector: 'printSomething') ifTrue: [doc 
> performSelector: 'printSomething'].
> 
> It doesn't crash if I simply call
> 
>          doc performSelector: 'printSomething'.
> 
> printSomething was successfully called in both cases, but the first one will 
> crash on the return, I think.
> I printed value of 'class' variable in sendmsg2.c:65, on its last moment it 
> looks like this
> 
> 0xb6ba79c0
> 0xb6be4780
> 0xabf4264
> (crash)
> 
> printSomething was implemented as - (void) printSomething, changing it to 
> return id nil prevent the crash.
> 
> 
> On Wed, Aug 22, 2012 at 4:37 AM, Mathieu SUEN <[email protected]> wrote:
> Hi
> 
> It looks like the LK build was broken since the ARC update:
> 
> In file included from CodeGenModule.mm:1:
> In file included from 
> /home/mathk/source/Etoile/Languages/LanguageKit/CodeGen/CodeGenModule.h:3:
> In file included from 
> /home/mathk/source/Etoile/Languages/LanguageKit/CodeGen/CGObjCRuntime.h:18:
> In file included from /usr/local/include/llvm/ADT/SmallVector.h:18:
> In file included from /usr/local/include/llvm/Support/type_traits.h:22:
> In file included from 
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/utility:70:
> In file included from 
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stl_pair.h:60:
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/move.h:46:22:
>  error: cast of an Objective-C pointer to
>       'const volatile char &' is disallowed with ARC
>         (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
>                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> 
> Any idea for a remedy?
> 
> Thanks
> 
> --
> Mathieu
> _______________________________________________
> Etoile-discuss mailing list
> [email protected]
> https://mail.gna.org/listinfo/etoile-discuss
> 
> 
> 
> -- 
> I used to be a GNUstep developer like them, then I took an arrow in the 
> knee...
> _______________________________________________
> Etoile-discuss mailing list
> [email protected]
> https://mail.gna.org/listinfo/etoile-discuss


-- Sent from my Cray X1


_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à