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

anyhow::bail!("Maybe we should never reach this?"): what if we did reach this? #645

Closed
mortenpi opened this issue May 19, 2023 · 3 comments · Fixed by #569
Closed

anyhow::bail!("Maybe we should never reach this?"): what if we did reach this? #645

mortenpi opened this issue May 19, 2023 · 3 comments · Fixed by #569
Labels
bug Something isn't working
Milestone

Comments

@mortenpi
Copy link

mortenpi commented May 19, 2023

I have an MWE that reaches this line:

anyhow::bail!("Maybe we should never reach this?");

It involves interrupting an IO hang due to --warn-overwrite=yes. This came up in JuliaDocs/Documenter.jl#2121. To reproduce, run the following script with IOCapture 0.2.2 (0.2.3 contains JuliaDocs/IOCapture.jl#15 which removes the hang):

# julia --warn-overwrite=yes --project script.jl
using IOCapture
println("The following will hang forever... Ctrl+C now.")
c = IOCapture.capture() do
    for i in 1:1024
        eval(:(function f() 1 end))
    end
end

This must be run as a script, i.e. julia --warn-overwrite=yes --project script.jl (where julia is juliaup). I have the correct manifest here: https://gist.github.com/mortenpi/6223ef6f3c02a1b9fbfe2530a0d884e3

It should result in

$ julia --warn-overwrite=yes --project script.jl
The following will hang forever... Ctrl+C now.
^CError: Maybe we should never reach this?

This is on Linux. And it seems like the Julia version matters -- I get this with the official 1.9 binary, but not with 1.7 or 1.8. I didn't try 1.10/master.

julia> versioninfo()
Julia Version 1.9.0
Commit 8e630552924 (2023-05-07 11:25 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × 12th Gen Intel(R) Core(TM) i7-1260P
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, alderlake)
  Threads: 1 on 16 virtual cores
@davidanthoff davidanthoff added the bug Something isn't working label Jun 27, 2023
@davidanthoff
Copy link
Collaborator

@maleadt and @staticfloat any thoughts? I think you helped me (i.e. told me ;) how to implement the signal handling stuff on Linux, and this seems like a corner case we aren't handling correctly yet?

@davidanthoff davidanthoff added this to the Backlog milestone Jun 27, 2023
@staticfloat
Copy link
Sponsor Member

staticfloat commented Jun 27, 2023

Okay so it looks like what's happening here is that Julia is dying with a signal (SIGINT) and when rust tries to kill itself with that same signal it doesn't die. I believe that's because of the ctrlc handler set here. We should revert our SIGINT handler back to the default behavior before calling the raise() calls.

I wish ctrlc contained a revert_to_default(), but it doesn't look like it does: Detegr/rust-ctrlc#106

@LilithHafner
Copy link
Member

I ran into this when ctrlc ing a package compiler run

Details
x@x julia % julia --project compile.jl 
PackageCompiler: bundled libraries:
  ├── Base:
  │    ├── libLLVM.dylib - 60.192 MiB
  │    ├── libatomic.1.dylib - 108.375 KiB
  │    ├── libdSFMT.dylib - 85.438 KiB
  │    ├── libgcc_s.1.1.dylib - 169.828 KiB
  │    ├── libgfortran.5.dylib - 1.788 MiB
  │    ├── libgmp.10.dylib - 474.734 KiB
  │    ├── libgmpxx.4.dylib - 112.391 KiB
  │    ├── libgomp.1.dylib - 420.859 KiB
  │    ├── libjulia-codegen.1.9.dylib - 1.711 MiB
  │    ├── libjulia-internal.1.9.dylib - 4.132 MiB
  │    ├── libmpfr.6.dylib - 543.938 KiB
  │    ├── libopenlibm.4.0.dylib - 174.516 KiB
  │    ├── libpcre2-8.0.dylib - 758.344 KiB
  │    ├── libquadmath.0.dylib - 373.531 KiB
  │    ├── libssp.0.dylib - 87.641 KiB
  │    ├── libstdc++.6.dylib - 3.417 MiB
  │    ├── libuv.2.dylib - 359.312 KiB
  │    ├── libz.1.2.13.dylib - 171.125 KiB
  │    ├── libunwind.1.0.dylib - 108.562 KiB
  │    ├── libjulia.1.9.dylib - 222.281 KiB
  ├── Stdlibs:
  │   ├── LibCURL_jll
  │   │   ├── libcurl.4.dylib - 581.734 KiB
  │   ├── LibGit2_jll
  │   │   ├── libgit2.1.5.0.dylib - 1.199 MiB
  │   ├── LibSSH2_jll
  │   │   ├── libssh2.1.0.1.dylib - 273.797 KiB
  │   ├── MbedTLS_jll
  │   │   ├── libmbedcrypto.2.28.2.dylib - 608.562 KiB
  │   │   ├── libmbedtls.2.28.2.dylib - 308.484 KiB
  │   │   ├── libmbedx509.2.28.2.dylib - 202.234 KiB
  │   ├── OpenBLAS_jll
  │   │   ├── libopenblas64_.0.3.21.dylib - 21.465 MiB
  │   │   ├── libopenblas64_.dylib - 21.465 MiB
  │   ├── SuiteSparse_jll
  │   │   ├── libamd.2.4.6.dylib - 100.938 KiB
  │   │   ├── libbtf.1.2.6.dylib - 83.828 KiB
  │   │   ├── libcamd.2.4.6.dylib - 100.969 KiB
  │   │   ├── libccolamd.2.9.6.dylib - 117.328 KiB
  │   │   ├── libcholmod.3.0.14.dylib - 978.078 KiB
  │   │   ├── libcholmod.dylib - 978.078 KiB
  │   │   ├── libcolamd.2.9.6.dylib - 100.672 KiB
  │   │   ├── libklu.1.3.8.dylib - 250.406 KiB
  │   │   ├── libldl.2.2.6.dylib - 84.344 KiB
  │   │   ├── librbio.2.2.6.dylib - 117.922 KiB
  │   │   ├── libspqr.2.0.9.dylib - 289.922 KiB
  │   │   ├── libspqr.dylib - 289.922 KiB
  │   │   ├── libsuitesparseconfig.5.10.1.dylib - 84.312 KiB
  │   │   ├── libumfpack.5.7.9.dylib - 799.469 KiB
  │   │   ├── libumfpack.dylib - 799.469 KiB
  │   ├── libblastrampoline_jll
  │   │   ├── libblastrampoline.5.dylib - 2.297 MiB
  │   ├── nghttp2_jll
  │   │   ├── libnghttp2.14.dylib - 285.500 KiB
  Total library file size: 129.002 MiB
⠙ [00m:00s] PackageCompiler: compiling base system image (incremental=false)^C
[58518] signal (2): Interrupt: 2
in expression starting at /Users/x/.julia/dev/related_post_gen/julia/compile.jl:3
kevent at /usr/lib/system/libsystem_kernel.dylib (unknown line)
unknown function (ip: 0x0)
Allocations: 5491585 (Pool: 5487484; Big: 4101); GC: 8
ERROR: rethrow() not allowed outside a catch block
^[[A┌ Warning: temp cleanup
│   exception =
│    schedule: Task not runnable
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:35
│      [2] enq_work(t::Task)
│        @ Base ./task.jl:769
│      [3] yield
│        @ ./task.jl:882 [inlined]
│      [4] yield
│        @ ./task.jl:880 [inlined]
│      [5] Channel{Tuple{String, Vector{String}, Vector{String}}}(func::Base.Filesystem.var"#28#31"{String}, size::Int64; taskref::Nothing, spawn::Bool)
│        @ Base ./channels.jl:140
│      [6] Channel (repeats 2 times)
│        @ ./channels.jl:132 [inlined]
│      [7] #walkdir#27
│        @ ./file.jl:967 [inlined]
│      [8] walkdir
│        @ ./file.jl:928 [inlined]
│      [9] prepare_for_deletion(path::String)
│        @ Base.Filesystem ./file.jl:507
│     [10] temp_cleanup_purge(; force::Bool)
│        @ Base.Filesystem ./file.jl:542
│     [11] temp_cleanup_purge
│        @ ./file.jl:535 [inlined]
│     [12] (::Base.var"#930#931")()
│        @ Base ./initdefs.jl:354
│     [13] _atexit(exitcode::Int32)
│        @ Base ./initdefs.jl:416
└ @ Base.Filesystem file.jl:547
schedule: Task not runnable
Stacktrace:
^CError: Maybe we should never reach this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants