This is an archive of the discontinued LLVM Phabricator instance.

[LIBC] Fix incorrect handling of `pthread_join(tid, nullptr)`
ClosedPublic

Authored by goldstein.w.n on Apr 13 2023, 8:05 PM.

Details

Summary

Previously unconditionally stored to the return value. This is
incorrect, we should only return if user value is non-null.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Apr 13 2023, 8:05 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 13 2023, 8:05 PM
goldstein.w.n requested review of this revision.Apr 13 2023, 8:05 PM

Can you please separate this patch out into two so that the null return value can be go in separately? I can then also add comments for the other changes in their own focused review.

Remove unrelated changes

Can you please separate this patch out into two so that the null return value can be go in separately? I can then also add comments for the other changes in their own focused review.

Done.

Sorry for more work, but this change is required for proper functioning of https://reviews.llvm.org/D148291, which has already landed. So, can you just prepare patch for the nullptr handling and not make it depend on the attributes patch? Or, make the tests in the patch not use the detach functionality. Either way, we should land this patch with some urgency.

libc/test/integration/src/pthread/pthread_join_test.cpp
58

We should not use randomized inputs/data in unit tests because we want them to be reproducible.

Remove dep on pthread_create patch
Use reproducible rand

Sorry for more work, but this change is required for proper functioning of https://reviews.llvm.org/D148291, which has already landed. So, can you just prepare patch for the nullptr handling and not make it depend on the attributes patch? Or, make the tests in the patch not use the detach functionality. Either way, we should land this patch with some urgency.

Oh shoot, forgot about the dependency when I pushed!

Updated v2 so no deps. If any issue I can just revert D148291

libc/test/integration/src/pthread/pthread_join_test.cpp
58

Switched with fixed seed rand. That should be reproducible.

sivachandra accepted this revision.Apr 20 2023, 12:28 PM

I am accepting but have also requested changes to reduce the scope of testing even further. I will review your other patch before the end of this week and we can include all kinds of testing in that patch.

libc/test/integration/src/pthread/pthread_join_test.cpp
30

Type names not specified by the C/C++ standard should be in UpperCase style: https://libc.llvm.org/dev/code_style.html#naming-style

72

Since we do not currently honor attrs, can you move this part to your other patch?

112

Just keep this in this patch.

This revision is now accepted and ready to land.Apr 20 2023, 12:28 PM

Pair down tests

goldstein.w.n marked 4 inline comments as done.Apr 20 2023, 12:48 PM

Use llvm style

This revision was landed with ongoing or failed builds.Apr 20 2023, 12:54 PM
This revision was automatically updated to reflect the committed changes.

@sivachandra this appears to be causing: https://lab.llvm.org/buildbot/#/builders/257/builds/630
want me to revert this and the key commit? Unable to reproduce locally so not really sure how to debug.

It is not because of your change. Accidentally, we have not been running tests on the builders for some time. I fixed it today so it started showing up regressions. I have already fixed that particular failure you have pointed out: https://reviews.llvm.org/D148844.