Skip to content

[Concurrency] Make leaks testing use the leaks macos tool#88375

Draft
ktoso wants to merge 2 commits intoswiftlang:mainfrom
ktoso:wip-leaks-test
Draft

[Concurrency] Make leaks testing use the leaks macos tool#88375
ktoso wants to merge 2 commits intoswiftlang:mainfrom
ktoso:wip-leaks-test

Conversation

@ktoso
Copy link
Copy Markdown
Contributor

@ktoso ktoso commented Apr 9, 2026

This is more reliable than the deinit printing which often is flaky when CI is slow etc.

Resolves rdar://174207235

Outputs are rather nice as well:

# | Process 8318: 453 nodes malloced for 55 KB
# | Process 8318: 0 leaks for 0 total leaked bytes.

And if we actually have a leak:

# | Process 82548: 5 leaks for 160 total leaked bytes.
# |
# | STACK OF 5 INSTANCES OF 'ROOT LEAK: <Something>':
# | 10  libsystem_pthread.dylib               0x18b01ec10 start_wqthread + 8
# | 9   libsystem_pthread.dylib               0x18b01fe84 _pthread_wqthread + 232
# | 8   libdispatch.dylib                     0x18ae7b120 _dispatch_worker_thread2 + 184
# | 7   libdispatch.dylib                     0x18ae7a980 _dispatch_root_queue_drain + 360
# | 6   libswift_Concurrency.dylib            0x100dbd578 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 188  Actor.cpp:2229
# | 5   libswift_Concurrency.dylib            0x100dbbfd0 swift::runJobInEstablishedExecutorContext(swift::Job*, swift::SerialExecutorRef, swift::TaskExecutorRef) + 228  Actor.cpp:238
# | 4   a.out                                 0x100d114e8 closure #1 in closure #1 in test_taskGroup_next() + 72
# | 3   a.out                                 0x100d10be0 Something.__allocating_init(int:) + 44
# | 2   libswiftCore.dylib                    0x102968bc4 swift_allocObject + 64  HeapObject.cpp:275
# | 1   libswiftCore.dylib                    0x102968744 swift_slowAlloc + 48  Heap.cpp:94
# | 0   libsystem_malloc.dylib                0x18ae50178 _malloc_zone_malloc_instrumented_or_legacy + 152
# | ====
# |     5 (160 bytes) << TOTAL >>
# |       1 (32 bytes) ROOT LEAK: <Something 0x827028060> [32]
# |       1 (32 bytes) ROOT LEAK: <Something 0x827028080> [32]
# |       1 (32 bytes) ROOT LEAK: <Something 0x8270280a0> [32]
# |       1 (32 bytes) ROOT LEAK: <Something 0x8270280c0> [32]
# |       1 (32 bytes) ROOT LEAK: <Something 0x8270280e0> [32]

etc

@ktoso ktoso requested a review from a team as a code owner April 9, 2026 02:59
@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 9, 2026

@swift-ci please smoke test

@ktoso ktoso requested review from al45tair, mikeash and xedin April 9, 2026 03:42
@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 9, 2026

@swift-ci please smoke test

Copy link
Copy Markdown
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

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

Looks good, although it's unfortunate to lose coverage on other platforms. In practice there shouldn't be any cross-platform variation that would cause a leak only on some other platform.

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 10, 2026

Yeah, unfortunately not great drop in equivalent on the other platforms 😢 We could make something but that'd be more work...

Thanks for review

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 10, 2026

@swift-ci please smoke test

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 10, 2026

@swift-ci please smoke test macOS

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 11, 2026

@swift-ci please smoke test macOS platform

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 13, 2026

Turns out this gets stuck on CI, likely due to leaks needing more permissions hm... Looking into it some more

This is more reliable than the deinit printing which often is flaky when
CI is slow etc.

Resolves rdar://174207235
@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 13, 2026

@swift-ci please smoke test

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 13, 2026

Nope, this also doesn't work on CI.

@ktoso
Copy link
Copy Markdown
Contributor Author

ktoso commented Apr 13, 2026

We may need to give up on leaks on CI and make this just some countdown latch style test.

@ktoso ktoso marked this pull request as draft April 13, 2026 13:27
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

Successfully merging this pull request may close these issues.

3 participants