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

TypeError: in typeassert, expected Union{Nothing, Base.ScopedValues.Scope} #56609

Closed
lgoettgens opened this issue Nov 19, 2024 · 3 comments · Fixed by #56612
Closed

TypeError: in typeassert, expected Union{Nothing, Base.ScopedValues.Scope} #56609

lgoettgens opened this issue Nov 19, 2024 · 3 comments · Fixed by #56612
Milestone

Comments

@lgoettgens
Copy link
Contributor

Since yesterday we see the following error in our nightly CI (see thofma/Hecke.jl#1687), and something similar locally

TypeError: in typeassert, expected Union{Nothing, Base.ScopedValues.Scope}, got a value of type ZZRingElem
  Stacktrace:
    [1] get
      @ ./scopedvalues.jl:152 [inlined]
    [2] _precision_with_base_2
      @ ./mpfr.jl:1041 [inlined]
    [3] BigFloat
      @ ./mpfr.jl:150 [inlined]
[...]
  TypeError: in typeassert, expected Union{Nothing, Base.ScopedValues.Scope}, got a value of type Tuple{Base.MP
FR.MPFRRoundingMode}
  Stacktrace:
    [1] get
      @ ./scopedvalues.jl:152 [inlined]
    [2] rounding_raw
      @ ./mpfr.jl:241 [inlined]
    [3] BigFloat
      @ ./mpfr.jl:369 [inlined]
[...]

From the set of changes since this appeared I assume this is due to #55907.

Originally posted by @lgoettgens in #55907 (comment)

@thofma
Copy link
Contributor

thofma commented Nov 19, 2024

Or sometimes

 Got exception outside of a @test
 TypeError: in typeassert, expected Union{Nothing, Base.ScopedValues.Scope}, got a value of type Core.Const
 Stacktrace:
   [1] setprecision(f::Nemo.var"#1023#1024"{ArbFieldElem}, ::Type{BigFloat}, prec::Int64; base::Int64)
     @ Base.MPFR ./mpfr.jl:1180
   [2] setprecision
     @ ./mpfr.jl:1179 [inlined]
   [3] round
     @ ~/.julia/packages/Nemo/0TzOv/src/HeckeMoreStuff.jl:157 [inlined]

I am sure I did not create a Core.Const somewhere myself on purpose.

@topolarity
Copy link
Member

The fix in #56612 appears to be working (Hecke.jl tests pass for me locally now), but I am quite confused how a Core.Const was making it into Core.current_scope()...

We were forgetting to restore the current scope, but we were never putting anything that's not a Base.ScopedValues.Scope into ct->scope so I'm confused how we produced the strange values in the failures above.

@topolarity
Copy link
Member

I am quite confused how a Core.Const was making it into Core.current_scope()...

I think I figured this out.

The problem is that we were using the scope value after it was dead from the point-of-view of our GC passes, which is illegal. By chance we were observing other objects that overlapped with us in memory. That made it look like non-Scope values were making it into ct->scope, but they were not.

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 a pull request may close this issue.

4 participants