Bug 19699 – [2.085.0-beta.2] Obj-C segfault - in objc_glue.getClassName

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2019-02-25T16:00:10Z
Last change time
2019-02-26T11:43:26Z
Keywords
pull
Assigned to
No Owner
Creator
Adam D. Ruppe

Comments

Comment #0 by destructionator — 2019-02-25T16:00:10Z
I can't figure out how to minimize this (I barely know how to use Macs at all), but I got a segfault and from the debugger's disassembly, it appears to be line 600 of objc_glue.d, I think objcClass is null. The call stack then leads to toDt(). If I can figure out how to build a debug dmd on this OS, I might be able to get more info. Or if I can figure out dustmite I might be able to reduce the example. Stay tuned for comments....
Comment #1 by destructionator — 2019-02-25T16:16:25Z
Here it is: --- extern(Objective-C) class Test { void foo() {} } --- With the second beta, simple `dmd test.d` will trigger the segfault. It seems to not like the function with a body.
Comment #2 by doob — 2019-02-25T19:33:32Z
I've found what the problem is. I'll try to make a PR as soon as I can. The actual issue is that there's no base class, in combination with a body for the function. Usually the code will look like this: extern (Objective-C) class NSObject { ... } extern (Objective-C) class Test : NSObject { ... } It's extremely rare to define a new root class in Objective-C.
Comment #3 by dlang-bot — 2019-02-26T10:24:49Z
@jacob-carlborg created dlang/dmd pull request #9390 "Fix issue 19699: Obj-C segfault - in objc_glue.getClassName" fixing this issue: - Fix issue 19699: Obj-C segfault - in objc_glue.getClassName The problem occurs when declaring an Objective-C root class and it contains a method with a body. https://github.com/dlang/dmd/pull/9390
Comment #4 by dlang-bot — 2019-02-26T11:43:26Z
dlang/dmd pull request #9390 "Fix issue 19699: Obj-C segfault - in objc_glue.getClassName" was merged into stable: - 0d61c3a01a37b666ff4354181c57910a77965956 by Jacob Carlborg: Fix issue 19699: Obj-C segfault - in objc_glue.getClassName The problem occurs when declaring an Objective-C root class and it contains a method with a body. https://github.com/dlang/dmd/pull/9390