vm: Fix potential crash in <word> primitive if profiling is enabled
parent
1b84f179cd
commit
576e725662
|
@ -59,3 +59,8 @@ words ;
|
|||
[ ] [ [ [ ] compile-call ] profile ] unit-test
|
||||
|
||||
[ [ gensym execute ] profile ] [ T{ undefined } = ] must-fail-with
|
||||
|
||||
: crash-bug-1 ( -- x ) "hi" "bye" <word> ;
|
||||
: crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ;
|
||||
|
||||
[ ] [ [ crash-bug-2 ] profile ] unit-test
|
||||
|
|
|
@ -66,7 +66,13 @@ void factorvm::update_word_xt(cell w_)
|
|||
if(profiling_p)
|
||||
{
|
||||
if(!w->profiling)
|
||||
w->profiling = compile_profiling_stub(w.value());
|
||||
{
|
||||
/* Note: can't do w->profiling = ... since if LHS
|
||||
evaluates before RHS, since in that case if RHS does a
|
||||
GC, we will have an invalid pointer on the LHS */
|
||||
code_block *profiling = compile_profiling_stub(w.value());
|
||||
w->profiling = profiling;
|
||||
}
|
||||
|
||||
w->xt = w->profiling->xt();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue