Skip to content

Instantiation without semicolons causes crash #167

Description

@lrettig

Calling new Class without parentheses in a function without semicolons seems to cause the compiler to crash.

Code sample: https://webassembly.studio/?f=w3e7cc0usm

Snippet:

class Foo {}

function add(x: i32, y: i32): i32 {
  var foo = new Foo
  return x + y
}

add(1, 2)

Try to build and you'll see the browser freeze. I get the same issue on the commandline:

<--- Last few GCs --->

[55172:0x102802a00]    15393 ms: Mark-sweep 1281.2 (1337.4) -> 1281.2 (1337.4) MB, 3052.1 / 0.0 ms  allocation failure GC in old space requested
[55172:0x102802a00]    18417 ms: Mark-sweep 1281.2 (1337.4) -> 1281.2 (1306.4) MB, 3024.0 / 0.0 ms  last resort
[55172:0x102802a00]    21426 ms: Mark-sweep 1281.2 (1306.4) -> 1281.2 (1306.4) MB, 3009.3 / 0.0 ms  last resort


<--- JS stacktrace --->

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

Security context: 0x3b0b503a8799 <JSObject>
    1: /* anonymous */ [/Users/user/folder/ewasm-as-multisig/node_modules/assemblyscript/dist/assemblyscript.js:~1] [pc=0x1514097510fd](this=0x2392fb4c6959 <t map = 0x2f9686c8c1d9>,e=1109,t=2,r=0x12c46ede0719 <e map = 0x2f9686c8c7b1>,n=0x3f65f4882201 <null>,i=0x3f65f4882201 <null>,a=0x3f65f4882201 <null>)
    2: /* anonymous */ [/Users/user/folder/ewasm-as-multisig/node_modules/ass...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/user/.nvm/versions/node/v8.6.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/user/.nvm/versions/node/v8.6.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/user/.nvm/versions/node/v8.6.0/bin/node]
 4: v8::internal::Factory::NewUninitializedFixedArray(int) [/Users/user/.nvm/versions/node/v8.6.0/bin/node]
 5: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacity(v8::internal::Handle<v8::internal::JSObject>, unsigned int) [/Users/user/.nvm/versions/node/v8.6.0/bin/node]
 6: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/user/.nvm/versions/node/v8.6.0/bin/node]
 7: 0x1514095846fd
sh: line 1: 55021 Abort trap: 6           npm run asbuild:untouched

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions