swiftlang / swiftlang/swift

Nil pointer dereference in libSwiftCore with Linux RedHat UBI9 on x86_64

Open
#80,909 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug crash triage needed
Dominant language
Swift
Stars
70.4k
Forks
10.8k
PR merge metrics
PR metrics pending

Description

Description

While running tests for swiftly on Linux x86_64 (RedHat UBI 9), I get the following nil pointer dereference crash in libSwiftCore;

warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors

*** Signal 11: Backtracing from 0x7f6c06cfff30... done ***

*** Program crashed: Bad pointer dereference at 0x0000000000000000 ***

...

Thread 5 crashed:

 0                  0x00007f6c06cfff30 swift::TargetMetadata<swift::InProcess>::getGenericArgs() const in libswiftCore.so
Reproduction

With a Linux system on x86_64 hardware and the RedHat UBI 9 distribution:

git clone https://github.com/cmcgee1024/swiftly.git -b convert_filepath
cd swiftly
git checkout a1c8e287ad97c3eafb6268d217775d6677b52c69
swift test
Stack dump
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors
warning: the Swift runtime was unable to demangle the type of field '_root'. the mangled type name is 'G,dy1MdG': unknown error. this field will show up as an empty tuple in Mirrors

*** Signal 11: Backtracing from 0x7f6c06cfff30... done ***

*** Program crashed: Bad pointer dereference at 0x0000000000000000 ***

Thread 0 "swiftlyPackageT":

0  0x00007f6c0500fa1a sigsuspend + 74 in libc.so.6

Thread 1:

0  0x00007f6c050578ba __futex_abstimed_wait_common + 202 in libc.so.6

Thread 2:

0  0x00007f6c050dee3e epoll_wait + 94 in libc.so.6

Thread 3:

0  0x00007f6c050578ba __futex_abstimed_wait_common + 202 in libc.so.6

Thread 4:

0  0x00007f6c050578ba __futex_abstimed_wait_common + 202 in libc.so.6

Thread 5 crashed:

 0                  0x00007f6c06cfff30 swift::TargetMetadata<swift::InProcess>::getGenericArgs() const in libswiftCore.so
 1 [ra]             0x00007f6c06d0b367 swift_getWitnessTable + 5046 in libswiftCore.so
 2 [ra] [system]    0x000055f876b54205 lazy protocol witness table accessor for type OptionGroup<GlobalOptions> and conformance OptionGroup<A> + 52 in swiftlyPackageTests.xctest at //<compiler-generated>
 3 [ra] [thunk]     0x000055f8772e560f Init.init(from:) + 1870 in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Sources/Swiftly/Init.swift
 4 [ra] [thunk]     0x000055f876b54730 protocol witness for Decodable.init(from:) in conformance Init + 31 in swiftlyPackageTests.xctest at //<compiler-generated>
 5 [ra]             0x00007f6c06cd57c7 dispatch thunk of Decodable.init(from:) + 6 in libswiftCore.so
 6 [ra]             0x000055f876ea8a69 CommandParser.parseCurrent(_:) + 1256 in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsing/CommandParser.swift:159:47
 7 [ra]             0x000055f876ea922b CommandParser.descendingParse(_:) + 234 in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsing/CommandParser.swift:184:31
 8 [ra]             0x000055f876ea9f9c CommandParser.parse(arguments:) + 635 in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsing/CommandParser.swift:243:11
 9 [ra]             0x000055f876ed4608 static ParsableCommand.parseAsRoot(_:) + 487 in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsable Types/ParsableCommand.swift:67:23
10 [ra]             0x000055f876c5639a static SwiftlyTests.runCommand<A>(_:_:) + 201 in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/SwiftlyTests.swift:183:34
11 [async]          0x000055f876c08690 closure #1 in InitTests.initFresh(_:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/InitTests.swift:31
12 [async] [thunk]  0x000055f876c0ca90 partial apply for closure #1 in InitTests.initFresh(_:) in swiftlyPackageTests.xctest at //<compiler-generated>
13 [async]          0x00007f6c067c81f0 TaskLocal.withValueImpl<A>(_:operation:isolation:file:line:) in libswift_Concurrency.so
14 [async]          0x00007f6c067c80c0 TaskLocal.withValue<A>(_:operation:isolation:file:line:) in libswift_Concurrency.so
15 [async]          0x000055f876c06dd0 InitTests.initFresh(_:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/InitTests.swift:16
16 [async]          0x000055f876c06850 static InitTests.$s12SwiftlyTests04InitB0V9initFresh4TestfMp_8da3c8337fMu_@Sendable (_:) in swiftlyPackageTests.xctest at /tmp/swift-generated-sources/@__swiftmacro_12SwiftlyTests04InitB0V9initFresh4TestfMp_.swift:4
17 [async] [system] 0x000055f876c07920 implicit closure #1 in static InitTests.$s12SwiftlyTests04InitB0V9initFresh4TestfMp_38__🟠$test_container__function__da3c8337fMu_.__tests.getter in swiftlyPackageTests.xctest at /tmp/swift-generated-sources/@__swiftmacro_12SwiftlyTests04InitB0V9initFresh4TestfMp_.swift
18 [async]          0x00007f6c055fcd70 closure #1 in closure #2 in Test.Case.Generator.init<>(arguments:parameters:testFunction:) in libTesting.so
19 [async] [thunk]  0x00007f6c055ff5f0 partial apply for closure #1 in closure #2 in Test.Case.Generator.init<>(arguments:parameters:testFunction:) in libTesting.so
20 [async]          0x00007f6c0562cac0 closure #1 in closure #1 in closure #1 in closure #1 in Runner._runTestCase(_:within:) in libTesting.so
21 [async] [thunk]  0x00007f6c05635480 partial apply for closure #1 in closure #1 in closure #1 in closure #1 in Runner._runTestCase(_:within:) in libTesting.so
22 [async] [thunk]  0x00007f6c05635540 thunk for @escaping @callee_guaranteed @Sendable @async () -> (@error @owned Error) in libTesting.so
23 [async]          0x00007f6c05635490 partial apply for thunk for @escaping @callee_guaranteed @Sendable @async () -> (@error @owned Error) in libTesting.so
24 [async] [thunk]  0x00007f6c05635530 thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out (), @error @owned Error) in libTesting.so
25 [async]          0x00007f6c056354b0 partial apply for thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out (), @error @owned Error) in libTesting.so
26 [async]          0x000055f876c537e0 closure #1 in TestHomeTrait.provideScope(for:testCase:performing:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/SwiftlyTests.swift:109
27 [async] [thunk]  0x000055f876c55bd0 partial apply for closure #1 in TestHomeTrait.provideScope(for:testCase:performing:) in swiftlyPackageTests.xctest at //<compiler-generated>
28 [async]          0x000055f876c58b40 closure #1 in closure #1 in static SwiftlyTests.withTestHome(name:_:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/SwiftlyTests.swift:255
29 [async] [thunk]  0x000055f876c75fc0 partial apply for closure #1 in closure #1 in static SwiftlyTests.withTestHome(name:_:) in swiftlyPackageTests.xctest at //<compiler-generated>
30 [async]          0x00007f6c067c81f0 TaskLocal.withValueImpl<A>(_:operation:isolation:file:line:) in libswift_Concurrency.so
31 [async]          0x00007f6c067c80c0 TaskLocal.withValue<A>(_:operation:isolation:file:line:) in libswift_Concurrency.so
32 [async]          0x000055f876c58220 closure #1 in static SwiftlyTests.withTestHome(name:_:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/SwiftlyTests.swift:254
33 [async] [thunk]  0x000055f876c58540 partial apply for closure #1 in static SwiftlyTests.withTestHome(name:_:) in swiftlyPackageTests.xctest at //<compiler-generated>
34 [async]          0x000055f876bbf590 withTemporary<A>(files:f:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Sources/SwiftlyCore/FileManager+FilePath.swift:54
35 [async]          0x000055f876c53b40 static SwiftlyTests.withTestHome(name:_:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/SwiftlyTests.swift:245
36 [async]          0x000055f876c535d0 TestHomeTrait.provideScope(for:testCase:performing:) in swiftlyPackageTests.xctest at /__w/swiftly/swiftly/Tests/SwiftlyTests/SwiftlyTests.swift:108
37 [async] [thunk]  0x000055f876c53e00 protocol witness for TestScoping.provideScope(for:testCase:performing:) in conformance TestHomeTrait in swiftlyPackageTests.xctest at //<compiler-generated>
38 [async]          0x00007f6c05626e90 implicit closure #2 in implicit closure #1 in closure #2 in Runner._applyScopingTraits(for:testCase:_:) in libTesting.so
39 [async]          0x00007f6c056354a0 partial apply for implicit closure #2 in implicit closure #1 in closure #2 in Runner._applyScopingTraits(for:testCase:_:) in libTesting.so
40 [async]          0x00007f6c05627040 closure #1 in closure #3 in Runner._applyScopingTraits(for:testCase:_:) in libTesting.so
41 [async]          0x00007f6c056354c0 partial apply for closure #1 in closure #3 in Runner._applyScopingTraits(for:testCase:_:) in libTesting.so
42 [async]          0x00007f6c056303d0 specialized Runner._applyScopingTraits(for:testCase:_:) in libTesting.so
43 [async]          0x00007f6c0562c930 closure #1 in closure #1 in closure #1 in Runner._runTestCase(_:within:) in libTesting.so
44 [async] [thunk]  0x00007f6c05635470 partial apply for closure #1 in closure #1 in closure #1 in Runner._runTestCase(_:within:) in libTesting.so
45 [async]          0x00007f6c0566e9a0 withTimeLimit(for:configuration:_:timeoutHandler:) in libTesting.so
46 [async]          0x00007f6c0562c6e0 closure #1 in closure #1 in Runner._runTestCase(_:within:) in libTesting.so
47 [async] [thunk]  0x00007f6c05635460 partial apply for closure #1 in closure #1 in Runner._runTestCase(_:within:) in libTesting.so
48 [async]          0x00007f6c055f9420 static Issue.withErrorRecording(at:configuration:isolation:_:) in libTesting.so
49 [async]          0x00007f6c0562c430 closure #1 in Runner._runTestCase(_:within:) in libTesting.so
50 [async] [thunk]  0x00007f6c056354d0 partial apply for closure #1 in Runner._runTestCase(_:within:) in libTesting.so
51 [async]          0x00007f6c067c81f0 TaskLocal.withValueImpl<A>(_:operation:isolation:file:line:) in libswift_Concurrency.so
52 [async]          0x00007f6c067c80c0 TaskLocal.withValue<A>(_:operation:isolation:file:line:) in libswift_Concurrency.so
53 [async]          0x00007f6c05623520 static Test.Case.withCurrent<A>(_:perform:) in libTesting.so
54 [async]          0x00007f6c0562c0b0 Runner._runTestCase(_:within:) in libTesting.so
55 [async]          0x00007f6c0562bd90 closure #2 in Runner._runTestCases<A>(_:within:) in libTesting.so
56 [async] [thunk]  0x00007f6c05635450 partial apply for closure #2 in Runner._runTestCases<A>(_:within:) in libTesting.so
57 [async]          0x00007f6c0562fa70 specialized closure #1 in closure #1 in Runner._forEach<A, B>(in:for:_:) in libTesting.so
58 [async] [thunk]  0x00007f6c05635440 partial apply for specialized closure #1 in closure #1 in Runner._forEach<A, B>(in:for:_:) in libTesting.so
59 [async] [system] 0x00007f6c067f5d30 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) in libswift_Concurrency.so

Thread 6:

0  0x00007f6c050578ba __futex_abstimed_wait_common + 202 in libc.so.6


Registers:

rax 0x0000000000000004  4
rdx 0x000055f878b977bc  00 00 01 00 00 00 00 00 3c 60 04 00 29 87 f1 ff  ········<`··)·ñÿ
rcx 0x000055f878b977b4  35 87 f1 ff 98 8e 84 fd 00 00 01 00 00 00 00 00  5·ñÿ···ý········
rbx 0x0000000000000001  1
rsi 0x0000000000000000  0
rdi 0x000055f878b977a0  41 87 f1 ff 78 00 00 00 00 00 00 00 00 00 03 00  A·ñÿx···········
rbp 0x00007f6bf99fd8f0  e0 d9 9f f9 6b 7f 00 00 67 b3 d0 06 6c 7f 00 00  àÙ·ùk···g³Ð·l···
rsp 0x00007f6bf99fd878  80 43 d1 06 6c 7f 00 00 00 d8 bd 78 f8 55 00 00  ·CÑ·l····Ø½xøU··
 r8 0x00000000000035a8  13736
 r9 0x0000000000000000  0
r10 0x0000000000000000  0
r11 0x00007f6c06de69bc  87 8d f3 ff a0 8d f3 ff b0 8d f3 ff c2 8d f3 ff  ··óÿ ·óÿ°·óÿ·óÿ
r12 0x000055f878b977a0  41 87 f1 ff 78 00 00 00 00 00 00 00 00 00 03 00  A·ñÿx···········
r13 0x000055f878b977a0  41 87 f1 ff 78 00 00 00 00 00 00 00 00 00 03 00  A·ñÿx···········
r14 0x00007f6be802b6a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
r15 0x00007f6be802b6a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
rip 0x00007f6c06cfff30  48 8b 0f 31 c0 48 81 f9 00 08 00 00 0f 43 c8 81  H··1ÀH·ù·····CÈ·

rflags 0x0000000000010206  PF

cs 0x0033  fs 0x0000  gs 0x0000


Images (18 omitted):

0x000055f876234000–0x000055f878a545c8 4e1e0052d4975b4e41c50cfaaf7b9a1e938d005f swiftlyPackageTests.xctest /__w/swiftly/swiftly/.build/x86_64-unknown-linux-gnu/debug/swiftlyPackageTests.xctest
0x00007f6c04fd1000–0x00007f6c0516ccdc 7a40a22c9a82854f3d66767232ae364a99174860 libc.so.6                  /usr/lib64/libc.so.6
0x00007f6c0556c000–0x00007f6c056bc068 edeaf8035b69f049156ee125ee55371908074ac3 libTesting.so              /root/.local/share/swiftly/toolchains/6.1.0/usr/lib/swift/linux/libTesting.so
0x00007f6c06777000–0x00007f6c067fc8a0 6e3a22d04f5ccf2a3035c22b3415d978660750a4 libswift_Concurrency.so    /root/.local/share/swiftly/toolchains/6.1.0/usr/lib/swift/linux/libswift_Concurrency.so
error: Exited with unexpected signal code 11
0x00007f6c0680e000–0x00007f6c06d98b50 9e86f37eecce9bf1d7c2d21327f4631b80a77357 libswiftCore.so            /root/.local/share/swiftly/toolchains/6.1.0/usr/lib/swift/linux/libswiftCore.so

Backtrace took 5.77s
Expected behavior

It's expected that the tests complete without crashing as they do with the other Linux distributions and versions (ubuntu 20.04, ubuntu 22.04, ubuntu 24.04, debian12).

Environment

Linux x86_64 on RedHat UBI 9, with Swift 6.1.0 installed.

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the RedHat UBI 9 x86_64 commands and swift test. Start from Sources/Swiftly/Init.swift, Tests/SwiftlyTests/InitTests.swift, and the stack frames for TargetMetadata.getGenericArgs and swift_getWitnessTable. Done means the test suite no longer triggers the nil pointer dereference on that environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.