-
Notifications
You must be signed in to change notification settings - Fork 165
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
julia: avoid access into Julia structs in Julia >= 1.6 #4086
julia: avoid access into Julia structs in Julia >= 1.6 #4086
Conversation
b6fca4f
to
51bb7c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me, given the commit messages.
This needs to be updated to reflect the changes in JuliaLang/julia#36823 |
It was previously turned off as an unintended side effect of adding `--disable-Werror` to the configure flags (as the `libuv.h` from Julia introduced some warnings)
We currently access members of various structs provided by Julia (of type jl_task_t resp. jl_tls_t). This introduces an unwanted binary dependency on the precise Julia version GAP was compiled against; i.e. because of these, a binary compiled against Julia 1.3 cannot be used with Julia 1.5 To avoid this, the Julia folks merged some new APIs: - `jl_active_task_stack` allows us to avoid access to `task->copy_stack` - `jl_get_safe_restore` and `jl_set_safe_restore` allow us to avoid direct access to `tls->safe_restore` In order to simultaneously support older and newer Julia versions, we use two tricks: - we don't link during compile time against the new APIs; instead we use `dlsym` to query at runtime if they are available, and only then call them (this introduces as small overhead at the call sites, but this is negligible) - for `task->copy_stack` this is enough as its offset has been unchanged between Julia 1.3 and Julia 1.6 - for `tls->safe_restore`, the offset *did* change once between Julia 1.4 and 1.5. Luckily, the change is the same on all 64 bit platforms: the offset shifted by 8. To adjust for that, we compare the Julia version used to compile GAP against that which runs GAP to compute a suitable offset for adjusting access to `tls->safe_restore`.
51bb7c3
to
5fa6e0b
Compare
Rebased and adapted to match the final version of @ThomasBreuer ping just FYI |
Backported to stabled-4.11 in ef2ad98 |
We currently access members of various structs provided by Julia (of type jl_task_t resp. jl_tls_t). This introduces an unwanted binary dependency on the precise Julia version GAP was compiled against; i.e. because of these, a binary compiled against Julia 1.3 cannot be used with Julia 1.5
To avoid this, the Julia folks merged some new APIs:
jl_active_task_stack
allows us to avoid access totask->copy_stack
(see Add jl_active_task_stack to gcext API JuliaLang/julia#36823)jl_get_safe_restore
andjl_set_safe_restore
allow us to avoid direct access totls->safe_restore
(see Accessors for current_task, safe_restore in TLS JuliaLang/julia#36064)In order to simultaneously support older and newer Julia versions, we use two tricks:
dlsym
to query at runtime if they are available, and only then call them (this introduces as small overhead at the call sites, but this is negligible)task->copy_stack
this is enough as its offset has been unchanged between Julia 1.3 and Julia 1.6tls->safe_restore
, the offset did change once between Julia 1.4 and 1.5. Luckily, the change is the same on all 64 bit platforms: the offset shifted by 8. To adjust for that, we compare the Julia version used to compile GAP against that which runs GAP to compute a suitable offset for adjusting access totls->safe_restore
.