-
Notifications
You must be signed in to change notification settings - Fork 18k
memory corruption on linux/386 with float32 arithmetic, GO386=387, buildmode pie/c-archive #41503
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
Comments
printing the same with all doing |
Thank you for this report @BenLubar. Kindly ccing some mobile folks @eliasnaur @hyangah. |
Does this problem reproduce on linux/386? |
FWIW, I failed to reproduce the error on an Android API 29 emulator, with
|
the problem does not reproduce on linux/386 |
full repro instructions:
running the resulting APK on I'm running the emulator on a Windows 10 machine as my Linux machine is headless. |
Thanks. I created an "system-images;android-29;default;x86" avd, but had no luck in reproducing the corruption. Can you try Go 1.15.2? What's your NDK version? I'm using version 21.1.6352462. |
NDK is 21.3.6528147 |
in case disassembly helps diagnose this, here's the APK generated by gomobile: https://ben.lubar.me/dump/issue41503.apk |
That's odd, your apk does reproduce the differing pointers, but I'm unable to build a version myself that does it. I tried NDK 21.3.6528147, no luck. |
I managed to reproduce the bug by setting GO386=387 like your |
I'm not sure how GO386 is being set. I can manually set it to sse2, but it's not being set to 387 in my environment variables or my wrapper script that sets up variables like |
Does the computer you build on support SSE2? Otherwise 387 is set. Line 146 in 24ff2af
Can the problem be reproduced on linux/386 with GO386=387? It is likely still good to understand what the root cause is here especially if reproducible outside android. |
The build machine has a Ryzen 5 1600, so it definitely supports SSE2. I'm using https://launchpad.net/~longsleep/+archive/ubuntu/golang-backports so the 387 might be from there. |
Note that buildmode c-archive is used for Android. That may help to reproduce on linux/386. |
Got it:
Note the different pointer values on the second line. |
To reproduce, I had to run:
Then Elias's command worked. I get a fault, not just a bad print:
That crash is happening here:
My guess is that the CX used for global variable access, set at |
Here's a simple reproducer:
Run with
It should print |
The code needs to do a FLDCW (float load control word) from a global to set to 32-bit rounding for the divide. I think we need to do some register shuffling to ensure correct compatibility of 387+pie. |
Change https://golang.org/cl/257277 mentions this issue: |
@gopherbot Please open backport issues. |
Backport issue(s) opened: #41619 (for 1.14), #41620 (for 1.15). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/Ha0xVDFyLCd
gomobile build
and then run on the android emulatorWhat did you expect to see?
The second log line should print the same pointer twice.
What did you see instead?
The text was updated successfully, but these errors were encountered: