You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
An EXC_BAD_ACCESS related to a null pointer (0x0) is encountered when attempting to run the unit test below.
Note that this only occurs via the command line; running this in Xcode will not generate a null pointer.
Steps to reproduce
This reproducer requires three files; the directory tree looks like this:
Test Case '-[aTestTest.Z testA]' started.
error: Exited with unexpected signal code 11
To run via lldb, use:
swift build --build-tests
lldb /Applications/Xcode.app/Contents/Developer/usr/bin/xctest ./.build/arm64-apple-macosx/debug/aTestPackageTests.xctest
(lldb) run
Expected behavior
The test should print (value: 2.4, pullback: (Function))
and exit with an exit code of 0.
Environment
Swift compiler version info: 2023-10-08a, 2023-10-15a
Xcode version info: N/A
Deployment target: macOS 13.6
Additional context
If we remove the control flow in line 3, that is, we replace it with: @differentiable(reverse) private func m(a: Double) -> Double {var c = 0.0; c = c + 2.4; return c}
then the program will run as expected.
Did some investigation into this issue and have the following findings.
The issue only happens on mac OS and does not need XCTest at all. In fact a further reduced version of the reproducer can can be put into a single file, compiled with swiftc and the failure will still happen.
import _Differentiation;
@differentiable(reverse)
func m(x: Double) -> Double {
for _ in 0 ... 0 {}
return 1.0
}
let _ = valueWithPullback(at: 2.3, of: m)
The issue is an artifact of some breaking changes that we had to make to fix a memory leak issue in the Swift Autodiff runtime.
The exact cause of the issue is that the code generated by the snapshot toolchain compiler is incompatible with mac OS' system swift-stdlib that is used by the package/executable at runtime.
The code uses autodiff builtin functions that don't exist in mac OS' system swift-stdlib.
%2 = metatype $@thick (predecessor: _AD__$s4main1m1xS2d_tF_bb3__Pred__src_0_wrt_0).Type // user: %3
// This function does not exist in mac OS' system swift-stdlib
%3 = builtin "autoDiffCreateLinearMapContextWithType"(%2 : $@thick (predecessor:
...
Description
An
EXC_BAD_ACCESS
related to a null pointer (0x0) is encountered when attempting to run the unit test below.Note that this only occurs via the command line; running this in Xcode will not generate a null pointer.
Steps to reproduce
This reproducer requires three files; the directory tree looks like this:
Listing for
Package.swift
:Listing for
test.swift
:The
main.swift
file can be blank.To run via command line, simply run:
swift test
This will generate output like this:
To run via
lldb
, use:Expected behavior
The test should print
(value: 2.4, pullback: (Function))
and exit with an exit code of 0.
Environment
Additional context
If we remove the control flow in line 3, that is, we replace it with:
@differentiable(reverse) private func m(a: Double) -> Double {var c = 0.0; c = c + 2.4; return c}
then the program will run as expected.
Stack trace (via
lldb
):The text was updated successfully, but these errors were encountered: