WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Nov 20, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

Replace all uses of `ptrdiff_t slide` and `int64_t slide` with
`uint64_t`. If a JITted object is ever assigned an address in the upper
half of the address space on a platform with `sizeof(char *) = 4`, which
is quite common on 32-bit Linux, the following can happen:

In JITDebugInfoRegistry::registerJITObject, `SectionAddr -
SectionLoadAddr` is computed in uint64_t (ok), then cast to ptrdiff_t
(two's complement of the uint64_t version mod 2^32). This is apparently
implementation-defined behaviour rather than undefined.

Say SectionAddr = 0x1000UL, SectionLoadAddr = 0xe93b2000UL and size_t
pointer = 0xe93b20abU.
```
(ptrdiff_t)(SectionAddr - SectionLoadAddr)
           == (ptrdiff_t)0xffffffff16c4f000
           == 382005248
```

jl_DI_for_fptr implicitly converts the ptrdiff_t to int64_t:
```
(int64_t)382005248 == 382005248L
```

lookup_pointer adds `size_t pointer` to `int64_t slide`. Both are
converted to int64_t because it can represent every size_t:
```
(int64_t)0xe93b20abU + 382005248L == 3912966315L + 382005248L
                                  == 4294971563L
```

This is converted back to uint64_t by makeAddress, resulting in an
address other than the 0x10ab we expected:
```
(uint64_t)4294971563L == 0x1000010abUL
```

It is easier to use uint64_t everywhere we need a difference, since they
avoid the problem of losing upper bits after sign extension and avoid
weird UB from signed overflow.

Cherry-picked from #60031.

[1] https://buildkite.com/julialang/julia-master/builds/52196/steps/canvas?sid=019a9d6f-14a6-4ffc-be19-f2f835d1e719
@pull pull bot locked and limited conversation to collaborators Nov 20, 2025
@pull pull bot added the ⤵️ pull label Nov 20, 2025
@pull pull bot merged commit 9f1cc44 into MLH-Fellowship:master Nov 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant