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/go: incorrect compilation of a specific function results in wasm crashes in Chrome on Android #68156

kkoreilly opened this issue Jun 24, 2024 · 2 comments
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.


Copy link

kkoreilly commented Jun 24, 2024

Go version

go version go1.22.4 darwin/arm64

Output of go env in your module/workspace:

GOENV='/Users/kaioreilly/Library/Application Support/go/env'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/pw/lntpc2cn37v41ct1t0t9t9880000gn/T/go-build988797772=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Apologies for the convoluted steps for reproducing. I tried for several hours to get a more reproducible example, but I could not. Somehow there is some deleterious interaction between these various components, and removing any one of them stops the issue. This may seem like an issue to do with one of these third party libraries, but as you will see, this behavior seems to almost certainly be an issue with the compiler or Chromium itself.

I made a workspace containing local clones of the main/master branches of Cogent Core ( and goldmark ( Then, I went to Cogent Core (cd core) and installed the Cogent Core tool (go install ./cmd/core). Then, I went to the basic example in Cogent Core (cd examples/basic) and ran the program for web using core run web. core run web is a command that runs go build using GOOS=js GOARCH=wasm under the hood. Then, I went to port 8080 of my computer's local IP address (http://192.168.1.x:8080; you can run ifconfig to get yours) in Google Chrome on an Android phone (mine is a Pixel 7 Pro running Android 14 with Chrome 126.0.6478.72). I observed that everything worked as expected.

Then, I changed the following line in basic.go in examples/basic from

import ""


import (
	_ ""

Then, I repeated the core run web step from above, opened a new tab on the Android phone, and went to the same URL again. After waiting for some amount of time (no more than a minute), I observed the issue described below.

What did you see happen?

After following all of the steps above, the browser tab reliably turns from correctly rendering the app to displaying an Aw, Snap! error screen (as in Nothing is printed to the console and no further information about a specific error is given.

What did you expect to see?

I expected to see the browser tab continue to correctly render the app.

After several hours of debugging, I have determined that the cause of the issue can be narrowed down to a single function declared in goldmark: util.ReadWhile. When I change the body of this function to just be panic("ReadWhile"), not only does the issue described above cease to happen, the app does not panic. This means that we are actually not even calling this function in the first place, yet somehow its contents are causing bizarre app crashes. I tried various different variations of this function: println("ReadWhile") with a return 0, false afterward results in no crashing and no print statement, whereas the same but with fmt.Println("ReadWhile") results in crashing just like the original body of the function. Several variations on the argument and loop structure of the function have not produced any changes in the crashing behavior; you basically have to remove the entire body of the function for it to stop crashing. Changing the name to SomethingElse also does not stop the crashing. I also tried moving this ReadWhile function elsewhere, but somehow I could not replicate the crash without it being in the same place in goldmark.

The fact that the innocuous contents of a function that is never called lead the program to randomly crash without any further details suggests that this is not a coding error on the part of a third party library but rather some issue with the way that the compiler is building wasm files, or the way that Chromium on Android is handling them. Cogent Core has its own custom wasm_exec.js file, but I verified that the issue still occurs with the standard version contained in misc.

I have only been able to reproduce this issue in Chrome on Android and other Chromium browsers on Android such as Kiwi Browser. It does not occur in Firefox on Android, Safari on iOS, or Chrome on macOS, Ubuntu, or Windows.

Copy link

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@joedian joedian added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jun 25, 2024
Copy link

matloob commented Jul 2, 2024

cc @aclements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
None yet

No branches or pull requests

4 participants