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

URL.appendingPathComponent crashes on Linux #4849

Open
MahdiBM opened this issue Dec 1, 2023 · 0 comments
Open

URL.appendingPathComponent crashes on Linux #4849

MahdiBM opened this issue Dec 1, 2023 · 0 comments

Comments

@MahdiBM
Copy link

MahdiBM commented Dec 1, 2023

To reproduce on an M1 device:

docker run --rm swift:5.9-jammy swift -e "import Foundation; URL(string: \"https://apple.com\")?.appendingPathComponent(\"\")"

Which executes this on a Linux environment:

import Foundation
URL(string: "https://apple.com")?.appendingPathComponent("")
  • Apparently doesn't happen with non-empty strings in appendingPathComponent()
  • Also doesn't happen if the url contains a trailing slash: URL(string: "https://apple.com/")
  • Happens on amd architecture as well.
  • Happens on 5.8 too.
  • Works fine on Darwin.
    • Only appends a trailing slash incase the appendingPathComponent() contains an empty string.

Stack trace:

Stack dump:
0.	Program arguments: /usr/bin/swift-frontend -frontend -interpret /tmp/TemporaryDirectory.5nN1kF/main.swift -Xllvm -aarch64-use-tbi -disable-objc-interop -new-driver-path /usr/bin/swift-driver -empty-abi-descriptor -resource-dir /usr/lib/swift -module-name main -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins
1.	Swift version 5.9.1 (swift-5.9.1-RELEASE)
2.	Compiling with the current language version
3.	While running user code "/tmp/TemporaryDirectory.5nN1kF/main.swift"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/usr/bin/swift-frontend(+0x5925e38)[0xaaaad6055e38]
/usr/bin/swift-frontend(+0x5924014)[0xaaaad6054014]
/usr/bin/swift-frontend(+0x5926254)[0xaaaad6056254]
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffffa447b790]
/usr/lib/swift/linux/libFoundation.so($s10Foundation8NSStringC9character2ats6UInt16VSi_tF+0x128)[0xffff9b40adec]
/usr/lib/swift/linux/libFoundation.so($s10Foundation33_CFSwiftStringGetCharacterAtIndex_5indexs6UInt16VyXl_SitF+0x48)[0xffff9b37baa4]
/usr/lib/swift/linux/libFoundation.so(+0x4acb38)[0xffff9b41cb38]
/usr/lib/swift/linux/libFoundation.so(CFURLCreateCopyAppendingPathComponent+0x118)[0xffff9b586544]
/usr/lib/swift/linux/libFoundation.so($s10Foundation5NSURLC22appendingPathComponentyAA3URLVSgSSF+0x7c)[0xffff9b4297a8]
/usr/lib/swift/linux/libFoundation.so($s10Foundation3URLV22appendingPathComponentyACSSF+0x68)[0xffff9b4a8550]
[0xffffa4472070]
/usr/bin/swift-frontend(+0xd5d5b0)[0xaaaad148d5b0]
/usr/bin/swift-frontend(+0xc5c538)[0xaaaad138c538]
/usr/bin/swift-frontend(+0xc1aa80)[0xaaaad134aa80]
/usr/bin/swift-frontend(+0xc17174)[0xaaaad1347174]
/usr/bin/swift-frontend(+0xc16450)[0xaaaad1346450]
/usr/bin/swift-frontend(+0xc1887c)[0xaaaad134887c]
/usr/bin/swift-frontend(+0xc17a28)[0xaaaad1347a28]
/usr/bin/swift-frontend(+0xa92d80)[0xaaaad11c2d80]
/lib/aarch64-linux-gnu/libc.so.6(+0x273fc)[0xffffa2b173fc]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffffa2b174cc]
/usr/bin/swift-frontend(+0xa91cb0)[0xaaaad11c1cb0]

*** Program crashed: System trap at 0x0000ffff9b40adec ***

Thread 0 "swift-frontend" crashed:

 0              0x0000ffff9b40adec NSString.character(at:) + 296 in libFoundation.so
 1 [ra]         0x0000ffff9b37baa4 _CFSwiftStringGetCharacterAtIndex(_:index:) + 71 in libFoundation.so
 2 [ra] [thunk] 0x0000ffff9b41cb38 @objc _CFSwiftStringGetCharacterAtIndex(_:index:) + 31 in libFoundation.so
 3 [ra]         0x0000ffff9b586544 CFURLCreateCopyAppendingPathComponent + 279 in libFoundation.so
 4 [ra]         0x0000ffff9b4297a8 NSURL.appendingPathComponent(_:) + 123 in libFoundation.so
 5 [ra]         0x0000ffff9b4a8550 URL.appendingPathComponent(_:) + 103 in libFoundation.so
 6 [ra]         0x0000ffffa4472070
 7 [ra]         0x0000aaaad148d5b0 llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::Optional<llvm::StringRef>) + 1315 in swift-frontend
 8 [ra]         0x0000aaaad138c538 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions const&, swift::SILOptions const&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >&&) + 5211 in swift-frontend
 9 [ra]         0x0000aaaad134aa80 processCommandLineAndRunImmediately(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >&&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::FrontendObserver*, int&) + 167 in swift-frontend
10 [ra]         0x0000aaaad1347174 performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1111 in swift-frontend
11 [ra]         0x0000aaaad1346450 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 731 in swift-frontend
12 [ra]         0x0000aaaad134887c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1243 in swift-frontend
13 [ra]         0x0000aaaad1347a28 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 1919 in swift-frontend
14 [ra]         0x0000aaaad11c2d80 swift::mainEntry(int, char const**) + 3455 in swift-frontend
15 [ra]         0x0000ffffa2b173fc <unknown> in libc.so.6
16 [ra]         0x0000ffffa2b174cc <unknown> in libc.so.6


Registers:

 x0 0x0000000000000000  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
 x1 0x0000ffffa41c6134  fd 7b bd a9 f5 0b 00 f9 f4 4f 02 a9 fd 03 00 91  ý{½©õ··ùôO·©ý···
 x2 0x0000000000000000  fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd  ýýýýýýýýýýýýýýýý
 x3 0xe000000000000000  fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd  ýýýýýýýýýýýýýýýý
 x4 0x0000000000000000  fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd  ýýýýýýýýýýýýýýýý
 x5 0x0000ffffc1593040  70 30 59 c1 ff ff 00 00 50 ad 40 9b ff ff 00 00  p0YÁÿÿ··P­@·ÿÿ··
 x6 0x0000000000000001  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
 x7 0x0000000000000001  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
 x8 0x0000000000000000  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
 x9 0x0000000000000000  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
x10 0x000000000000000c  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
x11 0x0000000000000000  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
x12 0x612f2f3a73707474  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
x13 0x0000000000000000  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
x14 0x0000000000000000  70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70  pppppppppppppppp
x15 0x0000ffffa441fc30  00 02 00 00 00 00 00 00 2c f4 33 a4 ff ff 00 00  ········,ô3¤ÿÿ··
x16 0x0000ffff9b6b0080  a8 87 20 a4 ff ff 00 00 d8 4f 22 9b ff ff 00 00  ¨· ¤ÿÿ··ØO"·ÿÿ··
x17 0x0000ffffa42087a8  08 f0 7d 92 00 f1 41 92 42 ee fe 17 08 f0 7d 92  ·ð}··ñA·Bîþ··ð}·
x18 0x0000000000000000  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x19 0xe000000000000000  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x20 0x000000000000000d  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x21 0x0000000000000000  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x22 0x0000000000000000  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x23 0xe000000000000000  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x24 0x0000000000000011  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x25 0x0000000000000000  08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08  ················
x26 0x0000aaaaf37f4e80  b8 4e 6c 9b ff ff 00 00 03 00 00 00 04 00 00 00  ¸Nl·ÿÿ··········
x27 0x0000aaaaf37c8460  00 d1 71 f3 aa aa 00 00 00 00 00 00 00 00 00 00  ·Ñq󪪷·········
x28 0x0000aaaaf36cbf20  00 d1 71 f3 aa aa 00 00 00 00 00 00 00 00 00 00  ·Ñq󪪷·········
 fp 0x0000ffffc1593070  b0 30 59 c1 ff ff 00 00 a4 ba 37 9b ff ff 00 00  °0YÁÿÿ··¤º7·ÿÿ··
 lr 0x0000ffff9b40ad50  7f 02 44 f2 a9 ee 7b d3 e8 17 9f 1a 8a 06 7e 92  ··Dò©î{Óè·····~·
 sp 0x0000ffffc1593070  b0 30 59 c1 ff ff 00 00 a4 ba 37 9b ff ff 00 00  °0YÁÿÿ··¤º7·ÿÿ··
 pc 0x0000ffff9b40adec  20 00 20 d4 e0 03 14 aa e1 03 15 aa e2 03 13 aa   · Ôà··ªá··ªâ··ª


Images (29 omitted):

0x0000aaaad0730000–0x0000aaaad6b92210 <no build ID>                            swift-frontend   /usr/bin/swift-frontend
0x0000ffff9af70000–0x0000ffff9b66fda0 <no build ID>                            libFoundation.so /usr/lib/swift/linux/libFoundation.so
0x0000ffffa2af0000–0x0000ffffa2c78274 317350dd9c806d5dfe9358afcdca6bf56f2b0a54 libc.so.6        /usr/lib/aarch64-linux-gnu/libc.so.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant