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

Speculative fix for alignment crash in directory iterator on Windows #10628

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

We've received about 16 crash reports for an alignment issue in the directory iterator code

So let's loosen the alignment requirements here and see if it goes away

This structure must be aligned on a LONGLONG (8-byte) boundary. If a buffer contains two or more of these structures, the NextEntryOffset value in each entry, except the last, falls on an 8-byte boundary.

See also: ziglang/zig#17958

How did you verify your code works?

Copy link
Contributor

@Jarred-Sumner, your commit has failing tests :(

💪 1 failing tests Darwin AARCH64

💻 1 failing tests Darwin x64 baseline

💻 1 failing tests Darwin x64

🐧💪 2 failing tests Linux AARCH64

🐧🖥 2 failing tests Linux x64 baseline

🐧🖥 1 failing tests Linux x64

🪟💻 9 failing tests Windows x64 baseline

🪟💻 9 failing tests Windows x64

View logs

@Jarred-Sumner Jarred-Sumner requested review from a team and zackradisic and removed request for a team April 29, 2024 18:55
Copy link
Contributor

@zackradisic zackradisic left a comment

Choose a reason for hiding this comment

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

this is an insane bug

i left some ocmments

Comment on lines +285 to 286
const dir_info: FILE_DIRECTORY_INFORMATION_PTR = @ptrCast(@alignCast(&self.buf[self.index]));
if (dir_info.NextEntryOffset != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the struct is unaligned, even if we cast alignment, do we have to worry about unaligned reads? Technically that is undefined behavior right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if the expected alignment is 2 but the alignment we're seeing is 8, then it is also 2 so that should be okay

src/bun.js/node/dir_iterator.zig Show resolved Hide resolved
@Jarred-Sumner Jarred-Sumner merged commit bca4d0b into main Apr 29, 2024
12 of 20 checks passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/fix-alignment-issue branch April 29, 2024 21:07
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