Segmentation fault trying to create a large string on v0.6.0-dev.2486


#1

Ran into this when I tried to get one of my packages to 100% coverage, where I only support storing strings up to typemax(UInt32) size.
To test that the error is actually thrown, i tried the following:

v = String(Vector{UInt8}(2^32)) ;

which resulted in the following:

signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
gc_setmark_pool_ at /j/julia/src/gc.c:518 [inlined]
gc_setmark_pool at /j/julia/src/gc.c:544
gc_setmark at /j/julia/src/gc.c:553 [inlined]
gc_mark_obj at /j/julia/src/gc.c:1563 [inlined]
gc_push_root at /j/julia/src/gc.c:1206
gc_mark_stack at /j/julia/src/gc.c:1292
gc_scan_obj at /j/julia/src/gc.c:1477
gc_push_root at /j/julia/src/gc.c:1209
gc_mark_stack at /j/julia/src/gc.c:1303
gc_scan_obj at /j/julia/src/gc.c:1477
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1463
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_mark_module at /j/julia/src/gc.c:1242
gc_scan_obj at /j/julia/src/gc.c:1473
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1430
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1430
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1430
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_mark_module at /j/julia/src/gc.c:1242
gc_scan_obj at /j/julia/src/gc.c:1473
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_scan_obj at /j/julia/src/gc.c:1492
gc_push_root at /j/julia/src/gc.c:1209
gc_mark_module at /j/julia/src/gc.c:1242
gc_scan_obj at /j/julia/src/gc.c:1473
gc_push_root at /j/julia/src/gc.c:1209
jl_gc_mark_thread_local at /j/julia/src/gc.c:1591 [inlined]
_jl_gc_collect at /j/julia/src/gc.c:1809
jl_gc_collect at /j/julia/src/gc.c:1969
jl_gc_pool_alloc at /j/julia/src/gc.c:856
jl_gc_alloc_ at /j/julia/src/./julia_internal.h:171 [inlined]
jl_gc_alloc at /j/julia/src/gc.c:2004
jl_gc_alloc_buf at /j/julia/src/./julia_internal.h:192 [inlined]
new_binding at /j/julia/src/module.c:81 [inlined]
jl_get_binding_wr at /j/julia/src/module.c:114
eval_body at /j/julia/src/interpreter.c:542
jl_interpret_toplevel_thunk at /j/julia/src/interpreter.c:664
jl_toplevel_eval_flex at /j/julia/src/toplevel.c:592
jl_toplevel_eval_in at /j/julia/src/builtins.c:614
eval at ./boot.jl:236
jlcall_eval_18151 at /j/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /j/julia/src/gf.c:2217
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x3204dd846)
jl_apply_generic at /j/julia/src/gf.c:2217
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x3204dac2f)
jl_apply_generic at /j/julia/src/gf.c:2217
jl_apply at /j/julia/src/./julia.h:1411 [inlined]
start_task at /j/julia/src/task.c:261
Allocations: 2960907 (Pool: 2959613; Big: 1294); GC: 4
Segmentation fault: 11

This works fine in v0.5.0.


#2

Note to @stevengj: This segmentation fault also occurs when creating an IOBuffer, if n is > 2^32-10
(at least on my Mac, which has 16GB of RAM, of which about 6GB was shown by the Activity Monitor as being available)


#3

#4

Thanks! It’s working fine now, with @yuyichao’s fix, for both the String(Vector{UInt8}(2^32)) case and the related IOBuffer(2^32) case. :+1: