Skip to content

Conversation

@rst0git
Copy link
Member

@rst0git rst0git commented Aug 16, 2025

The offset argument to mmap() was computed with a direct cast from pointer to off_t:

(off_t)addr_hint - (off_t)map_base

This causes a build failure when compiling since pointers and off_t may differ in size on some platforms. The fix in this patch is to cast both pointers to intptr_t, perform the subtraction in that type, and then cast the result back to off_t.

@rst0git rst0git requested review from avagin and mihalicyn August 16, 2025 14:53
The `offset` argument to `mmap()` was computed with a direct cast from
pointer to `off_t`:

`(off_t)addr_hint - (off_t)map_base`

This causes a build failure when compiling since pointers and `off_t`
may differ in size on some platforms.

maps12.c: In function 'mmap_pages':
maps12.c:114:50: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  114 |                    filemap ? fd : -1, filemap ? ((off_t)addr_hint - (off_t)map_base) : 0);
      |                                                  ^
maps12.c:114:69: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  114 |                    filemap ? fd : -1, filemap ? ((off_t)addr_hint - (off_t)map_base) : 0);

The fix in this patch is to cast both pointers to `intptr_t`,
perform the subtraction in that type, and then cast the result
back to `off_t`.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Copy link
Member

@mihalicyn mihalicyn left a comment

Choose a reason for hiding this comment

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

Thanks!

@mihalicyn mihalicyn merged commit 5c2f02b into checkpoint-restore:criu-dev Aug 16, 2025
32 of 42 checks passed
@rst0git rst0git deleted the maps12-fix branch August 16, 2025 16:02
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