Skip to content

Segfault with Unicode.normalize() compiled into sysimage #45716

Open

Description

When Unicode.normalize() is compiled into the sysimage, calling it in a new session results in a segfault.

Originally I found this by trying to use PackageCompiler.jl with JuliaSyntax.jl, but I've reduced it to only code from the Unicode stdlib and a basic userimg.jl file.

I've compiled a few days old nightly (d92acb9) with the following userimg.jl:

using Unicode

@info "Normalized \"x\"" str = Unicode.normalize("x", compose=true, stable=true,
                                chartransform=Unicode.julia_chartransform)

Running the normalize function in a new session with this sysimage results in a segfault:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-DEV.758 (2022-06-13)
 _/ |\__'_|_|_|\__'_|  |  Commit d92acb93fd7* (4 days old master)
|__/                   |

julia> Unicode.normalize("x", compose=true, stable=true, chartransform=Unicode.julia_chartransform)

signal (11): Segmentation fault
in expression starting at REPL[1]:1
typekeyvalue_hash at /home/chris/dev/julia/src/jltypes.c:1191 [inlined]
lookup_typevalue at /home/chris/dev/julia/src/jltypes.c:739
jl_inst_arg_tuple_type at /home/chris/dev/julia/src/jltypes.c:1633
arg_type_tuple at /home/chris/dev/julia/src/gf.c:1913 [inlined]
jl_lookup_generic_ at /home/chris/dev/julia/src/gf.c:2518 [inlined]
ijl_apply_generic at /home/chris/dev/julia/src/gf.c:2570
jlcapi_utf8proc_custom_func_50506 at /home/chris/dev/julia/usr/lib/julia/sys.so (unknown line)
utf8proc_decompose_custom at /home/chris/dev/julia/usr/bin/../lib/libjulia-internal.so.1 (unknown line)
utf8proc_decompose at ./strings/unicode.jl:159
jfptr_utf8proc_decompose_50505 at /home/chris/dev/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/chris/dev/julia/src/gf.c:2392 [inlined]
ijl_apply_generic at /home/chris/dev/julia/src/gf.c:2574
utf8proc_map at ./strings/unicode.jl:167
#normalize#1 at ./strings/unicode.jl:225 [inlined]
normalize##kw at ./strings/unicode.jl:187 [inlined]
#normalize#1 at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/Unicode/src/Unicode.jl:118 [inlined]
normalize##kw at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/Unicode/src/Unicode.jl:118
jfptr_normalizeYY.YY.kw_23504 at /home/chris/dev/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/chris/dev/julia/src/gf.c:2392 [inlined]
ijl_apply_generic at /home/chris/dev/julia/src/gf.c:2574
jl_apply at /home/chris/dev/julia/src/julia.h:1845 [inlined]
do_call at /home/chris/dev/julia/src/interpreter.c:126
eval_value at /home/chris/dev/julia/src/interpreter.c:215
eval_stmt_value at /home/chris/dev/julia/src/interpreter.c:166 [inlined]
eval_body at /home/chris/dev/julia/src/interpreter.c:594
jl_interpret_toplevel_thunk at /home/chris/dev/julia/src/interpreter.c:750
jl_toplevel_eval_flex at /home/chris/dev/julia/src/toplevel.c:912
jl_toplevel_eval_flex at /home/chris/dev/julia/src/toplevel.c:856
jl_toplevel_eval_flex at /home/chris/dev/julia/src/toplevel.c:856
ijl_toplevel_eval_in at /home/chris/dev/julia/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
eval_user_input at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:152
repl_backend_loop at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:248
#start_repl_backend#46 at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:233
start_repl_backend##kw at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:230 [inlined]
#run_repl#59 at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:372
run_repl at /home/chris/dev/julia/usr/share/julia/stdlib/v1.9/REPL/src/REPL.jl:357
jfptr_run_repl_51676 at /home/chris/dev/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/chris/dev/julia/src/gf.c:2392 [inlined]
ijl_apply_generic at /home/chris/dev/julia/src/gf.c:2574
#980 at ./client.jl:415
jfptr_YY.980_45290 at /home/chris/dev/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/chris/dev/julia/src/gf.c:2392 [inlined]
ijl_apply_generic at /home/chris/dev/julia/src/gf.c:2574
jl_apply at /home/chris/dev/julia/src/julia.h:1845 [inlined]
jl_f__call_latest at /home/chris/dev/julia/src/builtins.c:774
run_main_repl at ./client.jl:400
exec_options at ./client.jl:314
_start at ./client.jl:516
jfptr__start_34651 at /home/chris/dev/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/chris/dev/julia/src/gf.c:2392 [inlined]
ijl_apply_generic at /home/chris/dev/julia/src/gf.c:2574
jl_apply at /home/chris/dev/julia/src/julia.h:1845 [inlined]
true_main at /home/chris/dev/julia/src/jlapi.c:567
jl_repl_entrypoint at /home/chris/dev/julia/src/jlapi.c:711
main at jld (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at jld (unknown line)
Allocations: 2143633 (Pool: 2141783; Big: 1850); GC: 3
Segmentation fault (core dumped)

Perhaps this is related to the way that normalize() calls the C utf8 library with a @cfunction callback, which then calls back into Julia and requires a generic function dispatch on some types which may not be present? This seems to be where things go wrong in the stacktrace.

I've recorded an rr session of the crash and uploaded it here (It's the first time I've done this, so hopefully it's right. Kudos for the smooth upload workflow!)

https://s3.amazonaws.com/julialang-dumps/reports/2022-06-17T04-08-11-c42f.tar.zst

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions