Issue 920 in cocotron: NSObjectIsKindOfClass() segfaults on Win32 when built on Xcode 4.2 (fix included)

8 views
Skip to first unread message

coco...@googlecode.com

unread,
Feb 10, 2012, 9:55:19 AM2/10/12
to cocotr...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 920 by pa...@lacquer.fi: NSObjectIsKindOfClass() segfaults on
Win32 when built on Xcode 4.2 (fix included)
http://code.google.com/p/cocotron/issues/detail?id=920

I'm trying to write a tutorial for setting up Cocotron with Lion + Xcode
4.2. I've now got Cocotron running fine and producing apparently working
Windows executables. On the way, I ran into a crash bug is NSObject. It was
easy to fix, but I wonder why this bug surfaced now. Is there maybe
something wrong with the way the obj-c runtime is getting built? Any input
appreciated... Description of the bug is below.


On the current Cocotron main branch, the function NSObjectIsKindOfClass()
will cause a segfault on Windows. The problem is a loop that walks up the
object's inheritance list, but doesn't check if the superclass is NULL.

Here is the fix:

BOOL NSObjectIsKindOfClass(id object,Class kindOf) {
struct objc_class *class=object->isa;

for(;class!=0;class=class->super_class){
if((struct objc_class *)kindOf==class)
return YES;
if(class->isa->isa==class)
break;
}

return NO;
}

Is class->super_class always supposed to be non-NULL? If so, what could be
causing this behaviour on a fresh Cocotron install?

coco...@googlecode.com

unread,
Feb 10, 2012, 10:20:30 AM2/10/12
to cocotr...@googlegroups.com

Comment #1 on issue 920 by pa...@lacquer.fi: NSObjectIsKindOfClass()
segfaults on Win32 when built on Xcode 4.2 (fix included)
http://code.google.com/p/cocotron/issues/detail?id=920

This fix is available in my branch 'pauli-cocotron', rev 26735d4f61b5:

https://code.google.com/r/pauli-cocotron/source/detail?r=26735d4f61b5a3857b7d37c5d386a5e188e1a675

coco...@googlecode.com

unread,
Feb 11, 2012, 8:12:58 PM2/11/12
to cocotr...@googlegroups.com

Comment #2 on issue 920 by r.tull...@gmail.com: NSObjectIsKindOfClass()
segfaults on Win32 when built on Xcode 4.2 (fix included)
http://code.google.com/p/cocotron/issues/detail?id=920

That works! Excellent. Thanks.

It must be being trigged by a specific class - maybe something in AppKit?
I've got a build of FoundationKit that seems to work fine under windows.

coco...@googlecode.com

unread,
Feb 12, 2012, 1:03:14 PM2/12/12
to cocotr...@googlegroups.com

Comment #3 on issue 920 by pa...@lacquer.fi: NSObjectIsKindOfClass()
segfaults on Win32 when built on Xcode 4.2 (fix included)
http://code.google.com/p/cocotron/issues/detail?id=920

The fix is now merged with latest changes in the main branch:

http://code.google.com/r/pauli-cocotron/source/detail?r=fffacabc3d861250dbe658c16124c86159f4c0a4

coco...@googlecode.com

unread,
Feb 14, 2012, 9:27:06 PM2/14/12
to cocotr...@googlegroups.com
Updates:
Status: Started

Comment #4 on issue 920 by cjwll...@gmail.com: NSObjectIsKindOfClass()

segfaults on Win32 when built on Xcode 4.2 (fix included)
http://code.google.com/p/cocotron/issues/detail?id=920

This has been merged with the mainline.

No good theory as to why this only happens when switching to Xcode 4.2,
although I believe checking for NULL is correct.

Reply all
Reply to author
Forward
0 new messages