-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Randomly occurring libpng bug in png_read_IDAT_data #21930
Comments
O, that sounds like a nasty issue. Do you have any idea what the error are? Are they related to memory layout? Or static data? Can you share the full set of link flags here in the bug? |
The errors depend on what optimisation level I try. I'll just show the libpng parts of the stack trace.. O0: completely crashes/exits:
O1+: prints an error to console, and continues without displaying images:
The link command is (I don't know if there's a more detailed one than what is just shown by make):
Last time I saw randomness in Emscripten output it was caused by a Python |
This isn't going to seem real... I'm working more on my project, and then it stopped successfully building, ever. It went from building successfully maybe 20% of the time, to seemingly never. I've tried probably like 50 times. I roll back to my last commit, and it works. Eventually I've isolated the change that seems to stop it working: I was adding a new JS library: |
Do you mean that changing just the name of the library changes the behaviour? And when you say "building successfully" I assume you mean that that program runs successfully? Or are you saying there are times when that actual build fails? If you can find the source the non-determinism that would be great. One thing to do would be to link with EMCC_DEBUG=1 and then check the checksums off all the intermediate files in |
Yeah, just changing the name of my JS library seemed to change the behaviour. I know it's possible nothing actually changed and I just got really unlucky, but it sure seemed like it never built successfully when it was called "library.js", and it went back to the normal rate when it was called "frotz-library.js". Yes, I mean that it runs successfully vs not running. It never has errors during the build. Ah, Possibly relevant things from a successful build:
From an unsuccessful build:
So it's definitely got things in a different order. |
sha256sums from a working build:
From a broken build
Looks like all the .wasms differ. If a build works, the .wasm will be identical. I haven't checked to see whether there are multiple broken .wasms, or if it always fails in the same way. |
So it looks like the issue is with the order of the native port libraries on the command line. Firstly, we should fix that so that its determinisitic. Secondly, you should probably figure out why one ordering works for you and one doesn't. Perhaps that means that perhaps some of those libraries are defining the same symbols names and racing to define them? |
I was wondering if perhaps it's the image ports, as most people would be using sdl_image? Does SDL bundle it's own version of zlib, something like that? Is there a compiler/linker option to log duplicate definitions? No, looks like it would be doing that already by default. So maybe it's excluding each other through conditional compilation? |
You could confirm by doing something like |
Thanks, I tried that and got
Looks like Freetype embeds a copy of zlib: https://github.com/emscripten-ports/FreeType/blob/master/src/gzip/inflate.c So I've found a Freetype option Oh, there's even a pull request for that! #18088 |
OK, thanks for debugging that! Sounds like have two different bugs here:
We should fix both of these. I'll take a look that (1) now. |
Awesome, thanks! For (2), you had switched to upstream Freetype (#18095), but then reverted it (#18205). It looks like the port is still not using upstream Freetype. This patch is needed: emscripten-ports/FreeType@40a760c |
In python `dict()` ordering is deterministic, but `set()` ordering is not. Annoying. This change adds a simple `OrderedSet` and uses that for managing ports. Fixes: emscripten-core#21930
In python `dict()` ordering is deterministic, but `set()` ordering is not. Annoying. This change adds a simple `OrderedSet` and uses that for managing ports. Fixes: #21930
Version of emscripten/emsdk:
I've found a randomly occurring bug. I uploaded a good build to https://curiousdannii.github.io/infocom-frotz/sfrotz.html?story=shogun, which successfully shows the title graphic. But most of the time when I build my app, I get errors in
png_read_IDAT_data
. To be clear, the randomness is at compilation time - once compiled it either always works or never does.My code is at https://github.com/curiousdannii/infocom-frotz
Run
./build.sh
to build it, orrm frotz/sfrotz.js && ./build.sh
to relink it.It actually appears that the randomness is happening at the linking stage, as simply running the linker like that is enough to switch between working and broken builds.
I was at my wit's end, even trying to rebuild libpng from source, unless I noticed that just occasionally it does work. Then I was at least a little relieved that if the compiler/linker isn't being consistent it's probably not my fault.
I'll attach two zips of the working and broken output, in case inspecting the .wasm would help.
dist-broken.zip
dist-working.zip
The text was updated successfully, but these errors were encountered: