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-7967] Segfault using string interpolation with Optional value #50502

Closed
mdiep opened this issue Jun 11, 2018 · 6 comments
Closed

[SR-7967] Segfault using string interpolation with Optional value #50502

mdiep opened this issue Jun 11, 2018 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution standard library Area: Standard library umbrella

Comments

@mdiep
Copy link
Contributor

mdiep commented Jun 11, 2018

Previous ID SR-7967
Radar rdar://problem/41016510
Original Reporter @mdiep
Type Bug
Status Closed
Resolution Cannot Reproduce
Environment

This is with:

Swift version 4.2-dev (LLVM 031e148970, Clang b58a7ad218, Swift af428be609)
Target: x86_64-apple-darwin17.6.0

It works correctly with:

Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: b54325c016d320605d6c033721ab9a2a

Issue Description:

This code segfaults:

let value: String? = ""
_ = "\(value)"

Here's the output:

test.swift:2:7: warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit?
_ = "\(value)"
      ^~~~~~~
test.swift:2:8: note: use 'String(describing:)' to silence this warning
_ = "\(value)"
      ~^~~~~~
       String(describing:  )
test.swift:2:8: note: provide a default value to avoid this warning
_ = "\(value)"
      ~^~~~~~
             ?? <#default value#>
0  swift                    0x0000000113fab47c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  swift                    0x0000000113faba79 PrintStackTraceSignalHandler(void*) + 25
2  swift                    0x0000000113fa7149 llvm::sys::RunSignalHandlers() + 425
3  swift                    0x0000000113fac192 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fff61415f5a _sigtramp + 26
5  libsystem_platform.dylib 0x00007ffee41e14b0 _sigtramp + 2195502448
6  libswiftCore.dylib       0x0000000120b451e8 swift_getTupleTypeMetadata + 56
7  libswiftCore.dylib       0x000000012103ad39 $Ss13_FixedArray16VMr + 185
8  libswiftCore.dylib       0x0000000120b5b688 (anonymous namespace)::GenericCacheEntry::tryInitialize(swift::TargetMetadata<swift::InProcess>*, swift::PrivateMetadataState, swift::PrivateMetadataCompletionContext*) + 200
9  libswiftCore.dylib       0x0000000120b5b13f swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 495
10 libswiftCore.dylib       0x0000000120b58a09 swift::MetadataResponse swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::beginInitialization<swift::TargetTypeContextDescriptor<swift::InProcess> const*&, void const* const*&>(swift::ConcurrencyControl&, swift::MetadataRequest, swift::TargetTypeContextDescriptor<swift::InProcess> const*&&&, void const* const*&&&) + 57
11 libswiftCore.dylib       0x0000000120b431f3 std::__1::pair<(anonymous namespace)::GenericCacheEntry*, swift::MetadataResponse> swift::LockingConcurrentMap<(anonymous namespace)::GenericCacheEntry, false, void>::getOrInsert<swift::MetadataCacheKey, swift::MetadataRequest&, swift::TargetTypeContextDescriptor<swift::InProcess> const*&, void const* const*&>(swift::MetadataCacheKey, swift::MetadataRequest&&&, swift::TargetTypeContextDescriptor<swift::InProcess> const*&&&, void const* const*&&&) + 931
12 libswiftCore.dylib       0x0000000120b42dc2 swift_getGenericMetadata + 130
13 libswiftCore.dylib       0x0000000120fd406c $Ss13_FixedArray16VMa + 28
14 libswiftCore.dylib       0x0000000120d89429 $Ss13_FixedArray16Vss27ExpressibleByIntegerLiteralRzlE8allZerosAByxGyt_tcfC + 73
15 libswiftCore.dylib       0x0000000120ebfbb1 $Ss16_SmallUTF8StringV10transcodeds13_FixedArray16Vys6UInt16VG_Si5counttvg + 81
16 libswiftCore.dylib       0x0000000120ec5002 $Ss16_SmallUTF8StringV21UnicodeScalarIteratorVyAdBcfC + 50
17 libswiftCore.dylib       0x0000000120ec5ab0 $Ss16_SmallUTF8StringV25makeUnicodeScalarIteratorAB0efG0VyF + 32
18 libswiftCore.dylib       0x0000000120f308dd $SSS17UnicodeScalarViewV8IteratorV7_opaqueADs11_StringGutsV_tcfC + 669
19 libswiftCore.dylib       0x0000000120f30282 $SSS17UnicodeScalarViewV8IteratorVyADs11_StringGutsVcfC + 114
20 libswiftCore.dylib       0x0000000120eea975 $SSS17UnicodeScalarViewV12makeIteratorAB0E0VyF + 101
21 libswiftCore.dylib       0x0000000120cc0be3 $SSS16debugDescriptionSSvg + 163
22 libswiftCore.dylib       0x0000000120eeb191 $SSSs28CustomDebugStringConvertiblessAAP16debugDescriptionSSvgTW + 17
23 libswiftCore.dylib       0x0000000120d6c5bb $Ss20_debugPrint_unlockedyyx_q_zts16TextOutputStreamR_r0_lF + 539
24 libswiftCore.dylib       0x0000000120e55b17 $Ss11_debugPrint_9separator10terminator2toySayypG_S2Sxzts16TextOutputStreamRzlF + 551
25 libswiftCore.dylib       0x0000000120c9ba67 $Ss10debugPrint_9separator10terminator2toyypd_S2Sxzts16TextOutputStreamRzlF + 71
26 libswiftCore.dylib       0x0000000120e48051 $SSq16debugDescriptionSSvg + 545
27 libswiftCore.dylib       0x0000000120e48179 $SxSgs28CustomDebugStringConvertiblessABP16debugDescriptionSSvgTW + 9
28 libswiftCore.dylib       0x0000000120d6a8a1 $Ss15_print_unlockedyyx_q_zts16TextOutputStreamR_r0_lF + 481
29 libswiftCore.dylib       0x0000000120cc0a43 $SSS10describingSSx_tclufC + 83
30 libswiftCore.dylib       0x0000000120cad059 $SSS26stringInterpolationSegmentSSx_tclufC + 105
31 libswiftCore.dylib       0x00000001209fd113 $SSS26stringInterpolationSegmentSSx_tclufC + 4292149539
32 swift                    0x000000010d43630e llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 1358
33 swift                    0x000000010d442a14 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*) + 3716
34 swift                    0x000000010bbbd27c 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&) + 8988
35 swift                    0x000000010bb20f8f processCommandLineAndRunImmediately(swift::CompilerInvocation&, swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::FrontendObserver*, int&) + 1343
36 swift                    0x000000010bb0b245 performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 6629
37 swift                    0x000000010bafb91f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 4127
38 swift                    0x000000010baf8a2f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5039
39 swift                    0x000000010ba357ac main + 5068
40 libdyld.dylib            0x00007fff61107015 start + 1
Stack dump:
0.  Program arguments: /Users/mdiep/Repositories/apple/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/bin/swift -frontend -interpret /Users/mdiep/Repositories/apple/bugs/7380.swift -enable-objc-interop -sdk /Applications/Xcode10.0.0b1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name main 
zsh: segmentation fault  ./swift ~/Repositories/apple/bugs/7380.swift
@belkadan
Copy link
Contributor

@mikeash, @jckarter, does this look familiar?

@jckarter
Copy link
Member

@swift-ci create

@mikeash
Copy link
Contributor

mikeash commented Jun 11, 2018

I think this one is new to me. I'll check it out.

@mikeash
Copy link
Contributor

mikeash commented Jun 21, 2018

@mdiep I've finally taking a look at this and I'm afraid I can't reproduce the crash. I tried af428be as well as the latest master. Does it still crash for you with a recent master?

@mdiep
Copy link
Contributor Author

mdiep commented Jun 21, 2018

Nope, I'm not seeing this anymore.

@mikeash
Copy link
Contributor

mikeash commented Jun 21, 2018

Kind of disconcerting, but I guess it's good news? Thanks for checking so quickly!

@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. crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

5 participants