-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorcompletionsTab and autocompletion in the replTab and autocompletion in the replmultithreadingBase.Threads and related functionalityBase.Threads and related functionality
Description
Typing at the REPL with ThreadSanitizer enabled will result in these warnings almost immediately. Running the REPL tests also triggers the warning:
==================
WARNING: ThreadSanitizer: data race (pid=25911)
Write of size 1 at 0xffff73d4fad8 by thread T4264:
#0 _setindex! genericmemory.jl:249 (sys.so+0x11d9900)
#1 setindex! genericmemory.jl:256 (sys.so+0x11d9900)
#2 _unsafe_write iobuffer.jl:929 (sys.so+0x11d9900)
#3 julia_unsafe_write_1839 iobuffer.jl:903 (sys.so+0x11d9900)
#4 write strings/io.jl:242 (u0gqU_TEU95.so+0x1cc6c4)
#5 edit_insert /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:1036 (u0gqU_TEU95.so+0x1cc6c4)
#6 julia_edit_insert_25325 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:990 (u0gqU_TEU95.so+0x1cc6c4)
#7 edit_insert /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:265 (u0gqU_TEU95.so+0x2c8e50)
#8 japi1_YY.191_26523 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:2626 (u0gqU_TEU95.so+0x2c8e50)
#9 jl_fptr_args /home/user/c/julia/src/gf.c:3367:12 (libjulia-internal.so.1.13+0x4dd80)
#10 _jl_invoke /home/user/c/julia/src/gf.c (libjulia-internal.so.1.13+0x5effc)
#11 ijl_apply_generic /home/user/c/julia/src/gf.c:3993:12 (libjulia-internal.so.1.13+0x5effc)
#12 jl_apply /home/user/c/julia/src/julia.h:2346:12 (libjulia-internal.so.1.13+0x78c5c)
#13 jl_f_invokelatest /home/user/c/julia/src/builtins.c:877:23 (libjulia-internal.so.1.13+0x78c5c)
#14 julia_YY.match_inputYY.YY.0_25527 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:1810 (u0gqU_TEU95.so+0x2e9a08)
#15 jfptr_YY.match_inputYY.YY.0_25528 text (u0gqU_TEU95.so+0x2e9acc)
[snip]
Previous read of size 1 at 0xffff73d4fad8 by thread T4279:
#0 getindex essentials.jl:398 (sys.so+0xcb0ea4)
#1 getindex subarray.jl:339 (sys.so+0xcb0ea4)
#2 copyto_unaliased! abstractarray.jl:1096 (sys.so+0xcb0ea4)
#3 julia_copytoNOT._50184 abstractarray.jl:1076 (sys.so+0xcb0ea4)
#4 julia_copy_57369 iobuffer.jl:312 (sys.so+0x6ce400)
#5 input_string /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:172 (u0gqU_TEU95.so+0x2c48f8)
#6 julia_YY.complete_lineYY.66_27241 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:826 (u0gqU_TEU95.so+0x2c48f8)
#7 julia_complete_line_27295 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:825 (u0gqU_TEU95.so+0x2ca0ac)
#8 jfptr_complete_line_27296 text (u0gqU_TEU95.so+0x2ca2bc)
#9 _jl_invoke /home/user/c/julia/src/gf.c (libjulia-internal.so.1.13+0x5effc)
#10 ijl_apply_generic /home/user/c/julia/src/gf.c:3993:12 (libjulia-internal.so.1.13+0x5effc)
#11 julia_YY.complete_line_namedYY.17_25586 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:401 (u0gqU_TEU95.so+0x2e7320)
#12 complete_line_named /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:400 (u0gqU_TEU95.so+0x263d78)
#13 macro expansion /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:442 (u0gqU_TEU95.so+0x263d78)
#14 macro expansion lock.jl:376 (u0gqU_TEU95.so+0x263d78)
#15 julia_YY.check_show_hintYY.YY.2_25563 /home/user/c/julia/usr/share/julia/stdlib/v1.13/REPL/src/LineEdit.jl:439 (u0gqU_TEU95.so+0x263d78)
#16 jfptr_YY.check_show_hintYY.YY.2_25564 text (u0gqU_TEU95.so+0x26502c)
[snip]
SUMMARY: ThreadSanitizer: data race genericmemory.jl:249 in _setindex!
==================
The nicest solution would be to read everything we need from the PromptState
before handing it off to the hint thread, but that would require changing the public interface of complete_line
again. Alternatively, we could add a lock for the IOBuffer
and provide a function for completion providers to call that atomically reads the input string and cursor position.
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorcompletionsTab and autocompletion in the replTab and autocompletion in the replmultithreadingBase.Threads and related functionalityBase.Threads and related functionality