Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7221] Class lookup at runtime fails in master toolchains #49769

Closed
tkrajacic opened this issue Mar 18, 2018 · 7 comments
Closed

[SR-7221] Class lookup at runtime fails in master toolchains #49769

tkrajacic opened this issue Mar 18, 2018 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2

Comments

@tkrajacic
Copy link

Previous ID SR-7221
Radar rdar://problem/38624844
Original Reporter @tkrajacic
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

macOS 10.13.3

Xcode 9.3b4

Tested with

Swift Development Snapshot 2018-03-15 (a)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression
Assignee None
Priority Medium

md5: 1983d684f3aa3ad20f268cacc1e6be35

is blocked by:

  • SR-7206 ld: symbol(s) not found for classes defined in Swift marked as @objc

Issue Description:

In a simple macOS app (Sample project included) when using recent toolchains from `master` this crashes at runtime:

class CellView: NSTableCellView {
    @IBOutlet weak var titleLabel: NSTextField!
    var someProperty: DataRepresentation?
}

struct DataRepresentation {
    // Only crashes when this is Date property on a struct. If changed to a class that's fine
    var crashMe: Date?    
}

with:

2018-03-18 10:20:27.261628+0100 ClassNotFoundBug[45832:16130501] Unknown class _TtC16ClassNotFoundBug8CellView in Interface Builder file at path /Users/tkrajacic/Library/Developer/Xcode/DerivedData/ClassNotFoundBug-biraypbutaaxdabyognrjyhtibrz/Build/Products/Debug/ClassNotFoundBug.app/Contents/Resources/Base.lproj/Main.storyboardc/JYF-Ss-Ahw-view-Xjx-Sl-QvV.nib.
2018-03-18 10:20:27.264312+0100 ClassNotFoundBug[45832:16130501] Failed to connect (titleLabel) outlet from (NSTableCellView) to (NSTextField): missing setter or instance variable
Could not cast value of type 'NSTableCellView' (0x7fff8bf484c0) to 'ClassNotFoundBug.CellView' (0x600000162dd0).
2018-03-18 10:20:27.277315+0100 ClassNotFoundBug[45832:16130501] Could not cast value of type 'NSTableCellView' (0x7fff8bf484c0) to 'ClassNotFoundBug.CellView' (0x600000162dd0).

This runs fine without modification using any other toolchain branches (current 4.0.3, 4.1-snapshots)

When compiling with the latest toolchain the crash can be averted by either using a class as the DataRepresentation property, or by removing the `Date` property of said representation. (Only Date properties crash)

Talk about distilling this down from a large project 😉

@belkadan
Copy link
Contributor

@DougGregor, @jckarter, is this related to the ObjC class reference changes you've been doing? Or something else?

@belkadan
Copy link
Contributor

Oh, it's "something else". :-( "Date" is resilient on master, which means the class doesn't have a fixed size, which means we can't expose it to the ObjC runtime. Hm. cc @slavapestov, @gparker42

@swift-ci create

@tkrajacic
Copy link
Author

Haha, why do I always find such obscure bugs. I sometimes think I am the only one using AppKit with Swift 😛

Sry for the noise but I had to chuckle.

@belkadan
Copy link
Contributor

I think we knew this one was coming, but didn't expect anyone to be testing development snapshots so soon! (Thank you.)

@belkadan
Copy link
Contributor

…although I guess it's clear now that we aren't testing this sufficiently in our regression tests.

@slavapestov
Copy link
Member

#15720

@tkrajacic
Copy link
Author

Tested in Xcode 10 and Swift 4.2 and this seems to be fixed

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2
Projects
None yet
Development

No branches or pull requests

4 participants