Branch: Tag:

2020-08-02

2020-08-02 12:40:38 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Runtime: Move calls of check_threads_etc() in mega_apply().

check_threads_etc() may in some circumstances execute code
that destructs the object that we are attempting to apply
a function in. Make sure to call check_threads_etc() before
we check that the object isn't destructed. Otherwise we may
be in for a surprise...

2400:    check_stack(256);    check_mark_stack(256);    + #ifdef PIKE_USE_MACHINE_CODE +  call_check_threads_etc(); + #else +  FAST_CHECK_THREADS_ON_CALL(); + #endif +     if( (p = o->prog) )    {    struct svalue *save_sp = Pike_sp - args;
2469: Inside #if defined(PROFILING)
   function->num_calls++;    function->recur_depth++;   #endif - #ifdef PIKE_USE_MACHINE_CODE -  call_check_threads_etc(); - #endif +        if( !constant )    {
2500:    new_frame->num_args = args;    new_frame->num_locals = args;    new_frame->pc = 0; - #ifndef PIKE_USE_MACHINE_CODE -  FAST_CHECK_THREADS_ON_CALL(); - #endif +     (*function->func.c_fun)(args);       /* .. and below follows what is basically a copy of the
2592:    }   #endif    +  FAST_CHECK_THREADS_ON_CALL(); +     switch(type)    {    case APPLY_STACK:
2654:    s->u.efun->name->str : "[widestring fn name]",    "");    } -  FAST_CHECK_THREADS_ON_CALL(); +     (*(s->u.efun->function))(args);    if (PIKE_FN_DONE_ENABLED()) {    /* DTrace leave probe