performSelector: causes a Segmentation fault

5 views
Skip to first unread message

decarbonization

unread,
Mar 19, 2008, 4:22:41 PM3/19/08
to Programming Nu
If you use - performSelector: on an object it will perform the
selector and then proceed to beech ball and crash of a segmentation
fault. The following code demonstrates this:

(class NSObject
(- (void)log is
(NSLog "#{(self description)}")))

((array 1 2 3) performSelector:"log")

Matt Mower

unread,
Mar 19, 2008, 6:04:59 PM3/19/08
to program...@googlegroups.com
On 3/19/08, decarbonization <alway...@gmail.com> wrote:
>
> If you use - performSelector: on an object it will perform the
> selector and then proceed to beech ball and crash of a segmentation
> fault. The following code demonstrates this:
>

I typed in your code to nush and it ran without beachballing or crashing.

Unfortunately I couldn't trick nush into disclosing which version of
Nu I have, it was installed some while ago on an MBP with MacOSX
10.5.2

M.

--
Matt Mower :: http://matt.blogs.it/

Jeff Buck

unread,
Mar 20, 2008, 1:47:57 AM3/20/08
to Programming Nu
On Mar 19, 6:04 pm, "Matt Mower" <matt.mo...@gmail.com> wrote:
> On 3/19/08, decarbonization <alwaysd...@gmail.com> wrote:
>
> >  If you use - performSelector: on an object it will perform the
> >  selector and then proceed to beech ball and crash of a segmentation
> >  fault. The following code demonstrates this:
>
> I typed in your code to nush and it ran without beachballing or crashing.
>
> Unfortunately I couldn't trick nush into disclosing which version of
> Nu I have, it was installed some while ago on an MBP with MacOSX
> 10.5.2
>
> M.

I tried it out on the latest github Nu on an Intel MBP with OS X
10.5.2 and it ran fine for me too.

BTW, you can execute
(version)
in nush to see the version stamp of Nu, although I think it only
changes when Tim presses an official release of Nu.


-Jeff


Matt Mower

unread,
Mar 20, 2008, 8:31:50 AM3/20/08
to program...@googlegroups.com
On 3/20/08, Jeff Buck <wiresa...@gmail.com> wrote:
> BTW, you can execute
> (version)

Thanks... I was testing with 0.2.1 (2007-11-12).

M

decarbonization

unread,
Mar 20, 2008, 12:37:06 PM3/20/08
to Programming Nu
I must be the last person to be using Nu on a PPC Mac. This might just
be another platform specific bug.

On Mar 20, 8:31 am, "Matt Mower" <matt.mo...@gmail.com> wrote:

Tim Burks

unread,
Mar 20, 2008, 2:36:47 PM3/20/08
to program...@googlegroups.com

I'll look into this tonight.

Tim

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Programming Nu" group.
> To post to this group, send email to program...@googlegroups.com
> To unsubscribe from this group, send email to programming-n...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/programmin

Tim

unread,
Mar 20, 2008, 2:44:29 PM3/20/08
to Programming Nu
There does appear to be a problem. Testing with a forced-ppc run on
Intel:

[Xenon:~] tim% arch -ppc nush
Nu Shell.
% (class NSObject (- (void) log is (NSLog "logging #{(self
description)}")))
()
% ((array 1 2 3) performSelector:"log")
2008-03-20 11:41:07.053 nush[19665:80f] logging (
1,
2,
3
)
Segmentation fault

while natively on Intel:

[Xenon:~] tim% nush
Nu Shell.
% (class NSObject (- (void) log is (NSLog "logging #{(self
description)}")))
()
% ((array 1 2 3) performSelector:"log")
2008-03-20 11:43:40.174 nush[19667:807] logging (
1,
2,
3
)
()


- Tim

Tim Burks

unread,
Mar 21, 2008, 11:27:38 AM3/21/08
to program...@googlegroups.com

The problem is in the bridge. performSelector: is expecting the method
it calls to return an id, but in this case, it is declared void.
When I change to the following, it runs without crashing:

(class NSObject (- (id) log is (NSLog "logging #{(self description)}")))


((array 1 2 3) performSelector:"log")

I guess we're just (un-)lucky that it doesn't crash on x86.

So far, this appears to only be an issue when you call
performSelector: with a selector who's corresponding method returns
void.
I'll fix things so that this is handled more robustly.

Tim

Reply all
Reply to author
Forward
0 new messages