Skip to content

asm2wasm crah #60

Closed
Closed

Description

@sletz

Crash with the following command :

bin/asm2wasm noise.js

for:

(i0 = 0; (((i0 | 0) < 2) | 0); i0 = (((i0 | 0) + 1) | 0)) {
HEAP32[dsp + 0 + ((i0 | 0) << 2) >> 2] = 0;

Abort trap: 6

Noise.js file content is :

/* ------------------------------------------------------------
author: "Grame"
copyright: "(c)GRAME 2009"
license: "BSD"
name: "Noise"
version: "1.1"
Code generated with Faust 2.0.a41 (http://faust.grame.fr)
------------------------------------------------------------ */

function mydspModule(global, foreign, buffer) {

'use asm';

var HEAP32 = new global.Int32Array(buffer);
var HEAPF32 = new global.Float32Array(buffer);

var imul = global.Math.imul;
var log = global.Math.log;

function fmodf(x, y) { x = +x; y = +y; return +(x % y); }
function log10f(a) { a = +a; return +(+log(a) / +log(10.)); }

function getNumInputs(dsp) {
    dsp = dsp | 0;
    return 0;
}

function getNumOutputs(dsp) {
    dsp = dsp | 0;
    return 1;
}

function classInit(dsp, samplingFreq) {
    dsp = dsp | 0;
    samplingFreq = samplingFreq | 0;

}

function instanceInit(dsp, samplingFreq) {
    dsp = dsp | 0;
    samplingFreq = samplingFreq | 0;
    var i0 = 0;
    HEAP32[dsp + 12 >> 2] = (samplingFreq | 0);
    HEAPF32[dsp + 8 >> 2] = +(0.);
    for (i0 = 0; (((i0 | 0) < 2) | 0); i0 = (((i0 | 0) + 1) | 0)) {
        HEAP32[dsp + 0 + ((i0 | 0) << 2) >> 2] = 0;

    }

}

function init(dsp, samplingFreq) {
    dsp = dsp | 0;
    samplingFreq = samplingFreq | 0;
    classInit(dsp, samplingFreq);
    instanceInit(dsp, samplingFreq);
}

function setValue(dsp, offset, value) {
    dsp = dsp | 0;
    offset = offset | 0;
    value = +value;
    HEAPF32[dsp + offset >> 2] = value;
}

function getValue(dsp, offset) {
    dsp = dsp | 0;
    offset = offset | 0;
    return +HEAPF32[dsp + offset >> 2];
}

function compute(dsp, count, inputs, outputs) {
    dsp = dsp | 0;
    count = count | 0;
    inputs = inputs | 0;
    outputs = outputs | 0;
    var output0 = 0;
    var fSlow0 = 0.;
    var i = 0;
    output0 = (HEAP32[outputs + (0 << 2) >> 2] | 0);
    fSlow0 = +(4.65661e-10 * +(+(HEAPF32[dsp + 8 >> 2])));
    for (i = 0; (((i | 0) < (count | 0)) | 0); i = (((i | 0) + 1) | 0)) {
        HEAP32[dsp + 0 + (0 << 2) >> 2] = ((12345 + (imul(1103515245, (HEAP32[dsp + 0 + (1 << 2) >> 2] | 0)) | 0)) | 0);
        HEAPF32[output0 + ((i | 0) << 2) >> 2] = +(+(+(fSlow0) * +((HEAP32[dsp + 0 + (0 << 2) >> 2] | 0))));
        HEAP32[dsp + 0 + (1 << 2) >> 2] = (HEAP32[dsp + 0 + (0 << 2) >> 2] | 0);

    }

}

return { getNumInputs : getNumInputs, getNumOutputs : getNumOutputs, classInit : classInit, instanceInit : instanceInit, init : init, setValue : setValue, getValue : getValue, compute : compute };

}

function getSizemydsp() {
return 16;
}

function getPathTablemydsp() {

var pathTable = [];
pathTable["/0x00/Volume"] = 8;
return pathTable;

}

function getJSONmydsp() {
return "{ "name": "Noise", "outputs": "1", "meta": [ { "author": "Grame" }, { "copyright": "(c)GRAME 2009" }, { "license": "BSD" }, { "name": "Noise" }, { "version": "1.1" } ], "ui": [ { "type": "vgroup", "label": "0x00", "items": [ { "type": "vslider", "label": "Volume", "address": "/0x00/Volume", "meta": [ { "style": "knob" } ], "init": "0", "min": "0", "max": "1", "step": "0.1" } ] } ] } ";
}

function metadatamydsp(m) {
m.declare("author", "Grame");
m.declare("copyright", "(c)GRAME 2009");
m.declare("license", "BSD");
m.declare("name", "Noise");
m.declare("version", "1.1");
}

Crash log is :

bt

  • thread build errors #1: tid = 0x303a, 0x00007fff83138866 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    • frame #0: 0x00007fff83138866 libsystem_kernel.dylib__pthread_kill + 10 frame #1: 0x00007fff8cdd835c libsystem_pthread.dylibpthread_kill + 92
      frame We need a proper build system #2: 0x00007fff858e3b1a libsystem_c.dylibabort + 125 frame #3: 0x000000010000f04f asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseAfterKeyword(cashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::Frag&, char_&, char const_) + 575
      frame Memory size from emcc #4: 0x000000010000e8df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElement(char*&, char const*) + 335 frame #5: 0x000000010000e481 asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElementOrStatement(char_&, char const_) + 577
      frame How to convert imported variables? #6: 0x000000010000e0df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBlock(char*&, char const*, cashew::IString, cashew::IString) + 463 frame #7: 0x0000000100012eff asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBracketedBlock(char_&) + 287
      frame Fix missing override warning. #8: 0x000000010001350a asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseFunction(char_&, char const_) + 922 frame #9: 0x000000010000e8df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElement(char_&, char const_) + 335
      frame Mysterious intermittent error #10: 0x000000010000e481 asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElementOrStatement(char_&, char const_) + 577 frame #11: 0x000000010000e0df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBlock(char_&, char const_, cashew::IString, cashew::IString) + 463
      frame fix typo in readme #12: 0x0000000100012eff asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBracketedBlock(char_&) + 287 frame #13: 0x000000010001350a asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseFunction(char*&, char const*) + 922
      frame Warning due to uninitialized value #14: 0x000000010000e8df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElement(char_&, char const_) + 335 frame #15: 0x000000010000e481 asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseElementOrStatement(char*&, char const*) + 577
      frame Spec test fail on unoptimized build #16: 0x000000010000e0df asm2wasmcashew::Parser<cashew::Ref, cashew::DotZeroValueBuilder>::parseBlock(char_&, char const_, cashew::IString, cashew::IString) + 463 frame #17: 0x000000010000485f asm2wasmmain + 463
      frame Sort the local variable order with the most frequently referenced first. #18: 0x00007fff8fcc15fd libdyld.dylib`start + 1

Activity

  1. kripken commented on Jan 4, 2016

    @kripken
    Member

    Perhaps try to escape your code with 4-backticks (`) before and after?

  2. sletz commented on Jan 4, 2016

    @sletz
    Author

    It seems that the "for loop" syntax is not handled in "parseAfterKeyword" (in parse.h file)

    for (i0 = 0; (((i0 | 0) < 2) | 0); i0 = (((i0 | 0) + 1) | 0)) {
    HEAP32[dsp + 0 + ((i0 | 0) << 2) >> 2] = 0;
    }

  3. kripken commented on Jan 4, 2016

    @kripken
    Member

    Ok, that makes sense. We have support for parsing emscripten asm.js output, which is a subset of asm.js - it never uses for loops, for example. It should be easy to add this support though, if it would be useful.

  4. sletz commented on Jan 4, 2016

    @sletz
    Author

    Well, our code backend currently generates "for loop" yes.

  5. kripken commented on Jan 4, 2016

    @kripken
    Member

    Ah, out of curiosity, what code backend is this?

  6. sletz commented on Jan 4, 2016

    @sletz
    Author

    FAUST (Functional Audio Stream) functional programming language specifically designed for real-time audio signal processing and synthesis (see http://faust.grame.fr)

  7. added a commit that references this issue on Jan 4, 2016
  8. kripken commented on Jan 4, 2016

    @kripken
    Member

    Interesting, thanks for the info.

    Ok, I just added for-loop support. I didn't test it beyond a simple testcase (see the commit), so let me know if you hit any issues

  9. sletz commented on Jan 5, 2016

    @sletz
    Author

    Working now, thanks!

  10. kripken commented on Jan 5, 2016

    @kripken
    Member

    Great, thanks for confirming.

  11. sletz commented on Jan 5, 2016

    @sletz
    Author

    Well I found later on that the following generated JS code is not parsed correctly. Any chance it could also be fixed?

    function getJSONmydsp() {
    return "{ "name": "Noise", "outputs": "1", "meta": [ { "author": "Grame" }, { "copyright": "(c)GRAME 2009" }, { "license": "BSD" }, { "name": "Noise" }, { "version": "1.1" } ], "ui": [ { "type": "vgroup", "label": "0x00", "items": [ { "type": "vslider", "label": "Volume", "address": "/0x00/Volume", "meta": [ { "style": "knob" } ], "init": "0", "min": "0", "max": "1", "step": "0.1" } ] } ] } ";
    }

  12. kripken commented on Jan 5, 2016

    @kripken
    Member

    That doesn't look like valid asm.js? It doesn't have arrays or strings.

    Btw, please use escaping (4 backticks "`") to make code easier to read.

  13. sletz commented on Jan 5, 2016

    @sletz
    Author

    OK, this is additional pure JS code that our backend adds with the asm.js module. We can live without that�

    Thanks.

    Le 5 janv. 2016 � 18:25, Alon Zakai notifications@github.com a �crit :

    That doesn't look like valid asm.js? It doesn't have arrays or strings.

    Btw, please use escaping (4 backticks "`") to make code easier to read.

    �
    Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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