Code Monkey home page Code Monkey logo

Comments (5)

stephencelis avatar stephencelis commented on July 30, 2024

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 πŸ˜„

from swift-snapshot-testing.

mluisbrown avatar mluisbrown commented on July 30, 2024

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 UIApplicationMain:

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

I have enabled Zombie Objects diagnostics for the test target and with that enabled you also get an error in the console similar to:

*** -[CALayer setNeedsLayout]: message sent to deallocated instance 0x60000327d100

You can make the bug happen earlier (before the tests end) if you uncomment the autoreleasepool block in SnapshotBugTests.swift

This will cause a slightly different Zombie error to appear in the console:

*** -[UIWindowLayer isHidden]: message sent to deallocated instance 0x600000d4cd60

This bug is somehow related with the async nature of the test and the fact that SnapshotTesting also uses XCWaiter. This kind of test works fine when using ios-snapshot-test-case which is not async.

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 toEventually don't cause the problem, but they can surface the crash earlier in the test suite.

from swift-snapshot-testing.

mluisbrown avatar mluisbrown commented on July 30, 2024

Just to clarify, if you do your async testing using .asyncPullback this issue does not exist. It's an issue if you use SnapshotTesting together with your own async code.

So, I wouldn't categorize it as a bug necessarily, but it's something users should be aware of.

from swift-snapshot-testing.

daehn avatar daehn commented on July 30, 2024

I'm experiencing the same issue very frequently now and was able to catch it using the address sanitizer SUMMARY: AddressSanitizer: heap-use-after-free (libclang_rt.asan_iossim_dynamic.dylib:x86_64+0x1a547) in wrap_memcpy.

Please let me know if there's more information that I can provide to help to isolate and fix this issue.

Screenshot 2019-03-29 at 13 58 48

I also noticed it happens in a view controller snapshot test in which the view controller displays a MKMapView, does not happen in any other of our snapshot tests.

from swift-snapshot-testing.

stephencelis avatar stephencelis commented on July 30, 2024

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!

from swift-snapshot-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.