Skip to content
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

Use read_all/pread_all where we expect full buffer to be read #12

Open
wants to merge 2 commits into
base: crac
Choose a base branch
from

Conversation

rvansa
Copy link
Member

@rvansa rvansa commented Oct 6, 2023

I've found that some GHA's in OpenJDK/crac are failing due to this error, and I think I've seen that even locally (on ia32) though rarely:

(00.040592) Error (criu/pagemap-cache.c:158): pagemap-cache: Can't read 9142's pagemap file: No such file or directory
(00.040595) Error (criu/pagemap-cache.c:173): pagemap-cache: Failed to fill cache for 9142 (ffe3b000-ffe3c000)
(00.040617) page-pipe: Killing page pipe
(00.040798) ----------------------------------------
(00.040804) Error (criu/mem.c:625): Can't dump page with parasite

Turns out that some parts of code use read(...) or pread(...) without handling that the call returns less bytes than the full size of the buffer; I've replaced those places where the expectation is obvious (error message if the returned value does not match buffer size) with read_all and new pread_all utility function.

@rvansa
Copy link
Member Author

rvansa commented Oct 6, 2023

@wkia Please review.

Comment on lines +1701 to +1702
if (errno == EAGAIN || errno == EWOULDBLOCK)
errno = EINVAL;
Copy link
Member

Choose a reason for hiding this comment

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

This disturbs me, impact is not clear. Later we can process the code. Let's keep errno intact?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually a copy-paste of the read_all method above (just read -> pread). I don't see a problem in writing to errno?

Copy link
Contributor

Choose a reason for hiding this comment

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

@AntonKozlov
I agree with @rvansa - we could keep this consistent with other existing functions.
BTW I'd prefer using curly braces for one-line if's, but just a note.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep the @rvansa code. It is a copy-paste of read_all - while I would prefer its removal it would be a needless fork from upstream CRIU and it is not really required. If something then it could be rather an upstream CRIU contribution.
@wkia: CRIU does not use curly braces for one-line ifs: https://github.com/CRaC/criu/blob/crac/CONTRIBUTING.md#edit-the-source-code

@wkia
Copy link
Contributor

wkia commented Oct 19, 2023

@rvansa Sorry, missed this PR.

LGTM

criu/ipc_ns.c Outdated Show resolved Hide resolved
@jankratochvil
Copy link
Contributor

LGTM now.

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.

4 participants