espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.75k stars 739 forks source link

ASSERT(size==0) FAILED AT src/jsvar.c:326 ASSERT(ref <= jsVarsSize) FAILED AT src/jsvar.c:223 #2366

Closed Limesss closed 1 year ago

Limesss commented 1 year ago

Reproduce: make Debug=1

POC:

load("./standalone-pre.js", "caller relative");

"use strict";

var typedArrays = ["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"];

function forEachTypedArray(constructors, testFunction, name, args) {
    for (let i = 0; i < constructors.length; ++i) {
        let typedArray = constructors[i];

        let result;
        if (name !== "")
            result = eval(typedArray + "." + name + args)
        else
            result = eval("new " + typedArray + args)

        let testResult = testFunction(result, typedArray)
        if (testResult !== true)
            return testResult;
    }

    return true;
}

function hasSameValues(msg, array1, array2) {
    if (array1.length !== array2.length) {
        debug(msg +  "The arrays had differing lengths, first array: " + array1 + " length: " + array1.length + " second array: " + array2 + " length" + array2.length);
        return false;
    }

    let allSame = true;
    for (let i = 0; i < array1.length; ++i) {
        allSame = allSame && Object.is(array1[i], array2[i]);
    }

    if (!allSame)
        debug(msg +  "The array did not have all the expected elements, first array: " + array1 + " second array: " + array2);
    return allSame;

}

function testConstructorFunction(name, args, expected) {
    function foo(array, constructor) {
        if (!hasSameValues(constructor + "." + name + " did not produce the correct result on " + name + args, array, expected))
            return false
        return true;
    }

    return forEachTypedArray(typedArrays, foo, name, args);
}

function testConstructor(args, expected) {
    function foo(array, constructor) {
        if (!hasSameValues(constructor + args + " did not produce the correct result", array, expected))
            return false
        return true;
    }

    return forEachTypedArray(typedArrays, foo, "", args);
}

details: ASSERT(size==0) FAILED AT src/jsvar.c:326 ASSERT(ref <= jsVarsSize) FAILED AT src/jsvar.c:223

gfwilliams commented 1 year ago

Thanks for these reports, however given the volume of different reports you've submitted in just a few minutes: #2360 #2361 #2362 #2363 #2364 #2365 #2366 you've submitted, it'd be great if you could also help to contribute fixes

Could you provide any information about how you came across these issues?

Limesss commented 1 year ago

Thanks for these reports, however given the volume of different reports you've submitted in just a few minutes: #2360 #2361 #2362 #2363 #2364 #2365 #2366 you've submitted, it'd be great if you could also help to contribute fixes

Could you provide any information about how you came across these issues?

Hi ,gfwilliams,i just run the testcase from others javascript engine . and i will try my best to help

Limesss commented 1 year ago

hi ,i want to know can those bug assign cve id ?

发自我的iPhone

------------------ Original ------------------ From: Gordon Williams @.> Date: Wed,May 10,2023 8:56 PM To: espruino/Espruino @.> Cc: Lime @.>, Author @.> Subject: Re: [espruino/Espruino] ASSERT(size==0) FAILED AT src/jsvar.c:326ASSERT(ref <= jsVarsSize) FAILED AT src/jsvar.c:223 (Issue #2366)

Thanks for these reports, however given the volume of different reports you've submitted in just a few minutes: #2360 #2361 #2362 #2363 #2364 #2365 #2366 you've submitted, it'd be great if you could also help to contribute fixes

Could you provide any information about how you came across these issues?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

gfwilliams commented 1 year ago

Answered when you posted the same question in https://github.com/espruino/Espruino/issues/2360#issuecomment-1543508223