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-14233] [AutoDiff] Weird runtime behavior when printing @differentiable functions #54757

Closed
dan-zheng opened this issue Mar 6, 2020 · 1 comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-14233
Radar None
Original Reporter @dan-zheng
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AutoDiff
Assignee None
Priority Medium

md5: 774bac7247c22922195bf596aa93de79

relates to:

Issue Description:

func id(_ x: Float) -> Float { x }
let functions: [@differentiable (Float) -> Float] = [id]
print(functions)

Immediate:

$ swift fn.swift
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2020-03-04-a.xctoolchain/usr/bin/swift -frontend -interpret fn.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name fn
0  swift                    0x0000000112562e75 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001125620b5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000011256345c SignalHandler(int) + 268
3  libsystem_platform.dylib 0x00007fff6c1b642d _sigtramp + 29
4  swift                    0x0000000114dc6e4b cmark_strbuf__initbuf + 175006
5  swift                    0x000000011240546b llvm::ConstantDataSequential::~ConstantDataSequential() + 27
6  swift                    0x000000011240546b llvm::ConstantDataSequential::~ConstantDataSequential() + 27
7  swift                    0x0000000112403874 llvm::LLVMContextImpl::~LLVMContextImpl() + 14948
8  swift                    0x00000001123fde16 llvm::LLVMContext::~LLVMContext() + 22
9  swift                    0x000000010f524293 llvm::object_deleter<llvm::LLVMContext>::call(void*) + 19
10 swift                    0x0000000112506fc8 llvm::llvm_shutdown() + 120
11 swift                    0x00000001124de043 llvm::InitLLVM::~InitLLVM() + 19
12 swift                    0x000000010e4298b0 main + 912
13 libdyld.dylib            0x00007fff6bfbd7fd start + 1

Compilation:

$ swiftc fn.swift
$ ./fn
3.1621606e-34

The weird value looks like some memory error (e.g. use after free). But SIL verification didn't catch it.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@BradLarson
Copy link
Collaborator

This no longer produces a segfault or bad memory access, it prints [(Function)]. I think it's probably safe to close out this older issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants