sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

Compile to wasm produces undefined stackAlloc [error]

Open slmyers opened this issue 8 years ago • 1 comments

Hello, I am trying to compile and run using native wasm. I updated Makefile like so:

wasm/debug: EMFLAGS= -O1 -g -s INLINING_LIMIT=10 -s RESERVED_FUNCTION_POINTERS=64 -s WASM=1
wasm/debug: js/sql-debug.js

I'm loading a module into sql-debug.js following the pattern in emscripten generated html output:

here is a gist with a few more details.

errors:

#chrome Version 57.0.2984.0 dev (64-bit)
Uncaught TypeError: Cannot read property 'apply' of undefined
    at Object.Module.stackAlloc (sql-debug.js:6069)
    at sql-debug.js:6388
    at sql-debug.js:7229
    
#firefox 54.0a1 (2017-03-06) (64-bit)
TypeError: Module.asm.stackAlloc is undefined[Learn More]

if stackAlloc is left undefined by doing this in sql-debug.js

//original 
var stackAlloc = Module["stackAlloc"] = function() { return Module["asm"]["stackAlloc"].apply(null, arguments) };

//edit 
var stackAlloc = Module["stackAlloc"] = function() { return Module["stackAlloc"].apply(null, arguments) };

then this is executed in index.html before errors are thrown when stackAlloc is called to execute SQL.

var sql = window.SQL;
 // Create a database
var db = new sql.Database();
// NOTE: You can also use new sql.Database(data) where
// data is an Uint8Array representing an SQLite database file

// Execute some sql
sqlstr = "CREATE TABLE hello (a int, b char);";
sqlstr += "INSERT INTO hello VALUES (0, 'hello');"
sqlstr += "INSERT INTO hello VALUES (1, 'world');"
db.run(sqlstr); // Run the query without returning anything

slmyers avatar Mar 07 '17 05:03 slmyers

I believe this might be fixed by #255, in that it compiles to WebAssembly, and is usable, and I haven't run into this issue. I haven't investigated this issue in depth though.

Taytay avatar Apr 26 '19 20:04 Taytay