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

MethodError: no method matching active_module() (leading to world age error), on Julia 1.11 #54780

Closed
charleskawczynski opened this issue Jun 12, 2024 · 11 comments
Milestone

Comments

@charleskawczynski
Copy link
Contributor

charleskawczynski commented Jun 12, 2024

We're seeing an odd MethodError on Julia 1.11 in ClimaCore CI (here):

field2arrays Unit Tests: Error During Test at /home/runner/work/ClimaCore.jl/ClimaCore.jl/test/MatrixFields/field2arrays.jl:6
  Got exception outside of a @test
  MethodError: no method matching active_module()
  You may have intended to import Base.active_module
  The applicable method may be too new: running in world age 26680, while current world is 27104.
  
  Closest candidates are:
    active_module(::REPL.LineEditREPL) (method too new to be called from this world context.)
     @ REPL /opt/hostedtoolcache/julia/1.11.0-beta2/x64/share/julia/stdlib/v1.11/REPL/src/REPL.jl:589
    active_module() (method too new to be called from this world context.)
     @ REPL /opt/hostedtoolcache/julia/1.11.0-beta2/x64/share/julia/stdlib/v1.11/REPL/src/REPL.jl:585
    active_module(::REPL.REPLDisplay) (method too new to be called from this world context.)
     @ REPL /opt/hostedtoolcache/julia/1.11.0-beta2/x64/share/julia/stdlib/v1.11/REPL/src/REPL.jl:591
    ...
  
  Stacktrace:
    [1] #invokelatest#2
      @ ./essentials.jl:1031 [inlined]
    [2] invokelatest
      @ ./essentials.jl:1028 [inlined]
    [3] active_module
      @ ./show.jl:519 [inlined]
    [4] show_type_name(io::IOBuffer, tn::Core.TypeName)
      @ Base ./show.jl:1058
    [5] show_datatype(io::IOBuffer, x::DataType, wheres::Vector{TypeVar})
      @ Base ./show.jl:1185
    [6] show_datatype
      @ ./show.jl:1094 [inlined]
    [7] _show_type(io::IOBuffer, x::Type)
      @ Base ./show.jl:978
    [8] show(io::IOBuffer, x::Type)
      @ Base ./show.jl:970
    [9] print(io::IOBuffer, x::Type)
      @ Base ./strings/io.jl:35
   [10] print_to_string(::String, ::Vararg{Any})
      @ Base ./strings/io.jl:148
   [11] string
      @ ./strings/io.jl:189 [inlined]
   [12] #s14#16
      @ ~/work/ClimaCore.jl/ClimaCore.jl/src/DataLayouts/DataLayouts.jl:172 [inlined]
   [13] var"#s14#16"(S::Any, Name::Any, ::Any, data::Any, ::Any)
      @ ClimaCore.DataLayouts ./none:0
   [14] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
      @ Core ./boot.jl:708
   [15] getproperty
      @ ~/work/ClimaCore.jl/ClimaCore.jl/src/DataLayouts/DataLayouts.jl:182 [inlined]
   [16] coordinates_data
      @ ~/work/ClimaCore.jl/ClimaCore.jl/src/Spaces/Spaces.jl:83 [inlined]
   [17] 

This same code works on Julia 1.10.

@IanButterworth IanButterworth added this to the 1.11 milestone Jun 12, 2024
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jun 12, 2024

It looks like there was an issue with #46866, where is wrongly used invokelatest instead of using applicable to determine if a particular method was safe to call

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jun 12, 2024

Note that the thing this generated function may be doing (string-ify a Type) may be causing UB as well, since that operation accesses a significant amount of non-constant global state (to pretty-ify the result), which may trigger arbitrary UB.

@JeffBezanson
Copy link
Sponsor Member

This doesn't seem to happen now in ClimaCore --- did you work around it? Still needs to be fixed, just checking.

@charleskawczynski
Copy link
Contributor Author

I didn’t do anything specifically, no 🤷🏻‍♂️, but you’re right in that the error doesn’t seem to be showing up anymore.

@charleskawczynski
Copy link
Contributor Author

If it's helpful, I could open a pull request in ClimaCore that reverts to the last commit where we saw the error.

@JeffBezanson
Copy link
Sponsor Member

Yes that would be helpful, thanks.

@charleskawczynski
Copy link
Contributor Author

charleskawczynski commented Jul 25, 2024

Alright, I opened CliMA/ClimaCore.jl#1904, let's see what happens.

Hm, it needs some fixes due to changes in upstream packages, I'll keep pushing fixes so long they're simple, and see if we can reproduce it. I'll comment on this issue again once it's working. Out of the office tomorrow, though, so I may not get back to it until Monday.

@sethaxen
Copy link
Contributor

sethaxen commented Aug 5, 2024

I'm seeing this error as well in https://github.com/arviz-devs/PosteriorStats.jl/blob/176faa772079c1e57b35fe6c5aa2aeb965de2354/src/summarize.jl#L404-L408. An example CI log is https://github.com/arviz-devs/PosteriorStats.jl/actions/runs/10247536730/job/28346942153#step:11:496

I don't have the nightly installed, but this should reproduce the error:

using PosteriorStats, Statistics, Test
x = randn(1_000, 4, 3)
stats1 = @inferred PosteriorStats.summarize(x, mean, std, median)

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 5, 2024

While we will likely look into fixes for this in some contexts, note that calling string on a Type from inside @generated has always been in the documented list of things that are UB to appear there and permitted to do anything (including corrupt your program and data). It looks like you might just want nameof there instead (without the generated function nonsense), with a helpful error if the user passes in a custom callable object that doesn't subtype Function

@charleskawczynski
Copy link
Contributor Author

I'm seeing this error as well

Good to know, I've been struggling to get our reproducer working again since there seem to be a bunch of required changes in the way.

@JeffBezanson
Copy link
Sponsor Member

Should be fixed by #55316

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

No branches or pull requests

5 participants