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

syscall/js: RangeError Offset is outside the bounds of the DataView #40923

Closed
lianghx-319 opened this issue Aug 20, 2020 · 9 comments
Closed
Labels
arch-wasm WebAssembly issues FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@lianghx-319
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.14.4 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/user/Library/Caches/go-build"
GOENV="/Users/user/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOOS="darwin"
GOPATH="/Users/user/go"
GOROOT="/usr/local/Cellar/go/1.14.4/libexec"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/user/Code/*****/*****/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/77/tr6w8vyx32l9yslxgbgvtb540000gp/T/go-build659170482=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. exec a golang wasm
  2. load two files to wasm about 120MB each
  3. get some call back from wasm to js
  4. finally got a negative int to DateView.getUint32
    image

What did you expect to see?

I want to know how to fix it or avoid it 😭

@agnivade
Copy link
Contributor

Looks like an incorrect memory address being generated. Are you able to post a code sample that triggers this?

/cc @neelance

@agnivade agnivade changed the title runtime/wasm: RangeError Offset is outside the bounds of the DataView syscall/js: RangeError Offset is outside the bounds of the DataView Aug 20, 2020
@agnivade agnivade added arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 20, 2020
@agnivade agnivade added this to the Go1.16 milestone Aug 20, 2020
@lianghx-319
Copy link
Author

lianghx-319 commented Aug 20, 2020

Unfortunately, I can't post a code sample here. But there is another weird behavior:

  • Here has there functions code with golang build into wasm
  • After read those two big files, WebSite memory usage about 2.1 GB
  • After read those two files, this error occurs when calling function A. (memory not change very much)
  • After read those two files, this time I call function B first, no error; Then I call function A, no error either. (memory not change very much too)

Finally, If those files are small file under 20MB, this error will not occur.

@neelance
Copy link
Member

Sorry, I have no idea what is causing this. I would need to be able to reproduce it to investigate.

@agnivade agnivade modified the milestones: Go1.16, Backlog Aug 22, 2020
@lianghx-319
Copy link
Author

Sorry, I have no idea what is causing this. I would need to be able to reproduce it to investigate.

Here is a sample code, occur this error. https://github.com/lianghx-319/golang-issue-40923

Maybe deploy a online preview soon.

@aakselrod
Copy link

Hi, random passer-by here! I found this issue last week because I was getting the same error message. This week, I tried updating to Go 1.15 and rebuilding my code, and this error message seems to have gone away. I haven't attempted to track it down any further.

@F3n67u
Copy link

F3n67u commented Aug 27, 2020

Sorry, I have no idea what is causing this. I would need to be able to reproduce it to investigate.

Here is a sample code, occur this error. https://github.com/lianghx-319/golang-issue-40923

Maybe deploy a online preview soon.

Hello, @agnivade, I am colleague of lianghx-319 . Could take a look at this reproduce repo?

It seem that this bug is caused by high memory use. We have optimized memory use of golang wasm in our internal project code which reduce the whole tab memory footprint to about 1.3G with the same file, then this error message gone away.

The error we are specifically running into seems this one -
https://groups.google.com/a/chromium.org/g/chromium-dev/c/IKZvzuBP9QE
2GB memory limit per renderer (i.e. per tab)

@agnivade
Copy link
Contributor

agnivade commented Aug 27, 2020

Without looking too much into it, and just looking at the symptoms, apart from the Chrome memory limit, it might also be possible that you are hitting the limits of the wasm linear memory. Currently, wasm linear memory supports only 32 bit addresses, which limits its total size to 4GiB. So anything above that will not work (and is likely causing an overflow for a 32 bit number). I think we just need to handle this case better and throw a nice error message.

Digging into the reproducer should verify if this is indeed the case. What is the behavior in other browsers?

In any case, it might help if you could try with 1.15. That has a number of optimizations which might generally help you to reduce memory usage.

@F3n67u
Copy link

F3n67u commented Aug 28, 2020

Without looking too much into it, and just looking at the symptoms, apart from the Chrome memory limit, it might also be possible that you are hitting the limits of the wasm linear memory. Currently, wasm linear memory supports only 32 bit addresses, which limits its total size to 4GiB. So anything above that will not work (and is likely causing an overflow for a 32 bit number). I think we just need to handle this case better and throw a nice error message.

Digging into the reproducer should verify if this is indeed the case. What is the behavior in other browsers?

In any case, it might help if you could try with 1.15. That has a number of optimizations which might generally help you to reduce memory usage.

The overall memory our website use is about 2GiB, so it not likely that 32 bits addr will overflow.

@gopherbot
Copy link

Change https://golang.org/cl/261358 mentions this issue: misc/wasm: make sure sp is unsigned

@golang golang locked and limited conversation to collaborators Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants