Crash when used in test target with asynchronous tests #501
Replies: 5 comments 2 replies
-
Dang, that's super frustrating 😕 A repro would be great. We haven't encountered this yet, but if we can narrow it down to a bug we can fix or file with Apple, that'd be great 😄 |
Beta Was this translation helpful? Give feedback.
-
Ok, I have finally managed to narrow down the cause to a single test function and have created a sample project which will repro the issue every time: https://github.com/mluisbrown/SnapshotBug The README for the repo explains everything, but I'll copy some of it here so the information is all in one place: When you run the tests (⌘U) they run fine but end in a crash in
I have enabled Zombie Objects diagnostics for the test target and with that enabled you also get an error in the console similar to:
You can make the bug happen earlier (before the tests end) if you uncomment the This will cause a slightly different Zombie error to appear in the console:
This bug is somehow related with the async nature of the test and the fact that Somehow the combination of the two async code paths is probably causing the run loop to release objects which otherwise would not be released. The root cause of the crashes is async tests similar to the once in the sample repo. Other types of async tests, eg with Nimble's |
Beta Was this translation helpful? Give feedback.
-
Just to clarify, if you do your async testing using So, I wouldn't categorize it as a bug necessarily, but it's something users should be aware of. |
Beta Was this translation helpful? Give feedback.
-
I'm experiencing the same issue very frequently now and was able to catch it using the address sanitizer Please let me know if there's more information that I can provide to help to isolate and fix this issue. I also noticed it happens in a view controller snapshot test in which the view controller displays a |
Beta Was this translation helpful? Give feedback.
-
I'm going to convert this to a discussion, as @mluisbrown notes, it's something folks may want to be aware of. If there are future related issues found that are due to bugs in SnapshotTesting that we can fix, though, please do open an issue! |
Beta Was this translation helpful? Give feedback.
-
As mentioned here. We have been trying to introduce the library to our project but are getting crashes in test targets which have asynchronous tests.
For example:
toEventually()
async testing they crash in Nimble's code to manage the runloopUIApplicationMain
) we get a crash trying which appears to be in a call toobjc_msgSend
.I enabled Zombie object diagnostics and in both of the above situations just before the crash I see this in the console:
*** -[CALayer setNeedsLayout]: message sent to deallocated instance 0x600000582da0
I'm sorry I can't provide more useful info right now. I will see if I can create a small project which reproduces the issue.
Beta Was this translation helpful? Give feedback.
All reactions