Brotli decompressor doesn't work on Visual C++ 2017 compiled with full optimizations #241

Closed
opened 2026-01-29 20:40:33 +00:00 by claunia · 5 comments
Owner

Originally created by @jhudsoncedaron on GitHub (Jun 15, 2018).

I extracted the decoder (by copying whole files), wrapped the stuff into a .dll, and built it with Visual C++ 2017 targeting x64. The decoder doesn't copy anything into its output file if the .dll is compiled with full optimization, but works just fine if I disable optimization.

I don't even know how to begin tracking this down. It could easily be a bug in brotli (which I would be much more certain of if this were gcc) or in Visual Studio. I could bisect which compiler optimization option causes this but I really don't think that's going to help.

Current git hash of brotli is 09cd3e877f

Originally created by @jhudsoncedaron on GitHub (Jun 15, 2018). I extracted the decoder (by copying whole files), wrapped the stuff into a .dll, and built it with Visual C++ 2017 targeting x64. The decoder doesn't copy anything into its output file if the .dll is compiled with full optimization, but works just fine if I disable optimization. I don't even know how to begin tracking this down. It could easily be a bug in brotli (which I would be much more certain of if this were gcc) or in Visual Studio. I could bisect which compiler optimization option causes this but I really don't think that's going to help. Current git hash of brotli is 09cd3e877f583e6352be146ab22415298366c8d6
Author
Owner

@eustas commented on GitHub (Jun 15, 2018):

Going to try to reproduce next week.

@eustas commented on GitHub (Jun 15, 2018): Going to try to reproduce next week.
Author
Owner

@eustas commented on GitHub (Jun 18, 2018):

Going to add VS2017 x64 debug and release builds to Appveyor matrix soon to see if it works.

@eustas commented on GitHub (Jun 18, 2018): Going to add VS2017 x64 debug and release builds to Appveyor matrix soon to see if it works.
Author
Owner

@eustas commented on GitHub (Jun 18, 2018):

Seems to work: build / test log

Could you try to build dlls with CMake generated project?
What optimization options are used?

@eustas commented on GitHub (Jun 18, 2018): Seems to work: [build / test log](https://ci.appveyor.com/project/szabadka/brotli/build/1.0.0%231280/job/7m1r2s0d1q9uy320) Could you try to build dlls with CMake generated project? What optimization options are used?
Author
Owner

@jhudsoncedaron commented on GitHub (Jun 18, 2018):

I have bisected the triggering compiler option. The one that breaks it is /NODEFUALTLIB. This makes trying the CMake project pointless.

Turning off optimizations makes it go away, but turning on optimizations and still linking against MSVC*.dll results in a working binary as well. The fault is occurring where the compiler tries to inline memcpy.

The current optimizations are: /O2 /Ot /GL /GS- /Gy /sdl- /NODEFAULTLIB

@jhudsoncedaron commented on GitHub (Jun 18, 2018): I have bisected the triggering compiler option. The one that breaks it is /NODEFUALTLIB. This makes trying the CMake project pointless. Turning off optimizations makes it go away, but turning on optimizations and still linking against MSVC*.dll results in a working binary as well. The fault is occurring where the compiler tries to inline memcpy. The current optimizations are: /O2 /Ot /GL /GS- /Gy /sdl- /NODEFAULTLIB
Author
Owner

@jhudsoncedaron commented on GitHub (Jun 18, 2018):

Nevermind. I messed up memcpy pretty bad. I'm shocked it worked with optimizations off.

@jhudsoncedaron commented on GitHub (Jun 18, 2018): Nevermind. I messed up memcpy pretty bad. I'm shocked it worked with optimizations off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#241