facebook / facebook/hermes

Too many handles in indirect recursive invocation of stringPrototypeReplace()

Open
#976 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## Bug Description

Hermes crash when I run test.js below. The code in try...catch... will throw a rangeError: Maximum call stack size exceed. Hermes should print the exception instead of crashing.

StackTrace:
```
hermes: /home/wjm/hermes_validate/hermes/include/hermes/VM/HandleRootOwner.h:443: hermes::vm::PinnedHermesValue* hermes::vm::GCScope::newPinnedHermesValue(hermes::vm::HermesValue): Assertion `getHandleCountDbg() < handlesLimit_ && "Too many handles allocated in GCScope"' failed.
````

Hermes version: ab9110de7d37375982785ef674d86679093831cd
React Native version (if any):
OS version (if any):
Platform: x86_64

## Steps To Reproduce

Hermes should be compiled in Debug mode.
```./hermes test.js```

code example:
```
function main(){
function F0(a2, a3, a4) {
try{
if (!new.target) { throw 'must be called with new'; }
const v6 = ("kAvR").replace;
function f7() {
return v6;
}
Object.defineProperty(v6, Symbol.toPrimitive, { enumerable: true, get: f7 });
f7 >>>= v6;
}
catch(e)
{
print(e)
}
}
const v10 = new F0();
}; main();
```

## The Expected Behavior
I test the code in V8. V8 prints the stacktrace and does not crash.
```
RangeError: Maximum call stack size exceeded
at Function.f7 (:7:13)
at Function.replace ()
at Function.replace ()
at Function.replace ()
at Function.replace ()
at Function.replace ()
at Function.replace ()
at Function.replace ()
at Function.replace ()
at Function.replace ()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.