Skip to content

Support for Julia v1.12 #196

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Support for Julia v1.12 #196

wants to merge 3 commits into from

Conversation

mhauru
Copy link
Member

@mhauru mhauru commented Jul 31, 2025

Work in progress, though most tests now pass. Current known issues are calling varargs functions and and more allocations than on v1.11.

@mhauru mhauru force-pushed the mhauru/julia1.12 branch from 2dfd832 to 0755577 Compare July 31, 2025 10:54
Copy link

github-actions bot commented Aug 5, 2025

Libtask.jl documentation for PR #196 is available at:
https://TuringLang.github.io/Libtask.jl/previews/PR196/

@mhauru
Copy link
Member Author

mhauru commented Aug 7, 2025

The test suite now passes except for the test cases called "nested with args (dynamic)" and "nested with args (dynamic + used)", which segfault due to JuliaLang/julia#59222. Waiting on a response there to see whether that's a Julia bug or something we need to adapt to.

@yebai
Copy link
Member

yebai commented Aug 7, 2025

JuliaLang/julia#59222

These tests look slightly weird. They might be violating opaque closure assumptions, e.g. dynamic dispatch of g(xs...) depends on inputs to the opaque closure itself. Do we need them here?

@yebai
Copy link
Member

yebai commented Aug 7, 2025

This works, it doesn't answer why JuliaLang/julia#59222 fails, though.

julia> g(xs::Tuple{Vararg{T}}) where T = 1

julia> (t::Tuple{typeof(g)})(xs::Tuple{Vararg{T}}) where T = t[1](xs)

julia> ir = Base.code_ircode_by_type(Tuple{Tuple{typeof(g)}, Tuple{Vararg{Symbol}}})[1][1]

julia> ir.argtypes[1] = Tuple{typeof(g)}

julia> oc = Core.OpaqueClosure(ir, g; isva=true, do_compile=true)

julia> oc(:a, :b)  # works on 1.12 and 1.11

EDIT: I suspect that g(xs...) is type unstable, though I still don't understand why that leads to a segfault on Julia 1.12 despite working fine on Julia 1.11.

@mhauru
Copy link
Member Author

mhauru commented Aug 8, 2025

The case where this comes up is if, in a TapedTask, you have a dynamic call to a varargs function that might have a produce statement. In that case Libtask.DynamicCallable calls it with the explicit arguments known at runtime, and hence the code_ircode_by_type call sees the concrete types rather than a Vararg type. I could maybe workaround that with some hacking of ir.argtypes. However, I couldn't figure out a nice way to do it, whereas the segfault seems to me like either Julia is bugging or something has changed about OCs that I need to understand.

Your comment about the callable being in the captures is good though, because it made me realise that I don't need that to replicate the problem. This, too, segfaults:

module MWE

g(xs...) = 1

ir = Base.code_ircode_by_type(Tuple{typeof(g), Symbol, Symbol})[1][1]
ir.argtypes[1] = Tuple{}

oc = Core.OpaqueClosure(ir; isva=true, do_compile=true)
oc(:a, :b)  # segfault on 1.12

end

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