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

std.os.linux: use isize to more accurately reflect mmap offset semantics #22782

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

garrisonhh
Copy link
Contributor

Resolves #22464.

@@ -916,7 +916,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, of
prot,
@as(u32, @bitCast(flags)),
@bitCast(@as(isize, fd)),
@as(u64, @bitCast(offset)),
@truncate(@as(u64, @bitCast(offset))),
Copy link
Member

Choose a reason for hiding this comment

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

seems obviously wrong? you're going to truncate the offset and now it becomes an incorrect value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point on a second glance!

@alexrp alexrp self-requested a review February 9, 2025 08:10
@garrisonhh garrisonhh changed the title std.os.linux: truncate mmap offset in all cases std.os.linux: use isize to more accurately reflect offset semantics Feb 9, 2025
@garrisonhh garrisonhh changed the title std.os.linux: use isize to more accurately reflect offset semantics std.os.linux: use isize to more accurately reflect mmap offset semantics Feb 9, 2025
@garrisonhh garrisonhh force-pushed the mmap-offset-type-error branch from 18bf783 to b5bf482 Compare February 9, 2025 16:05
Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

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

Also wrong. On 32 bit systems file offsets are 64 bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants