Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meriyah crashes when parsing specific js #38

Closed
xuld opened this issue Aug 26, 2019 · 3 comments
Closed

meriyah crashes when parsing specific js #38

xuld opened this issue Aug 26, 2019 · 3 comments

Comments

@xuld
Copy link

xuld commented Aug 26, 2019

var input = require("fs").readFileSync("input.js", "utf8")

require("meriyah").parse(input, {jsx: true, next: true, globalReturn: true, module: true, ranges: true,  specDeviation: true,})

(input.js is uploaded as attachment)

Output:

<--- Last few GCs --->
lo[88772:00000275497AF5E0]    77833 ms: Mark-sweep 2043.3 (2047.8) -> 2043.3 (2047.8) MB, 753.1 / 0.0 ms  (+ 0.0 ms in 4 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 990 ms) (average mu = 0.275, current mu = 0.244) allo[88772:00000275497AF5E0]    78806 ms: Mark-sweep 2045.8 (2050.3) -> 2045.8 (2050.3) MB, 729.7 / 0.0 ms  (+ 0.0 ms in 4 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 971 ms) (average mu = 0.263, current mu = 0.250) allo

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 00007FF77D41982D]
Security context: 0x02e7579ea1b9 <JSObject>
    1: parseClassElementList(aka parseClassElementList) [00000248E1AA9AC9] [D:\App\Node\node_modules\meriyah\dist\meriyah.umd.js:~5905] [pc=0000034C0520BE0A](this=0x03a9e7cc04d1 <undefined>,0x0120fc6c8d29 <Object map = 000000804BA2C009>,536882227,0x03a9e7cc04d1 <undefined>,536882227,2,0x03078ae7ffb9 <JSArray[0]>,0,0,265,9,46)
    2: parseClassBody(aka pars...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Writing Node.js report to file: report.20190826.095314.88772.0.001.json
Node.js report completed
 1: 00007FF77C86AA8F napi_wrap+122063
 2: 00007FF77C812746 public: bool __cdecl v8::base::CPU::has_sse(void)const __ptr64+34470
 3: 00007FF77C813406 public: bool __cdecl v8::base::CPU::has_sse(void)const __ptr64+37734
 4: 00007FF77CFFA3DE private: void __cdecl v8::Isolate::ReportExternalAllocationLimitReached(void) __ptr64+94
 5: 00007FF77CFE272A public: class v8::SharedArrayBuffer::Contents __cdecl v8::SharedArrayBuffer::Externalize(void) __ptr64+842
 6: 00007FF77CE73E3C public: static void __cdecl v8::internal::Heap::EphemeronKeyWriteBarrierFromCode(unsigned __int64,unsigned __int64,class v8::internal::Isolate * __ptr64)+1436
 7: 00007FF77CE7BD5F public: unsigned __int64 __cdecl v8::internal::Heap::OldGenerationSizeOfObjects(void) __ptr64+4879
 8: 00007FF77CE72003 public: bool __cdecl v8::internal::Heap::CollectGarbage(enum v8::internal::AllocationSpace,enum v8::internal::GarbageCollectionReason,enum v8::GCCallbackFlags) __ptr64+1235
 9: 00007FF77CE70894 public: void __cdecl v8::internal::Heap::AddRetainedMap(class v8::internal::Handle<class v8::internal::Map>) __ptr64+2292
10: 00007FF77CE8F375 public: class v8::internal::Handle<class v8::internal::HeapObject> __cdecl v8::internal::Factory::NewFillerObject(int,bool,enum v8::internal::AllocationType) __ptr64+53
11: 00007FF77CC455A3 public: class v8::internal::interpreter::JumpTableTargetOffsets::iterator & __ptr64 __cdecl v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=(class v8::internal::interpreter::JumpTableTargetOffsets::iterator && __ptr64) __ptr64+3427
12: 00007FF77D41982D public: virtual bool __cdecl v8::internal::SetupIsolateDelegate::SetupHeap(class v8::internal::Heap * __ptr64) __ptr64+614605
13: 0000034C0520BE0A

input.zip

@KFlash
Copy link
Contributor

KFlash commented Aug 26, 2019

@xuld I'm not sure why this happened to you. But your input.zip code is a mix of both TS and JS, and also invalid for a JS parser :) Like this line: readonly typeScriptCompilers = new Map<string, TypeScriptCompiler>()

If you try this in the online REPL you will notice it doesn't crash at all, but it throws an error on line 9:29.

Update: In fact your entire file is TypeScript, and if I remove the TypeScript syntax it passes just fine

@xuld
Copy link
Author

xuld commented Aug 26, 2019

It is indeed TypeScript, but it should report syntax error, rather than crashing

(Node v12.6)

@KFlash KFlash closed this as completed in 9834975 Aug 26, 2019
@KFlash
Copy link
Contributor

KFlash commented Aug 26, 2019

@xuld It should have been fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants