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

[wasm64] Fix wasm64 memory read in Fetch.js #21246

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
function saveResponseAndStatus() {
var ptr = 0;
var ptrLen = 0;
if (xhr.response && fetchAttrLoadToMemory && HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.data }}} >> 2] === 0) {
if (xhr.response && fetchAttrLoadToMemory && {{{ makeGetValue('fetch', C_STRUCTS.emscripten_fetch_t.data, '*') }}} === 0) {
ptrLen = xhr.response.byteLength;
}
if (ptrLen > 0) {
Expand Down
4 changes: 2 additions & 2 deletions test/fetch/test_fetch_sync_xhr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ int result = -1;
int main() {
// If an exception is thrown from the user callback, it bubbles up to
// self.onerror but is otherwise completely swallowed by xhr.send.
EM_ASM({self.onerror = function() {
out('Got error');
EM_ASM({self.onerror = (e) => {
out('Got error', e);
HEAP32[$0 >> 2] = 2;
};}, &result);
emscripten_fetch_attr_t attr;
Expand Down
10 changes: 10 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5908,6 +5908,16 @@ def setUp(self):
self.require_wasm64()


class browser64_2gb(browser):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.set_setting('INITIAL_MEMORY', '2200gb')
self.set_setting('GLOBAL_BASE', '2gb')
self.emcc_args.append('-Wno-experimental')
self.require_wasm64()


class browser_2gb(browser):
def setUp(self):
super().setUp()
Expand Down
Loading