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-5861] [4.0] function abnormally releasing instance #48431

Closed
belkadan opened this issue Sep 8, 2017 · 2 comments
Closed

[SR-5861] [4.0] function abnormally releasing instance #48431

belkadan opened this issue Sep 8, 2017 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression run-time crash Bug → crash: Swift code crashed during execution swift 4.0

Comments

@belkadan
Copy link
Contributor

belkadan commented Sep 8, 2017

Previous ID SR-5861
Radar rdar://problem/34333874
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression, Miscompile, RunTimeCrash
Assignee @xedin
Priority Medium

md5: d59aa2a1882ff36dfae7cbc024c5576a

cloned from:

  • SR-2773 function abnormally releasing instance.

Issue Description:

import Foundation
public func with<T: AnyObject>(_ item: T, update: (inout T) throws -> Void) rethrows -> T {
    var this = item
    try update(&this)
    return this
}

let p = Process()
let task3 = with(p) {
    $0.launchPath = "/usr/bin/mdfind"
    $0.arguments = ["kMDItemDisplayName == *.playground"]
    $0.standardOutput = pipe
}

let task4 = with(Process()) {
    $0.launchPath = "/usr/bin/mdfind"
    $0.arguments = ["kMDItemDisplayName == *.playground"]
    $0.standardOutput = pipe
}
print(task3)
print(task4)

The second test (task4) fails.

% swiftc test.swift
% ./test
<NSConcreteTask: 0x7fb531c0b200>
Segmentation fault
% swift test.swift
<NSConcreteTask: 0x7fad8b6cfbe0>
0  swift                    0x000000010d0a7b6d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x000000010d0a75b6 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffce81fbba _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 830342240
4  swift                    0x000000010a9821b8 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 456
5  swift                    0x000000010a98774b llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 763
6  swift                    0x000000010a4d3662 swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 3234
7  swift                    0x000000010a4be07e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23358
8  swift                    0x000000010a4b6265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
9  swift                    0x000000010a47382d main + 8685
10 libdyld.dylib            0x00007fffce613255 start + 1
11 libdyld.dylib            0x000000000000000c start + 832490936
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name test 
Segmentation fault
% 
@belkadan
Copy link
Contributor Author

belkadan commented Sep 8, 2017

Broken again in Xcode 9, reported by @hujunfeng.

@swift-ci create

@xedin
Copy link
Member

xedin commented Sep 12, 2017

Should be resolved by PR #11855

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression run-time crash Bug → crash: Swift code crashed during execution swift 4.0
Projects
None yet
Development

No branches or pull requests

3 participants