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

cmd/compile: wasm: LinkError: "data segment does not fit in memory" #34395

Closed
Splizard opened this issue Sep 19, 2019 · 8 comments
Closed

cmd/compile: wasm: LinkError: "data segment does not fit in memory" #34395

Splizard opened this issue Sep 19, 2019 · 8 comments

Comments

@Splizard
Copy link

@Splizard Splizard commented Sep 19, 2019

There is a regression from 1.12 to 1.13, a program that successfully compiles and runs on Firefox and Google Chrome in Go 1.12 will not run when compiled with Go 1.13

Firefox gives the error:

LinkError: "data segment does not fit in memory"

Google Chrome gives the error:

LinkError: WebAssembly.instantiate(): data segment is out of bounds

The project is quite large and the Web Assembly file is ~50mb when uncompressed.

I'm happy to provide further details on request, however, I don't have a trivial program that reproduces this.
I am using the appropriate wasm_exec files for both versions.

@agnivade
Copy link
Contributor

@agnivade agnivade commented Sep 19, 2019

Thanks @Splizard. It will be very helpful to have further details for us to debug this further.

Since it is readily reproducible for you, may I also ask you to run a git bisect and check which commit introduced this regression. I understand this is a time taking request, but if we know which commit caused this, it may give us an idea as to what went wrong.

@agnivade agnivade added this to the Go1.14 milestone Sep 19, 2019
@agnivade agnivade changed the title wasm: LinkError: "data segment does not fit in memory" cmd/compile: wasm: LinkError: "data segment does not fit in memory" Sep 19, 2019
@agnivade
Copy link
Contributor

@agnivade agnivade commented Sep 19, 2019

@neelance
Copy link
Member

@neelance neelance commented Sep 19, 2019

This is most likely due to 460f9c6. Could you please check if increasing the initialSize solves the issue?

@janpfeifer
Copy link

@janpfeifer janpfeifer commented Oct 5, 2019

Same problem here (main.wasm is 33Mb size), and my project won't run on go 1.13.

Is there a flag way to change initialSize, or does one has to recompile wasm ?

@agnivade
Copy link
Contributor

@agnivade agnivade commented Oct 5, 2019

You have to recompile the Go distribution with the new initialSize.

@janpfeifer
Copy link

@janpfeifer janpfeifer commented Oct 5, 2019

Thanks Agniva.

I tried recompiling setting it to 128Mb and it still failed. When I changed it to 1 GB it got back working.

Changing initialSize to 128Mb, cleaning and then recompiling my code worked :)

@agnivade agnivade removed the WaitingForInfo label Oct 5, 2019
@neelance
Copy link
Member

@neelance neelance commented Oct 5, 2019

Let's try to come up with a minimal example that triggers this bug. Maybe a large global array?

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 5, 2019

Change https://golang.org/cl/199358 mentions this issue: cmd/link: produce valid binaries with large data section on wasm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.