Skip to content

Fix null-ptr write with pthread_create #356

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

Merged
merged 2 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/JavaScriptEventLoop/WebWorkerTaskExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,9 @@ public final class WebWorkerTaskExecutor: TaskExecutor {
let unmanagedContext = Unmanaged.passRetained(context)
contexts.append(unmanagedContext)
let ptr = unmanagedContext.toOpaque()
var thread = pthread_t(bitPattern: 0)
let ret = pthread_create(
nil,
&thread,
nil,
{ ptr in
// Cast to a optional pointer to absorb nullability variations between platforms.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ final class JavaScriptEventLoopTests: XCTestCase {
let result = try await promise2.value
XCTAssertEqual(result, .string("3.0"))
}
XCTAssertGreaterThanOrEqual(thenDiff, 200)
XCTAssertGreaterThanOrEqual(thenDiff, 150)
}

func testPromiseThenWithFailure() async throws {
Expand Down