Skip to content

valueForKey broken after upgrading libobjc2/gnustep-base/gnustep-make #52

@dlobron

Description

@dlobron

I've been working to get a large program running on Ubuntu Linux, with the clang compiler. As part of this, I took the latest source for libobjc2, gnustep-base, and gnustep-make.

After doing this, I found that the valueForKey is broken for a large class in one of my shared libraries. The class is a subclass of NSObject, so it's using the valueForKey implementation from the runtime.

I confirmed with print statements that I'm assigning the ivars correctly, but I find that the valueForKey method returns the wrong ivar for a given key. For example, I have two keys called "binary" and "argument", of type NSString* and NSArray*, respectively. I assign to these variables directly in my main program. I then attempt to print the variables in a loop, having stored their names in an array called _keys:

- (void)debugKeyLoop { NSLog(@"DBG: Printing keys"); for (NSString *key in _keys) { id v = [self valueForKey:key]; NSLog(@"DBG: debug key loop, got val %@ for key %@, my class is %@", v, key, [[self class] description]); } }

The object is called "config", and the code is:

config->binary = [NSString stringWithFormat:@"/bin/sh"];
config->argument = [[NSArray arrayWithObjects:@"-c", @"echo Child starting; sleep 10; echo Child exiting", nil] retain];
[config debugKeyLoop];

On the first iteration, the wrong value for the key "binary" is printed:

2018-01-12 17:42:53.026 MinRep[5192:5192] DBG: Printing keys
2018-01-12 17:42:53.026 MinRep[5192:5192] DBG: debug key loop, got val ("-c", "echo Child starting; sleep 10; echo Child exiting") for key binary, my class is SubprogramConfiguration

Note that the key "binary" is returning the NSArray value that was assigned to a different instance variable, "argument". The next iteration of the loop throws a segmentation fault.

My code has been around for years, and previous versions of libobjc2/gnustep-base/gnustep-make did not exhibit this problem, which leads me to suspect a problem with the libobjc2 runtime. I'm working on a minimal reproducer now. So far, the minimal code has not reproduced the bug, but I figured I would open this ticket in case owners of the runtime code might have an idea of recent changes that could cause this. If this turns out not to be reproducible or not in libobjc2, I will close this CR (I can't revert my gnustep-base and gnustep-make versions to the previous ones, because only the latest codelines are compatible).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions