Project

General

Profile

Actions

Bug #350

closed

Assign property cause crash of application (Objective-C)

Added by Dmitry M. over 11 years ago. Updated over 10 years ago.

Status:
Completed
Priority:
High
Assignee:
Alexander Z.
Category:
-
Target version:
Start date:
05/07/2013
Due date:
% Done:

100%

Estimated time:
CPU Architecture:
all
Host OS:
Toolchain:
all
Android version:
CrystaX NDK Version:

Description

Code example is below:


@interface foo : BaseObject {
    BOOL boolProperty;
    id stringProperty;
}

@property (assign) BOOL boolProperty;
@property (copy) id stringProperty;

-(id) init;
-(void) bar;

@end

@implementation foo

@synthesize boolProperty;
@synthesize stringProperty;

- (void) bar
{
    self.boolProperty = YES;
    self.stringProperty = @"";
}

@end
Actions #1

Updated by Dmitry M. over 11 years ago

  • Assignee set to Alexander Z.
Actions #2

Updated by Alexander Z. over 11 years ago

  • Status changed from Open to In Progress
  • % Done changed from 0 to 50
Actions #3

Updated by Dmitry M. over 10 years ago

  • Target version changed from r8-crystax-2 to 10.0.0
Actions #4

Updated by Alexander Z. over 10 years ago

  • Status changed from In Progress to Completed
  • % Done changed from 0 to 100

Declaring property as 'copy' requires respective class to implement NSCoping protocol and thus implement copyWithZone method.

The issues's code example (slightly modified) compiled with GCC 4.6 correctly raises runtime exception (copyWithZone selector not found), but code compiled with GCC 4.8 or 4.9 just dumps core.

The described behavior can be reproduced on any Linux box with GCC Objective C compiler or Clang with GNU objc runtime.

To prevent application crash one needs either not declare property as 'copy' or implement copyWithZone method.

See test/device/crystax-issue-350-copy-with-zone sample code.

Actions

Also available in: Atom PDF