Skip to content

Commit 1d0e67c

Browse files
committed
FIX: prevent crash when task with error is evaluated
This fix should be enhanced as now the error is not reported. It just prevents the crash. Actually there is no way how to provide result of any task back to caller implemented yet. Related to: Oldes/Rebol-issues#47
1 parent 8a63f42 commit 1d0e67c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/core/c-task.c

+13
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
*/
5959

6060
#include "sys-core.h"
61+
#include "sys-state.h"
62+
//#define INCLUDE_TASK
6163

6264
#ifdef INCLUDE_TASK
6365
/***********************************************************************
@@ -66,15 +68,26 @@
6668
/*
6769
***********************************************************************/
6870
{
71+
REBOL_STATE state;
6972
REBSER *body;
7073

7174
Debug_Str("Begin Task");
7275

7376
Init_Task();
7477
body = Clone_Block(VAL_MOD_BODY(task));
7578
OS_TASK_READY(0);
79+
80+
PUSH_STATE(state, Saved_State);
81+
if (SET_JUMP(state)) {
82+
POP_STATE(state, Saved_State);
83+
Catch_Error(DS_NEXT); // Stores error value here
84+
Debug_Str("End Task -> error!");
85+
return;
86+
}
87+
SET_STATE(state, Saved_State);
7688
Do_Blk(body, 0);
7789

90+
POP_STATE(state, Saved_State);
7891
Debug_Str("End Task");
7992
}
8093
#endif

src/core/t-object.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ static REBSER *Trim_Object(REBSER *obj)
316316
// make task! [init]
317317
if (type == REB_TASK) {
318318
// Does it include a spec?
319+
VAL_SET(value, REB_TASK);
319320
if (IS_BLOCK(VAL_BLK(arg))) {
320321
arg = VAL_BLK(arg);
321322
if (!IS_BLOCK(arg+1)) Trap_Make(REB_TASK, value);
@@ -325,7 +326,9 @@ static REBSER *Trim_Object(REBSER *obj)
325326
obj = Make_Module_Spec(0);
326327
VAL_MOD_BODY(value) = VAL_SERIES(arg);
327328
}
328-
break; // returns obj
329+
VAL_MOD_FRAME(value) = obj;
330+
DS_RET_VALUE(value);
331+
return R_RET;
329332
}
330333
}
331334

0 commit comments

Comments
 (0)