Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rconnell9
Copy link
Contributor

@rconnell9 rconnell9 commented Aug 13, 2025

Explanation:

(cherry picked from commit 16452e1)

Frequent crashes in LLBuildProgressTracker while building swift-java on linux and swift 6.1.2

This was a race condition because the
Command is associated with a handle (pointer) that may be reclaimed when this function finishes.

Scope:

Minimal, copy variables into locals before accessing them from async block.

Issues:

swiftlang/swift-java#314 almost all CI runs fail with this race condition due to the timing of the command being influenced by the gradle build in swift-java.

Original PRs:

#8998

Risk:

Minimal. Change explicitly copies variables prior to usage in async block. This avoided a race condition that would manifest before as null pointer crashes when trying to access these variables.

Change has been tested in main and 6.2

Testing:

Confirmed fixed in main and 6.2. Manually verified in always reproducing project.

…on linux and swift 6.1.2 (swiftlang#8998)

Frequent crashes in LLBuildProgressTracker while building swift-java on
linux and swift 6.1.2

> Thread 4 crashed:
>
> 0 0x00007f1559da359a swift_slowAlloc + 74 in
[libswiftCore.so](http://libswiftcore.so/)
> 1 [ra] 0x00007f1559da3877 swift_allocObject + 38 in
[libswiftCore.so](http://libswiftcore.so/)
> 2 [ra] 0x00007f1559b85571 _allocateStringStorage(codeUnitCapacity:) +
160 in [libswiftCore.so](http://libswiftcore.so/)
> 3 [ra] 0x00007f1559d03452 _StringGuts.grow(_:) + 273 in
[libswiftCore.so](http://libswiftcore.so/)
> 4 [ra] 0x00007f1559bf7e88 specialized static
String._fromUTF8Repairing(_:) + 999 in
[libswiftCore.so](http://libswiftcore.so/)
> 5 [ra] [inlined] [system] 0x000056315a96e7ef specialized
String.init<A, B>(decoding:as:) in swift-package at
//<compiler-generated>
> 6 [ra] [inlined] 0x000056315a96e7ef stringFromData(_:) in
swift-package at
/home/build-user/llbuild/products/llbuildSwift/Internals.swift:49:12
> 7 [ra] 0x000056315a96e7ef Command.name.getter + 78 in swift-package at
/home/build-user/llbuild/products/llbuildSwift/BuildSystemBindings.swift:720:20
> 8 [ra] 0x00005631593a61a2 closure swiftlang#1 in
LLBuildProgressTracker.commandProcessFinished(_:process:result:) + 33 in
swift-package at
/home/build-user/swiftpm/Sources/Build/LLBuildProgressTracker.swift:347:65
> 9 [ra] [thunk] 0x00005631592f6989 thunk for @escaping
@callee_guaranteed @sendable () -> () + 24 in swift-package at
//<compiler-generated>

Command is associated with a handle (pointer) that may be reclaimed when
this function finishes.

Do not access command attributes asynchronously

(cherry picked from commit 16452e1)
Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Lgtm! I confirmed this seems to resolve our issues when we tried a nightly toolchain with the fix.

Nitpick: Pr needs to follow the template a bit more

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@bkhouri bkhouri changed the title Frequent crashes in LLBuildProgressTracker while building swift-java on linux and swift 6.1.2 [6.1] Frequent crashes in LLBuildProgressTracker while building swift-java on linux and swift 6.1.2 Aug 13, 2025
@bkhouri bkhouri added the swift 6.1 Related to Swift 6.1 release branch label Aug 13, 2025
@ktoso ktoso merged commit 00feb23 into swiftlang:release/6.1 Aug 26, 2025
6 checks passed
@ktoso
Copy link
Contributor

ktoso commented Aug 26, 2025

@airspeedswift approved, merged. Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift 6.1 Related to Swift 6.1 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants