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-372] Swift emits a segfaulting program for this source listing #42991

Open
drewcrawford opened this issue Dec 25, 2015 · 4 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself non-optimized only Flag: An issue whose reproduction requires non-optimized compilation

Comments

@drewcrawford
Copy link
Contributor

Previous ID SR-372
Radar None
Original Reporter @drewcrawford
Type Bug
Environment

Apple Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 17fe37d)
Target: x86_64-apple-macosx10.9

OSX 10.11.2 (15C50)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, NotOptimizedOnly
Assignee None
Priority Medium

md5: e7e51b2ff195e82069296a8a1d620811

relates to:

  • SR-392 Creating a String from an object of type ErrorType segfaults

Issue Description:

public enum Error: ErrorType {
    case ExitStatus(Int32, [String])
    case ExitSignal
}

extension Error: CustomStringConvertible {
    public var description: String {
        switch self {
        case .ExitStatus(let code, let args):
            return "exit(\(code)): \(args)"
        case .ExitSignal:
            return "Child process exited with signal"
        }
    }
}

func throwMe() throws {
    throw Error.ExitStatus(2, ["a"])
}
do {
    try throwMe()
} 
catch {
    print("\(error)")
}

Reproduction steps: `swift test.swift`

Expected results: Program prints an error message

Actual results:

0  swift                    0x000000010f24780b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x000000010f246ac6 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x000000010f247eb2 SignalHandler(int) + 322
3  libsystem_platform.dylib 0x00007fff92cd2eaa _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 1832046961
5  libswiftCore.dylib       0x0000000111f9696d _TTSf4s___TFSSg16debugDescriptionSS + 461
6  libswiftCore.dylib       0x0000000111f440ac _TTWSSs28CustomDebugStringConvertiblesFS_g16debugDescriptionSS + 44
7  libswiftCore.dylib       0x0000000111efd829 _TTSg5P__SSSSs16OutputStreamTypes___TFs20_debugPrint_unlockedu0_R_s16OutputStreamTyperFTxRq__T_ + 281
8  libswiftCore.dylib       0x0000000111f9a2bf _TTSf4g_gs_gs_n___TTSg5SSSSs16OutputStreamTypes___TFs11_debugPrintuRxs16OutputStreamTyperFTGSaP__9separatorSS10terminatorSS8toStreamRx_T_ + 319
9  libswiftCore.dylib       0x0000000111e44232 _TFSa16_makeDescriptionfT7isDebugSb_SS + 930
10 libswiftCore.dylib       0x0000000111e443a5 _TTWurGSax_s23CustomStringConvertiblesFS_g11descriptionSS + 37
11 libswiftCore.dylib       0x0000000111efc8a7 _TFs15_print_unlockedu0_R_s16OutputStreamTyperFTxRq__T_ + 903
12 libswiftCore.dylib       0x0000000111ed67d0 _TFSSCurfT26stringInterpolationSegmentx_SS + 64
13 libswiftCore.dylib       0x000000011188b4ca _TFSSCurfT26stringInterpolationSegmentx_SS + 4288367930
14 libswiftCore.dylib       0x000000011188b593 _TFSSCurfT26stringInterpolationSegmentx_SS + 4288368131
15 libswiftCore.dylib       0x0000000111efc8a7 _TFs15_print_unlockedu0_R_s16OutputStreamTyperFTxRq__T_ + 903
16 libswiftCore.dylib       0x0000000111ed67d0 _TFSSCurfT26stringInterpolationSegmentx_SS + 64
17 libswiftCore.dylib       0x000000011188b149 _TFSSCurfT26stringInterpolationSegmentx_SS + 4288367033
18 swift                    0x000000010d139251 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 1345
19 swift                    0x000000010d13c5bf 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*) + 1231
20 swift                    0x000000010d007b40 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&) + 2752
21 swift                    0x000000010cb192d3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 15187
22 swift                    0x000000010cb14b7a frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2794
23 swift                    0x000000010cb10147 main + 2855
24 libdyld.dylib            0x00007fff96afa5ad start + 1
25 libdyld.dylib            0x000000000000000c start + 1766873696
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-22-a.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.11.sdk -color-diagnostics -module-name test
Segmentation fault: 11
@gottesmm
Copy link
Member

Is this with optimization enabled?

@drewcrawford
Copy link
Contributor Author

It segfaults with and without optimizations enabled.

@gottesmm
Copy link
Member

Thanks!

@Dante-Broggi
Copy link
Contributor

I believe this has been fixed. if so, it should be closed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 non-optimized only Flag: An issue whose reproduction requires non-optimized compilation
Projects
None yet
Development

No branches or pull requests

3 participants