Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Fix exit_group test #1943

Merged
merged 1 commit into from Nov 23, 2020
Merged

Conversation

pwmarcz
Copy link
Contributor

@pwmarcz pwmarcz commented Nov 4, 2020

Description of the changes

This fixes #1937, but more importantly, makes sure that any thread calling exit() will cause the correct exit code to be reported.

The issue has been fixed by threads rework in #1949, this adds a test for exit() from a thread.

How to test this PR?

The exit_group test is a test for this scenario:

cd LibOS/shim/test/regression
make exit_group exit_group.manifest

# run the test:
../../../../Scripts/run-pytest -k test_401_exit_group -v

# trigger the binary manually:
./exit_group 3 100; echo $?
./pal_loader exit_group 3 100; echo $?

This change is Reviewable

yamahata
yamahata previously approved these changes Nov 4, 2020
Copy link
Contributor

@yamahata yamahata left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r1.
Reviewable status: all files reviewed, all discussions resolved, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel)

Copy link
Contributor

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @pwmarcz)

a discussion (no related file):
Today I'll submit a PR reworking threads (just waiting for #1938) which will get rid of these per thread exit codes and unfortunately remove all code introduced in this PR.
Now I know why I hit that LTP accept02 issue :)

We could merge this as temporary fix, but I'll revert all this changes anyway. What you guys think? cc @dimakuv @mkow @yamahata


Copy link
Contributor Author

@pwmarcz pwmarcz left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @dimakuv, @mkow, and @yamahata)

a discussion (no related file):

Previously, boryspoplawski (Borys Popławski) wrote…

Today I'll submit a PR reworking threads (just waiting for #1938) which will get rid of these per thread exit codes and unfortunately remove all code introduced in this PR.
Now I know why I hit that LTP accept02 issue :)

We could merge this as temporary fix, but I'll revert all this changes anyway. What you guys think? cc @dimakuv @mkow @yamahata

No problem, the change is somewhat hacky anyway, but you can still use the test :)


Copy link
Contributor

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @dimakuv, @mkow, and @yamahata)

a discussion (no related file):

Previously, pwmarcz (Paweł Marczewski) wrote…

No problem, the change is somewhat hacky anyway, but you can still use the test :)

Yeah, we will definitely keep the reworked test, the question is when do we merge it. I expect threads rework merge to be lengthy process, as the PR will be quite big.


Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @dimakuv and @yamahata)

a discussion (no related file):

Previously, boryspoplawski (Borys Popławski) wrote…

Yeah, we will definitely keep the reworked test, the question is when do we merge it. I expect threads rework merge to be lengthy process, as the PR will be quite big.

@boryspoplawski Your call, I'm fine with both options. But if we decide to merge it, then I'd do it before submitting your changes, because they will conflict.


Copy link
Contributor

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @dimakuv and @yamahata)

a discussion (no related file):

Previously, mkow (Michał Kowalczyk) wrote…

@boryspoplawski Your call, I'm fine with both options. But if we decide to merge it, then I'd do it before submitting your changes, because they will conflict.

Given that it would be me, who needs to resolve the conflicts and that this is not a fatal issue, I would wait and merge just the test after threads PR :)


Copy link
Contributor

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 8 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @yamahata)

a discussion (no related file):

Previously, boryspoplawski (Borys Popławski) wrote…

Given that it would be me, who needs to resolve the conflicts and that this is not a fatal issue, I would wait and merge just the test after threads PR :)

What about we drop the second commit from this PR (bar that skip of the accept02 LTP test)? And mark it as blocked until we merge Borys's PR (This PR must be rebased on top of ...).


Copy link
Contributor

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @yamahata)

a discussion (no related file):

Previously, dimakuv (Dmitrii Kuvaiskii) wrote…

What about we drop the second commit from this PR (bar that skip of the accept02 LTP test)? And mark it as blocked until we merge Borys's PR (This PR must be rebased on top of ...).

I guess we can live without this test (old version) in the meantime, so I'm ok with this


Copy link
Contributor

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (1 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @yamahata)

a discussion (no related file):

Previously, boryspoplawski (Borys Popławski) wrote…

I guess we can live without this test (old version) in the meantime, so I'm ok with this

Threads PR was merged, this can be updated (just the test will remain, I guess?)


@pwmarcz pwmarcz changed the title Fix incorrect thread exit code Fix exit_group test Nov 20, 2020
Copy link
Contributor Author

@pwmarcz pwmarcz left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ) (waiting on @dimakuv and @yamahata)

a discussion (no related file):

Previously, boryspoplawski (Borys Popławski) wrote…

Threads PR was merged, this can be updated (just the test will remain, I guess?)

Done. I rebased the code on newest master and left only the test.


Copy link
Contributor

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 8 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ) (waiting on @yamahata)

a discussion (no related file):

In addition, propagate the exit code from a forked process. That use case is actually broken and will be fixed in next commit.

I believe this para in the commit message should be removed (in the final rebase).


Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ) (waiting on @pwmarcz and @yamahata)


LibOS/shim/test/regression/exit_group.c, line 53 at r2 (raw file):

    pid_t pid = fork();
    if (fork < 0) {

Ouch. Are you testing here a function pointer for being negative? :P
Really weird that this didn't produce a warning...

Copy link
Contributor Author

@pwmarcz pwmarcz left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), "fixup! " found in commit messages' one-liners (waiting on @dimakuv, @mkow, and @yamahata)


LibOS/shim/test/regression/exit_group.c, line 53 at r2 (raw file):

Previously, mkow (Michał Kowalczyk) wrote…

Ouch. Are you testing here a function pointer for being negative? :P
Really weird that this didn't produce a warning...

Wow :) Yeah, crazy that this compiled without warnings. Fixed.

mkow
mkow previously approved these changes Nov 20, 2020
Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (1 more required), not enough approvals from different teams (1 more required, approved so far: ITL), "fixup! " found in commit messages' one-liners (waiting on @yamahata)

The exit code of the test was a random number between 0 and 4,
which gave no guarantee that the right code from exit() will
actually reach the user.

Instead of testing a race between threads, make it possible to
call exit() in a chosen thread, and verify that it always works.

In addition, propagate the exit code from a forked process. That
use case was broken recently and has been fixed in the commit
titled 'Rework threads implementation'.
Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (1 more required), not enough approvals from different teams (1 more required, approved so far: ITL) (waiting on @yamahata)

Copy link
Contributor

@dimakuv dimakuv left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @yamahata)

Copy link
Contributor

@yamahata yamahata left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 8 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @yamahata)

Copy link
Contributor

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 8 files at r2, 1 of 1 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@mkow mkow merged commit 6c8321b into gramineproject:master Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LTP] accept02 from LTP fails, but is not reported
5 participants