hllboolfor op SEGVs
coke opened this issue · 6 comments
coke commented
21:48 < [Coke]> m: use nqp; dd nqp::hllboolfor(1,"nqp")
21:48 < camelia> rakudo-moar ec50b9618: OUTPUT: «(signal SEGV)»
21:48 < [Coke]> m: use nqp; dd nqp::hllboolfor(1,"Raku")
21:48 < camelia> rakudo-moar ec50b9618: OUTPUT: «Bool::True»
21:48 < [Coke]> m: use nqp; dd nqp::hllboolfor(1,"tcl")
21:48 < camelia> rakudo-moar ec50b9618: OUTPUT: «(signal SEGV)»
coke commented
Once this is resolved, need to add docs to ops.markdown explaining what values are expected to work for the second arg.
MasterDuke17 commented
It's actually a spesh bug. SEGVs with MVM_JIT_DISABLE=1
, but just prints an empty string with MVM_SPESH_DISABLE=1
.
dogbert17 commented
Here's some additional information:
dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-m -v
This is Rakudo version 2020.02.1-342-gec50b96 built on MoarVM version 2020.02.1-107-gab089e9
implementing Raku 6.d.
dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-m -e 'use nqp; say nqp::hllboolfor(1,"nqp")'
Segmentation fault (core dumped)
dogbert@dogbert-VirtualBox ~/repos/rakudo $ gdb ./perl6-m core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./perl6-m...done.
[New LWP 14263]
[New LWP 14264]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./perl6-m -e use nqp; say nqp::hllboolfor(1,"nqp")'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007efe7db16f9a in log_parameter (tc=0x82fd20, cid=14549, arg_idx=0, param=0x0) at src/spesh/log.c:95
95 MVMContainerSpec const *cs = STABLE(param)->container_spec;
[Current thread is 1 (Thread 0x7efe7e560700 (LWP 14263))]
(gdb) bt
#0 0x00007efe7db16f9a in log_parameter (tc=0x82fd20, cid=14549, arg_idx=0, param=0x0) at src/spesh/log.c:95
#1 0x00007efe7db17234 in MVM_spesh_log_entry (tc=0x82fd20, cid=14549, sf=0x20aca28, cs=0x7efe7e1e5500 <inv_arg_callsite>, args=0x93fb38) at src/spesh/log.c:132
#2 0x00007efe7da3bd2b in MVM_frame_invoke (tc=0x82fd20, static_frame=0x20aca28, callsite=0x7efe7e1e5500 <inv_arg_callsite>, args=0x93fb38, outer=0x7efe7c7bc988, code_ref=0x24c1990, spesh_cand=-1)
at src/core/frame.c:546
#3 0x00007efe7daaff28 in invoke_handler (tc=0x82fd20, invokee=0x24c1990, callsite=0x7efe7e1e5500 <inv_arg_callsite>, args=0x93fb38) at src/6model/reprs/MVMCode.c:10
#4 0x00007efe7da0907e in MVM_interp_run (tc=0x82fd20, initial_invoke=0x7efe7db86e78 <toplevel_initial_invoke>, invoke_data=0x90dfe8) at src/core/interp.c:1066
#5 0x00007efe7db87016 in MVM_vm_run_file (instance=0x82f210, filename=0x82f1a0 "/home/dogbert/repos/rakudo/install/share/perl6/runtime/perl6.moarvm") at src/moar.c:463
#6 0x00000000004010e1 in main (argc=<optimized out>, argv=0x7fffa7209bb8) at src/vm/moar/runner/main.c:392
(gdb) l
90 entry->param.flags |= MVM_SPESH_LOG_TYPE_FLAG_RW_CONT;
91 entry->param.arg_idx = arg_idx;
92 commit_entry(tc, sl);
93 }
94 void log_parameter(MVMThreadContext *tc, MVMint32 cid, MVMuint16 arg_idx, MVMObject *param) {
95 MVMContainerSpec const *cs = STABLE(param)->container_spec;
96 MVMROOT(tc, param, {
97 log_param_type(tc, cid, arg_idx, param, MVM_SPESH_LOG_PARAMETER,
98 cs && IS_CONCRETE(param) && cs->fetch_never_invokes
99 ? cs->can_store(tc, param)
(gdb) f 1
#1 0x00007efe7db17234 in MVM_spesh_log_entry (tc=0x82fd20, cid=14549, sf=0x20aca28, cs=0x7efe7e1e5500 <inv_arg_callsite>, args=0x93fb38) at src/spesh/log.c:132
132 log_parameter(tc, cid, arg_idx, args[arg_idx].o);
(gdb) l
127 if (!tc->spesh_log)
128 break;
129 if (cs->arg_flags[i] & MVM_CALLSITE_ARG_NAMED)
130 arg_idx++;
131 if (cs->arg_flags[i] & MVM_CALLSITE_ARG_OBJ)
132 log_parameter(tc, cid, arg_idx, args[arg_idx].o);
133 arg_idx++;
134 }
135 }
136 }
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7efe7e560700 (LWP 14263) 0x00007efe7db17234 in MVM_spesh_log_entry (tc=0x82fd20, cid=14549, sf=0x20aca28, cs=0x7efe7e1e5500 <inv_arg_callsite>, args=0x93fb38) at src/spesh/log.c:132
2 Thread 0x7efe7c716700 (LWP 14264) 0x00007efe7db9eeaa in apply_template (tc=0x8bba00, tree=0x7efe7436e630, len=103,
info=0x7efe7df58488 "nsinsi.nsl.ns..nsllnslnsi.nsl.nsl.nsl.nslnslllnsi.nsl.nsl.nsl.nsl.nsl.nsnsl.nsi.nsi.nslllnsllnsii.nslll", code=0x7efe7df540b0 <MVM_jit_expr_templates+59856>, operands=0x7efe7c714310)
at src/jit/expr.c:421
(gdb) p arg_idx
$1 = 0
(gdb) p i
$2 = 0
(gdb) p cs->arg_flags[i]
$3 = 1 '\001'
(gdb)
niner commented
I think spesh is just a victim here. My guess is that hllboolfor returns a NULL and spesh is just the first to try to dereference it
MasterDuke17 commented
What should it return for a non-valid hll? Bool::False
? VMNull
?
vrurg commented
It must throw. Bool::False
implies Raku being the first-class default which would be unjust. VMNull would require extra checks, especially at QAST/bytecode level. But since there just must not be non-existing HLL dying would be a fair response.