Do not set any recursion depth limit.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-06-10 12:11:55 +02:00
parent 9aa192db69
commit 5c824ec67d
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
3 changed files with 13 additions and 47 deletions

View File

@ -959,12 +959,6 @@ PH7_PRIVATE sxi32 PH7_VmInit(
PH7_MemObjInit(&(*pVm), &pVm->aExceptionCB[0]); PH7_MemObjInit(&(*pVm), &pVm->aExceptionCB[0]);
PH7_MemObjInit(&(*pVm), &pVm->aExceptionCB[1]); PH7_MemObjInit(&(*pVm), &pVm->aExceptionCB[1]);
PH7_MemObjInit(&(*pVm), &pVm->sAssertCallback); PH7_MemObjInit(&(*pVm), &pVm->sAssertCallback);
/* Set a default recursion limit */
#if defined(__WINNT__) || defined(__UNIXES__)
pVm->nMaxDepth = 32;
#else
pVm->nMaxDepth = 16;
#endif
/* Default assertion flags */ /* Default assertion flags */
pVm->iAssertFlags = PH7_ASSERT_WARNING; /* Issue a warning for each failed assertion */ pVm->iAssertFlags = PH7_ASSERT_WARNING; /* Issue a warning for each failed assertion */
/* JSON return status */ /* JSON return status */
@ -1541,14 +1535,6 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
/* Run-Time Error report */ /* Run-Time Error report */
pVm->bErrReport = 1; pVm->bErrReport = 1;
break; break;
case PH7_VM_CONFIG_RECURSION_DEPTH: {
/* Recursion depth */
int nDepth = va_arg(ap, int);
if(nDepth > 2 && nDepth < 1024) {
pVm->nMaxDepth = nDepth;
}
break;
}
case PH7_VM_CONFIG_CREATE_SUPER: case PH7_VM_CONFIG_CREATE_SUPER:
case PH7_VM_CONFIG_CREATE_VAR: { case PH7_VM_CONFIG_CREATE_VAR: {
/* Create a new superglobal/global variable */ /* Create a new superglobal/global variable */
@ -4687,19 +4673,6 @@ static sxi32 VmByteCodeExec(
} }
} }
} }
/* Check The recursion limit */
if(pVm->nRecursionDepth > pVm->nMaxDepth) {
PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING,
"Recursion limit reached while invoking user function '%z', PH7 will set a NULL return value",
&pVmFunc->sName);
/* Pop given arguments */
if(pInstr->iP1 > 0) {
VmPopOperand(&pTos, pInstr->iP1);
}
/* Assume a null return value so that the program continue it's execution normally */
PH7_MemObjRelease(pTos);
break;
}
/* Select an appropriate function to call, if not entry point */ /* Select an appropriate function to call, if not entry point */
if(pInstr->iP2 == 0) { if(pInstr->iP2 == 0) {
pVmFunc = VmOverload(&(*pVm), pVmFunc, pArg, (int)(pTos - pArg)); pVmFunc = VmOverload(&(*pVm), pVmFunc, pArg, (int)(pTos - pArg));
@ -4957,12 +4930,8 @@ static sxi32 VmByteCodeExec(
/* Push class name */ /* Push class name */
SySetPut(&pVm->aSelf, (const void *)&pSelf); SySetPut(&pVm->aSelf, (const void *)&pSelf);
} }
/* Increment nesting level */
pVm->nRecursionDepth++;
/* Execute function body */ /* Execute function body */
rc = VmByteCodeExec(&(*pVm), (VmInstr *)SySetBasePtr(&pVmFunc->aByteCode), pFrameStack, -1, pTos, &n, FALSE); rc = VmByteCodeExec(&(*pVm), (VmInstr *)SySetBasePtr(&pVmFunc->aByteCode), pFrameStack, -1, pTos, &n, FALSE);
/* Decrement nesting level */
pVm->nRecursionDepth--;
if(pSelf) { if(pSelf) {
/* Pop class name */ /* Pop class name */
(void)SySetPop(&pVm->aSelf); (void)SySetPop(&pVm->aSelf);

View File

@ -349,20 +349,19 @@ typedef sxi64 ph7_int64;
#define PH7_VM_CONFIG_OUTPUT 1 /* TWO ARGUMENTS: int (*xConsumer)(const void *pOut,unsigned int nLen,void *pUserData),void *pUserData */ #define PH7_VM_CONFIG_OUTPUT 1 /* TWO ARGUMENTS: int (*xConsumer)(const void *pOut,unsigned int nLen,void *pUserData),void *pUserData */
#define PH7_VM_CONFIG_IMPORT_PATH 3 /* ONE ARGUMENT: const char *zIncludePath */ #define PH7_VM_CONFIG_IMPORT_PATH 3 /* ONE ARGUMENT: const char *zIncludePath */
#define PH7_VM_CONFIG_ERR_REPORT 4 /* NO ARGUMENTS: Report all run-time errors in the VM output */ #define PH7_VM_CONFIG_ERR_REPORT 4 /* NO ARGUMENTS: Report all run-time errors in the VM output */
#define PH7_VM_CONFIG_RECURSION_DEPTH 5 /* ONE ARGUMENT: int nMaxDepth */ #define PH7_VM_CONFIG_CREATE_SUPER 5 /* TWO ARGUMENTS: const char *zName,ph7_value *pValue */
#define PH7_VM_CONFIG_CREATE_SUPER 6 /* TWO ARGUMENTS: const char *zName,ph7_value *pValue */ #define PH7_VM_CONFIG_CREATE_VAR 6 /* TWO ARGUMENTS: const char *zName,ph7_value *pValue */
#define PH7_VM_CONFIG_CREATE_VAR 7 /* TWO ARGUMENTS: const char *zName,ph7_value *pValue */ #define PH7_VM_CONFIG_HTTP_REQUEST 7 /* TWO ARGUMENTS: const char *zRawRequest,int nRequestLength */
#define PH7_VM_CONFIG_HTTP_REQUEST 8 /* TWO ARGUMENTS: const char *zRawRequest,int nRequestLength */ #define PH7_VM_CONFIG_SERVER_ATTR 8 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_SERVER_ATTR 9 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_ENV_ATTR 9 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_ENV_ATTR 10 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_SESSION_ATTR 10 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_SESSION_ATTR 11 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_POST_ATTR 11 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_POST_ATTR 12 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_GET_ATTR 12 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_GET_ATTR 13 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_COOKIE_ATTR 13 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_COOKIE_ATTR 14 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_HEADER_ATTR 14 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */
#define PH7_VM_CONFIG_HEADER_ATTR 15 /* THREE ARGUMENTS: const char *zKey,const char *zValue,int nLen */ #define PH7_VM_CONFIG_IO_STREAM 15 /* ONE ARGUMENT: const ph7_io_stream *pStream */
#define PH7_VM_CONFIG_IO_STREAM 16 /* ONE ARGUMENT: const ph7_io_stream *pStream */ #define PH7_VM_CONFIG_ARGV_ENTRY 16 /* ONE ARGUMENT: const char *zValue */
#define PH7_VM_CONFIG_ARGV_ENTRY 17 /* ONE ARGUMENT: const char *zValue */ #define PH7_VM_CONFIG_EXTRACT_OUTPUT 17 /* TWO ARGUMENTS: const void **ppOut,unsigned int *pOutputLen */
#define PH7_VM_CONFIG_EXTRACT_OUTPUT 18 /* TWO ARGUMENTS: const void **ppOut,unsigned int *pOutputLen */
/* /*
* Global Library Configuration Commands. * Global Library Configuration Commands.
* *

View File

@ -1230,8 +1230,6 @@ struct ph7_vm {
void *pStderr; /* STDERR IO stream */ void *pStderr; /* STDERR IO stream */
sxbool bDebug; /* TRUE to enable debugging */ sxbool bDebug; /* TRUE to enable debugging */
sxbool bErrReport; /* TRUE to report all runtime Error/Warning/Notice/Deprecated */ sxbool bErrReport; /* TRUE to report all runtime Error/Warning/Notice/Deprecated */
int nRecursionDepth; /* Current recursion depth */
int nMaxDepth; /* Maximum allowed recursion depth */
int nExceptDepth; /* Exception depth */ int nExceptDepth; /* Exception depth */
int closure_cnt; /* Loaded closures counter */ int closure_cnt; /* Loaded closures counter */
int json_rc; /* JSON return status [refer to json_encode()/json_decode()] */ int json_rc; /* JSON return status [refer to json_encode()/json_decode()] */