Skip to content

SnoopPrecompile segfault regression with IOCapture.jl #48837

@mortenpi

Description

I don't know if this is a SnoopPrecompile (v1.0.3) issue or a Julia one, but adding the following call to IOCapture.jl:

using SnoopPrecompile
@precompile_all_calls begin
    IOCapture.capture() do
        println("...")
    end
end

Leads to a segfault with 1.10-DEV after e06a591 (#44527 and #47407, cc @timholy @vchuravy; 328dd57 is still good; thanks to @inkydragon for bisecting!).

Full segfault stacktrace
$ julia --project -e'using Pkg; Pkg.test()'
     Testing IOCapture
      Status `/tmp/jl_xDO7rM/Project.toml`
  [b5f81e59] IOCapture v0.2.2 `~/juliadocs/clones/IOCapture.jl`
  [66db9d55] SnoopPrecompile v1.0.3
  [56ddb016] Logging `@stdlib/Logging`
  [9a3f8284] Random `@stdlib/Random`
  [8dfed614] Test `@stdlib/Test`
      Status `/tmp/jl_xDO7rM/Manifest.toml`
  [b5f81e59] IOCapture v0.2.2 `~/juliadocs/clones/IOCapture.jl`
  [21216c6a] Preferences v1.3.0
  [66db9d55] SnoopPrecompile v1.0.3
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [de0858da] Printf `@stdlib/Printf`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA v0.7.0 `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [fa267f1f] TOML v1.0.3 `@stdlib/TOML`
  [8dfed614] Test `@stdlib/Test`
  [4ec0a83e] Unicode `@stdlib/Unicode`
     Testing Running tests...
[ Info: Running IOCapture.capture

[794841] signal (11.128): Segmentation fault
in expression starting at /home/mortenpi/juliadocs/clones/IOCapture.jl/test/runtests.jl:3
ijl_subtype_env at /home/mortenpi/juliadocs/precompile/julia-bad/src/subtype.c:1867
ijl_isa at /home/mortenpi/juliadocs/precompile/julia-bad/src/subtype.c:2124
jl_tuple1_isa at /home/mortenpi/juliadocs/precompile/julia-bad/src/subtype.c:2029
jl_typemap_entry_assoc_exact at /home/mortenpi/juliadocs/precompile/julia-bad/src/typemap.c:974
jl_typemap_assoc_exact at /home/mortenpi/juliadocs/precompile/julia-bad/src/julia_internal.h:1441 [inlined]
jl_lookup_generic_ at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:2646 [inlined]
ijl_apply_generic at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:2702
sroa_pass! at ./compiler/ssair/passes.jl:967
run_passes at ./compiler/optimize.jl:558
run_passes at ./compiler/optimize.jl:573 [inlined]
optimize at ./compiler/optimize.jl:522 [inlined]
_typeinf at ./compiler/typeinfer.jl:271
typeinf at ./compiler/typeinfer.jl:215
typeinf_ext at ./compiler/typeinfer.jl:1064
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1097
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1093
jfptr_typeinf_ext_toplevel_15062 at /home/mortenpi/juliadocs/precompile/julia-bad/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/mortenpi/juliadocs/precompile/julia-bad/src/julia.h:1875 [inlined]
jl_type_infer at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:312
jl_generate_fptr_impl at /home/mortenpi/juliadocs/precompile/julia-bad/src/jitlayers.cpp:421
jl_compile_method_internal at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:2157 [inlined]
jl_compile_method_internal at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:2098
_jl_invoke at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:2516 [inlined]
ijl_apply_generic at /home/mortenpi/juliadocs/precompile/julia-bad/src/gf.c:2706
capture at /home/mortenpi/juliadocs/clones/IOCapture.jl/src/IOCapture.jl:72
unknown function (ip: 0x7fb3810fc3c2)
jl_apply at /home/mortenpi/juliadocs/precompile/julia-bad/src/julia.h:1875 [inlined]
do_call at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:126
eval_value at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:226
eval_stmt_value at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:177 [inlined]
eval_body at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:624
jl_interpret_toplevel_thunk at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:762
jl_toplevel_eval_flex at /home/mortenpi/juliadocs/precompile/julia-bad/src/toplevel.c:912
jl_toplevel_eval_flex at /home/mortenpi/juliadocs/precompile/julia-bad/src/toplevel.c:856
ijl_toplevel_eval_in at /home/mortenpi/juliadocs/precompile/julia-bad/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
include_string at ./loading.jl:1522
_include at ./loading.jl:1582
include at ./client.jl:478
unknown function (ip: 0x7fb3810fb082)
jl_apply at /home/mortenpi/juliadocs/precompile/julia-bad/src/julia.h:1875 [inlined]
do_call at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:126
eval_value at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:226
eval_stmt_value at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:177 [inlined]
eval_body at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:624
jl_interpret_toplevel_thunk at /home/mortenpi/juliadocs/precompile/julia-bad/src/interpreter.c:762
jl_toplevel_eval_flex at /home/mortenpi/juliadocs/precompile/julia-bad/src/toplevel.c:912
jl_toplevel_eval_flex at /home/mortenpi/juliadocs/precompile/julia-bad/src/toplevel.c:856
ijl_toplevel_eval_in at /home/mortenpi/juliadocs/precompile/julia-bad/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
exec_options at ./client.jl:280
_start at ./client.jl:522
jfptr__start_33934 at /home/mortenpi/juliadocs/precompile/julia-bad/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/mortenpi/juliadocs/precompile/julia-bad/src/julia.h:1875 [inlined]
true_main at /home/mortenpi/juliadocs/precompile/julia-bad/src/jlapi.c:573
jl_repl_entrypoint at /home/mortenpi/juliadocs/precompile/julia-bad/src/jlapi.c:717
main at /home/mortenpi/juliadocs/precompile/julia-bad/cli/loader_exe.c:58
unknown function (ip: 0x7fb38da29d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/mortenpi/juliadocs/precompile/julia-bad/usr/bin/julia (unknown line)
Allocations: 2976 (Pool: 2963; Big: 13); GC: 0
ERROR: Package IOCapture errored during testing (received signal: 11)
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/Types.jl:68
 [2] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
   @ Pkg.Operations ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1878
 [3] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, test_fn::Nothing, julia_args::Cmd, test_args::Cmd, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
   @ Pkg.API ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:435
 [4] kwcall(::NamedTuple{(:io,), Tuple{Base.TTY}}, ::typeof(Pkg.API.test), ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})
   @ Pkg.API ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:414
 [5] test(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:156
 [6] test(pkgs::Vector{Pkg.Types.PackageSpec})
   @ Pkg.API ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:145
 [7] test(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:171
 [8] test()
   @ Pkg.API ~/juliadocs/precompile/julia-bad/usr/share/julia/stdlib/v1.10/Pkg/src/API.jl:162
 [9] top-level scope
   @ none:1

It can be reproduced by running a simple snippet in the test environment (I can't replicate it in the normal environment..).

IOCapture.capture() do
    println("println")
end

I have pushed a branch with an MWE and doing julia --project -e'using Pkg; Pkg.test()' with Julia master should reproduce it.

While the error is different, I think it's related to our precompile woes in Documenter where a SnoopPrecompile leads to a strange error after e06a591 that also traces back to IOCapture usage: JuliaDocs/Documenter.jl#2004

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions