mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
8 years ago
4 changed files with 110 additions and 2 deletions
@ -0,0 +1,35 @@ |
|||
/* |
|||
* Error handling callstack headroom (GH-191) |
|||
* |
|||
* Check that relaxed callstack limit during error creation is still bounded |
|||
* so that an errCreate callback doing unbounded recursion is caught. The |
|||
* result is a DoubleError. |
|||
*/ |
|||
|
|||
/*--- |
|||
{ |
|||
"custom": true |
|||
} |
|||
---*/ |
|||
|
|||
/*=== |
|||
DoubleError: error in error handling |
|||
===*/ |
|||
|
|||
try { |
|||
function recurse() { |
|||
var dummy; |
|||
recurse(); |
|||
dummy = 1; |
|||
} |
|||
|
|||
Duktape.errCreate = function(e) { |
|||
recurse(); |
|||
return e; |
|||
}; |
|||
|
|||
function f() { f(); } |
|||
f(); |
|||
} catch(e) { |
|||
print(e); |
|||
} |
@ -0,0 +1,37 @@ |
|||
/* |
|||
* Errors thrown by Duktape internals during an errCreate() will work |
|||
* normally except they won't be augmented to avoid recursion. |
|||
*/ |
|||
|
|||
/*=== |
|||
errCreate: RangeError |
|||
internal error: URIError |
|||
internal error: EvalError |
|||
errThrow: RangeError |
|||
RangeError |
|||
===*/ |
|||
|
|||
try { |
|||
Duktape.errCreate = function (e) { |
|||
print('errCreate:', e.name); |
|||
try { |
|||
decodeURIComponent('%ff%ff'); |
|||
} catch (e2) { |
|||
print('internal error:', e2.name); |
|||
} |
|||
try { |
|||
throw new EvalError('user error'); // created but not augmented
|
|||
} catch (e2) { |
|||
print('internal error:', e2.name); |
|||
} |
|||
return e; |
|||
}; |
|||
Duktape.errThrow = function (e) { |
|||
print('errThrow:', e.name); |
|||
return e; |
|||
}; |
|||
|
|||
throw new RangeError('aiee'); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
@ -0,0 +1,37 @@ |
|||
/* |
|||
* Errors thrown by Duktape internals during an errThrow() will work |
|||
* normally except they won't be augmented to avoid recursion. |
|||
*/ |
|||
|
|||
/*=== |
|||
errCreate: RangeError |
|||
errThrow: RangeError |
|||
internal error: URIError |
|||
internal error: EvalError |
|||
RangeError |
|||
===*/ |
|||
|
|||
try { |
|||
Duktape.errCreate = function (e) { |
|||
print('errCreate:', e.name); |
|||
return e; |
|||
}; |
|||
Duktape.errThrow = function (e) { |
|||
print('errThrow:', e.name); |
|||
try { |
|||
decodeURIComponent('%ff%ff'); |
|||
} catch (e2) { |
|||
print('internal error:', e2.name); |
|||
} |
|||
try { |
|||
throw new EvalError('user error'); // created but not augmented
|
|||
} catch (e2) { |
|||
print('internal error:', e2.name); |
|||
} |
|||
return e; |
|||
}; |
|||
|
|||
throw new RangeError('aiee'); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
Loading…
Reference in new issue