Skip to content

Remove C++ dependency from thread state#108

Open
ggeier wants to merge 6 commits into
mainfrom
remove-thread-libcxx-dependency
Open

Remove C++ dependency from thread state#108
ggeier wants to merge 6 commits into
mainfrom
remove-thread-libcxx-dependency

Conversation

@ggeier

@ggeier ggeier commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Convert the thread state implementation from C++ to C so libcoldtrace no longer pulls in libc++/libstdc++.
  • Replace std::vector stack storage with malloc/free-backed stack storage while preserving stack diff serialization.
  • Update the coldtrace source list to build thread.c instead of thread.cpp.

Verification

  • cmake --build build -j
  • ldd build/src/libcoldtrace.so shows only libc and the dynamic loader
  • ctest --test-dir build --output-on-failure currently reports 32/45 passing with existing trace-checker failures

@ggeier ggeier force-pushed the remove-thread-libcxx-dependency branch from ac90a7e to b2548b3 Compare May 11, 2026 20:22
ggeier added 2 commits May 11, 2026 22:32
Signed-off-by: Gideon Sebastian Geier <gideon.sebastian.geier@huawei.com>
Signed-off-by: Gideon Sebastian Geier <gideon.sebastian.geier@huawei.com>
@ggeier ggeier force-pushed the remove-thread-libcxx-dependency branch from b2548b3 to c3ee667 Compare May 11, 2026 20:33
Signed-off-by: Gideon Sebastian Geier <gideon.sebastian.geier@huawei.com>
@db7 db7 self-requested a review May 18, 2026 06:25

@db7 db7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I think this is a good improvement. It removes one potential source of problems.

@ggeier

ggeier commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

There's just one problem left to solve: apparently, this uncovers a race between the first trace entry and file creation and the attribute constructor that calls the cleanup. At least the pipeline seems to show that:
https://github.com/open-s4c/coldtrace/actions/runs/25734106254/job/75566434211

coldtrace: copy procmaps
coldtrace: fopen '/home/runner/work/coldtrace/coldtrace/build/test/unmap__traces/freezer_log_1_0.bin (deleted)': No such file or directory
coldtrace: Failed to copy mapped files to '/home/runner/work/coldtrace/coldtrace/build/test/unmap__traces', coldtrace dump will be incomplete

For now, the pipeline just passes, because I disabled the cleanup. I assume it is a race, because I don't have this issue on my machine. However, it could be also deterministically first alloc/trace entry, constructor and cleanup, and then the remaining tracing.

@db7

db7 commented May 18, 2026

Copy link
Copy Markdown
Member

There's just one problem left to solve: apparently, this uncovers a race between the first trace entry and file creation and the attribute constructor that calls the cleanup. At least the pipeline seems to show that: https://github.com/open-s4c/coldtrace/actions/runs/25734106254/job/75566434211

coldtrace: copy procmaps
coldtrace: fopen '/home/runner/work/coldtrace/coldtrace/build/test/unmap__traces/freezer_log_1_0.bin (deleted)': No such file or directory
coldtrace: Failed to copy mapped files to '/home/runner/work/coldtrace/coldtrace/build/test/unmap__traces', coldtrace dump will be incomplete

For now, the pipeline just passes, because I disabled the cleanup. I assume it is a race, because I don't have this issue on my machine. However, it could be also deterministically first alloc/trace entry, constructor and cleanup, and then the remaining tracing.

I will try to reproduce on my side.

@db7

db7 commented May 27, 2026

Copy link
Copy Markdown
Member

There's just one problem left to solve: apparently, this uncovers a race between the first trace entry and file creation and the attribute constructor that calls the cleanup. At least the pipeline seems to show that: https://github.com/open-s4c/coldtrace/actions/runs/25734106254/job/75566434211

coldtrace: copy procmaps

coldtrace: fopen '/home/runner/work/coldtrace/coldtrace/build/test/unmap__traces/freezer_log_1_0.bin (deleted)': No such file or directory

coldtrace: Failed to copy mapped files to '/home/runner/work/coldtrace/coldtrace/build/test/unmap__traces', coldtrace dump will be incomplete

For now, the pipeline just passes, because I disabled the cleanup. I assume it is a race, because I don't have this issue on my machine. However, it could be also deterministically first alloc/trace entry, constructor and cleanup, and then the remaining tracing.

I will try to reproduce on my side.

I couldnt reproduce on my Ubuntu system

@ggeier

ggeier commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

I ran once the pipeline without changes to confirm it's not because github changed the runners #110. And I made the current change no longer be triggered by no longer calling thread_stack_push (#109) to make sure our code change is not triggering this. It seems that the change from having a libc++ dependency to no longer having it is actually the culprit.

@db7

db7 commented May 29, 2026

Copy link
Copy Markdown
Member

@ggeier - I am quite confused now. Why is this branching #108 passing now?

@ggeier

ggeier commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

070e188 'fixed' it: disabling the cleanup in the pipeline, but this can't be the solution

@db7

db7 commented May 29, 2026

Copy link
Copy Markdown
Member

070e188 'fixed' it: disabling the cleanup in the pipeline, but this can't be the solution

Ok, if that was the change than I really cannot reproduce it.

@db7 db7 force-pushed the remove-thread-libcxx-dependency branch 2 times, most recently from 6cee6ef to 2ff0287 Compare May 29, 2026 14:22
Signed-off-by: Diogo Behrens <db7@sdf.org>
@db7 db7 force-pushed the remove-thread-libcxx-dependency branch from b4c4497 to 9d730ba Compare May 29, 2026 14:42
db7 added 2 commits May 29, 2026 16:45
Signed-off-by: Diogo Behrens <db7@sdf.org>
Signed-off-by: Diogo Behrens <db7@sdf.org>
@ggeier ggeier force-pushed the remove-thread-libcxx-dependency branch from 58fc021 to c090e34 Compare June 16, 2026 16:38
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.

2 participants