gnustep-dev
[Top][All Lists]
Advanced

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

Re: Is the GNUstep Objective-C runtime to picky about method signatures?


From: Wolfgang Lux
Subject: Re: Is the GNUstep Objective-C runtime to picky about method signatures?
Date: Tue, 14 Apr 2020 19:27:06 +0200


> Am 14.04.2020 um 12:34 schrieb David Chisnall <address@hidden>:
> 
> Calling a method with the wrong signature is undefined behaviour in 
> Objective-C.  The Apple runtime just ignores the type entirely and will 
> happily corrupt your stack in a few cases. We try to allow it in benign 
> cases, which probably should include `Class` vs `id`, though I'm not entirely 
> convinced: it's fine to pass a `Class` to something that expects an `id`, but 
> passing an arbitrary object to something that expects a `Class` can cause 
> exciting breakage.

I assume the difference of that to passing, say, an NSDictionary for an 
NSWindow, which both use the same representation in the method signature, is 
just that for NSDictionary vs. NSWindow you can wreak havoc only on a single 
object, while doing that for a Class vs. some other object you could break all 
instance of the respective class (and its subclasses)?

> 
>> And while I was writing that test program, I accidentally uncovered another 
>> bug in the libobjc2 runtime (see Test2.m): When calling super with a method 
>> that isn't implemented by the super class (or its own ancestors) libobjc2 
>> simply does nothing, as if the method was called against nil.
> 
> This is a bug.  Please open an issue on GitHub so that I can track it.

Sure. Created issue #153.

Wolfgang




reply via email to

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