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

Crash on reload every time #484

Open
everlof opened this issue Feb 1, 2024 · 6 comments
Open

Crash on reload every time #484

everlof opened this issue Feb 1, 2024 · 6 comments

Comments

@everlof
Copy link

everlof commented Feb 1, 2024

Hi,

While developing I suddenly couldn't use it anymore as it crashes on every reload. I know I can't modify the memory but I get crashes even by just changing this:

rootStackView.spacing = 20

to

rootStackView.spacing = 10

How can I debug this? I just crash with Thread 1: EXC_BAD_ACCESS (code=1, address=0x28)

Here's the stacktrace of the crash:

  * frame #0: 0x000000011c105c2c eval101.dylib`CalendarView.hasHeader.getter(self=0x00000001127efc40) at CalendarView.swift:47:30
    frame #1: 0x000000011c106a9c eval101.dylib`CalendarView.setup(self=0x00000001127efc40) at CalendarView.swift:100:12
    frame #2: 0x000000011c105718 eval101.dylib`CalendarView.init(date=2024-02-01 22:59:59 UTC, period=month) at CalendarView.swift:24:9
    frame #3: 0x000000011c105494 eval101.dylib`CalendarView.__allocating_init(date:period:) at CalendarView.swift:0
@johnno1962
Copy link
Owner

Hi, I'm wondering if this is a problem where a static singleton var is getting uninitialised. Without seeing your code I can't say much more. Let me know if you would like to TeamView.

@everlof
Copy link
Author

everlof commented Feb 1, 2024 via email

@everlof
Copy link
Author

everlof commented Feb 1, 2024

Maybe some additional info when running with some diagnostics:

💉 ⚠️ Loading .dylib has failed, This is likely because Swift code being injected references a function using a default argument or a member with access control that is too restrictive or perhaps an XCTest that depends on code not normally linked into your application. Rebuilding and re-running your project (without a build clean) can resolve this.
💉 Loading .dylib ...
💉 ⚠️ dlopen() error: dlopen(/Users/d/Library/Developer/CoreSimulator/Devices/EDFBEFFC-81AE-4D67-BF2A-1BD9B6719A1C/data/Containers/Data/Application/53ACE3EE-77EE-4F35-AAB0-43178F1D101C/tmp/eval104.dylib, 0x0002): symbol not found in flat namespace '___asan_option_detect_stack_use_after_return'
💉 ⚠️ Loading .dylib has failed, This is likely because Swift code being injected references a function using a default argument or a member with access control that is too restrictive or perhaps an XCTest that depends on code not normally linked into your application. Rebuilding and re-running your project (without a build clean) can resolve this.

@johnno1962
Copy link
Owner

You can email your details to github at johnholdsworth.com.

@everlof
Copy link
Author

everlof commented Feb 1, 2024

Hm, thanks, but maybe solved it myself. Your comment static singleton var is getting uninitialised. got me thinking.

Could this be caused by Calendar.autoupdatingCurrent perhaps?

Changing this:

calendarLogic = CalendarLogic(calendar: .autoupdatingCurrent, currentDate: date, period: period)

to

calendarLogic = CalendarLogic(calendar: .init(identifier: .gregorian), currentDate: date, period: period)

doesn't crash in the same location it seems.

@johnno1962
Copy link
Owner

Yes, when you inject, your static/top level vars get reinitialised as they live in the memory of the object file that has been injected. You can change this behaviour if you prefer by setting environment variable INJECTION_PRESERVE_STATICS then references to top level variables will always refer to their first definition. i.e. they won't get set to zero/nil. Happy you've sorted this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants