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

ASM zlib build on Windows gives erroneous results #41

Closed
weltling opened this issue Apr 24, 2013 · 9 comments
Closed

ASM zlib build on Windows gives erroneous results #41

weltling opened this issue Apr 24, 2013 · 9 comments

Comments

@weltling
Copy link

The bug happens using an ASM optimized static zlib 1.2.5 or 1.2.7 on Windows x86. Supposed is to have no output, but currently it outs "%Cë". Non ASM versions on Windows do that right, as well both ASM and non ASM builds on Linux. The bad data can be fetched from http://188.40.74.4/corrupted.gz .

Using the snippet and data from

https://gist.github.com/anonymous/2c5a88ca9ac6f4c2a064

the erroneous behavior is reproducible.

It is possible, that the same issue does exist on Darwin, but sadly I've no such OS to test. This bug is originally detected in PHP https://bugs.php.net/bug.php?id=61677 .

@rhuijben
Copy link

I found a similar issue with the ASM optimized builds on Windows x86 and x64 while debugging a Subversion issue. A test program shows quite different behavior depending on how much data is feeded into the inflate() function.

@ch3cooli
Copy link

ch3cooli commented Nov 3, 2013

Therefore, TortoiseSVN disabled using ASM 2 days ago.

ngyuki pushed a commit to ngyuki/php-src that referenced this issue Dec 4, 2013
The real issue is a bug in asm zlib build, reported here
madler/zlib#41 . Non ASM builds
behave more predictable.
@rhuijben rhuijben mentioned this issue May 28, 2014
Closed
GoogleCodeExporter pushed a commit to luanzhiye/tortoisesvn that referenced this issue Mar 24, 2015
* Patch from Sergey Azarkevich: Pass the peg revision to the revert command. (Fixes issue #584) : Revert from log dialog bottom pane fails if the file was deleted 
* Do not use assembly optimized zlib build since it's buggy: madler/zlib#41 http://svn.haxx.se/dev/archive-2013-08/0386.shtml
yuexiaoyun pushed a commit to yuexiaoyun/tortoisesvn that referenced this issue Jul 11, 2015
* Patch from Sergey Azarkevich: Pass the peg revision to the revert command. (Fixes issue #584) : Revert from log dialog bottom pane fails if the file was deleted 
* Do not use assembly optimized zlib build since it's buggy: madler/zlib#41 http://svn.haxx.se/dev/archive-2013-08/0386.shtml
@madler
Copy link
Owner

madler commented Jul 29, 2015

What assembly code is being used? There are a few in zlib's contrib directory. By the way, the stuff in the contrib directory is not part of zlib. It is just there as a convenience and is supported (or not) by those third-party contributors. What I will do is simply remove the offending code from the next distribution.

maitrihegde pushed a commit to maitrihegde/tortoisesvn that referenced this issue Sep 22, 2015
* Patch from Sergey Azarkevich: Pass the peg revision to the revert command. (Fixes issue #584) : Revert from log dialog bottom pane fails if the file was deleted 
* Do not use assembly optimized zlib build since it's buggy: madler/zlib#41 http://svn.haxx.se/dev/archive-2013-08/0386.shtml
@rhuijben
Copy link

rhuijben commented Jul 7, 2017

@madler All the 'standard' Windows project files for Visual Studio make it much to easy to enable these optimizations from the 'contrib' directory, while there are still known issues. These users just assume that because the project files are supported, all settings are too. (See also issue #274)

wzv5 added a commit to wzv5/libpck that referenced this issue Jul 7, 2017
@madler
Copy link
Owner

madler commented Oct 14, 2017

Due to bugs and other issues, the assembler code in the contrib directory has been removed.

@madler madler closed this as completed Oct 14, 2017
@weltling
Copy link
Author

To mention were also, that we stopped to use any ASM implementations in PHP back then. C versions do no issues for years already, and combined with PGO there's no impact on performance. If those ASM files aren't supported anymore, it is right' that they shouldn't show up in the distribution.

Thanks.

@pcordes
Copy link

pcordes commented Jan 11, 2018

@weltling:

and combined with PGO there's no impact on performance.

That's probably because the asm isn't tuned very well for modern x86 (http://agner.org/optimize/). I had a look at contrib/masmx64/inffas8664.asm and there are things like partial-register stalls and false dependencies, and sub-optimal sequences for doing foo &= (1<<count)-1; (e.g. bts is more efficient than a variable-count shift to create 1<<count). And using rsp as the struct pointer (not exception safe!) is a bad choice: every [rsp+const] memory operand takes an extra byte to encode vs. using any other register.

The memcpy strategy for short copies is also suspect. Using rep movsw + a branch to optionally copy one extra byte might possible work well, but for small lengths you can probably do much better with an unaligned XMM load / store which writes more than you need, as long as you aren't close to the end of the output buffer.

contrib/amd64/amd64-match.S has room for improvement, too. (And probably USE_SSE would be a win on modern CPUs, especially Skylake, where unaligned load penalties are lower. Especially with some tuning to improve efficiency).

@pcordes
Copy link

pcordes commented Jan 11, 2018

@madler: Is zlib interested in "officially" including any new asm? Or at least in an optional but easy-to-use way that some Linux distro packages might enable?

And what about runtime dispatching to use BMI1/BMI2 instructions, and/or AVX instructions? Intel CPUs run plain variable-count shifts as 3 uops (because of x86 legacy baggage with FLAGS semantics in case the count is zero), and there's a lot of bit shifting, so shlx / shrx are a nice win on their own. The other BMI instructions are also quite nice. (And lzcnt/tzcnt are significantly faster on AMD than bsr / bsf).

Compilers know how to use BMI1/BMI2 instructions when compiling ordinary C, for example foo = bar & ((1<<count) - 1 can compile to a BZHI instruction. So runtime dispatching could be orthogonal to hand-written asm, building a baseline version and a BMI2 version for a few important functions. There is some compiler support for doing this automatically (GNU C ifunc), or there are various ways to do it manually (e.g. function pointers, although with Spectre just being announced, introducing new indirect branches into a library used all over the place might be a bad idea...)

bolabola added a commit to bolabola/assimp that referenced this issue Mar 26, 2019
* Apply suggestions from code review

* make the copy constructors explicitly defaulted
* split compound assert

* Smd loads a single animation file

Can't load without mesh before

* Fix smd animation mess

aiMatrix4x4t<TReal>::FromEulerAnglesXYZ modified to row order

* Issue 1117: Smd load multiple animations

Read an animation list from a file

* Fix: Smd Cannot read bone names containing spaces

* Issue 1639: Smd mesh vertex bone assignment

bone.mOffsetMatrix not set when bone.iParent == -1

* Update SMDLoader.cpp

Fix compiler warning and do some reformattings.

* closes assimp#2228: prepare pull-request.

* Fix CMake target alias typo

* Off-Importer: introduce unittest.

* closes assimp#2247: change include folder from debian package from /usr/lib/include to /usr/include

* collada export: Use Camera local coordinate system

Fixes assimp#2255

* Use ADD_ASSIMP_IMPORTER for STEP importer

* Fix failed assimp validation for glTF2 sample animations

* Add check for NULL texcoord values.

* closes assimp#817: use emmisive factor instead of color.

* Add minimal unit-test for LWO file format

* Add unit-test for STL format auto detection

* Add formatDetection unit-test for 3DS importer

* Add silent flag to assimp cmd

Add a new command line flag to assimp cmd in order to only display minimal
info when loading a file.

This is especially useful for quick profiling/fuzzing.

* Fix animations import in gltf2

* added arm64e to iOS build script
added arm64e iOS cmake file

* added bitcode ios

* Update Info.cpp

Add a simple check to avoid verbose + silent mode together,

* Update Readme.md

Add issue solution time-tracking.

* Update Readme.md

Add codacy badge.

* Update .travis.yml

make coverity scan looking for master.

* JAssimp: fix simple code analysis issues.

* Fix next finding.

* Fix next finding.

* Review: fix wrong interpretation of methods for JNI.

* Update Jassimp.java

Fix another misinterpretation from the JNI-interface.

* python: fix review findings.

* Testing: improve test coverage:

* Update .travis.yml

revert name of branch

* Coverity-findings

* more fixes for coverity-findings.

* remove dead code.

* fix more findings.

* Add a check for the resule of a dynamic cast.

* eremove useless assertion test.

* Fix: except `SyntaxError` for py3 viewer

Following https://www.python.org/dev/peps/pep-3110/

* Fix unnecessary allocation.

* Fix memory leak.

* remove unique_ptr ina local function / method.

* fix streamreader::end definition for iterators.

* fix review findings.

* fix review findings.

* fix out-of-bound access.

* fix review warning: wrapper object used after free.

* fix review finding: Wrapper object use after free.

* fix review finding: fix resource leak.

* next try.

* fix finding: possible override.

* fix review finding: dereference after null-check.

* Correction on clipper crash on some IFC files when points are empty

* Various additions/fixes (FBX blend-shapes support added)

Added animMesh name assignment at ColladaLoader
Fixed animMesh post-processing on ConvertToLhProcess (blend-shapes weren't being affected by post-processing)
Added WindowsStore define. This is used to change some incompatible WinRT methods
Added FBX blend-shapes and blend-shapes animations support
Added Maya FBX specific texture slots parsing
Added extra FBX metadata parsing
Added GLTF2 vertex color parsing
Fixed IFC-Loader zip-buffer reading rountine
Fixed OBJ file parsing line-breaker bug
Fixed IOStreamBuffer cache over-read bug
Added mName field to aiAnimMesh
Reverted EmissiveFactor, TransparencyFactor and SpecularFactor assignment on FBXConverter. Really, the commit assimp#817 breaks a lot of old code.

* Test fixes

Test fixes

* Change access of getData() to package-private for access in JaiDebug.
Move private field to fix compile error.

* Add ProgressHandler support.

* Make this public for JaiDebug and to pass quality checks.

* Fix progress reporting in ObjFileParser. Remove old unused code which is claiming to still take up "1/3" of the total progress.

* add FBX Line Element support

add FBX Line Element support

* Update FBXConverter.cpp

* Preserve all the material parameters from FBX models

* Disable step.

* Adapt MemoryIOSystem to delegate unhandled calls to shadowed IO system

* Fill in rest of interface; switch created_stream to a unique_ptr

* Update MemoryIOWrapper.h

Fix leak.

* Update MemoryIOWrapper.h

Make code more readable.

* Update MemoryIOWrapper.h

Make code more readable.

* Closes assimp#2251: introduce AI_CONFIG_PP_FID_IGNORE_TEXTURECOORDS to avoid removing textures.

* Update README.md

Update doc.

* Update FindInvalidDataProcess.cpp

-Fix some review findings.

* Fix glTF2 export with no texture coordinates

* Update copyrights.

* Fix review findings.

* [pyassimp] Bumped to 4.1.4

Main changes:
- Support for metadata fields (Vincent Fazio, Wojciech Matyjewicz)
- added support for aiExportSceneToBlob (Vincent Fazio)
- a few bug fix + code beautification

* Some more findings.

* closes assimp#2297: introduce obj-unittest to validate working importer.

* Merged PR 2811682: buffer grow changes and large files support

Buffer grow changes:
The exporting of relatevely large data could take a few days, because reallocation of a buffer every time for a few new bytes is overkill. I've introduced standard capacity member for the buffer and growth it by 1.5 times every time. That helps a lot, descrease exporting to a minute (from a few days).

Large file support:
glTF is a json file, all lengths and offsets don't have a type, just numbers, but code was always reading it as uint32, this doesn't work for files bigger than int32 (almost all files we have as an example). So, I've changed it to be reading as size_t. Specification doesn't specify the type for it, so it's not against spec.

* warning fix for gcc

* fix openfiledialog in modelviewer.

* remove dead code

* Update Readme.md

closes assimp#2248: Add lgtm badge.

* Fix potential security issues.

* Add tokenization of 'c' type arrays, both compressed and uncompressed.

* Remove unneeded newline.

* Add two test files which require 'c' handling to be tokenized correctly.

* cast size_t to unsigned int

* Devil: replace this by header-only lib.

* Update README

- Update the readme for the exampes.

* [Issue_2340] Added ASSIMP_ANDROID_JNIIOSYSTEM precheck to only remain set to ON in proper ANDROID enabled toolchain environment

* [Issue_2340] Wrong precondition layout... missed ANDROID=ON and ASSIMP_ANDROID_JNIIOSYSTEM=OFFvalid constellation

* [Issue_2340] Proper closing endif()...

* closes assimp#305': fix viewer

* Add test file.

* Update appveyor.yml

Disable vs2015-test

* Update appveyor.yml

Disable vs2017

* closes assimp#2115: rollback setup of FBX-camera.

* closes assimp#1593: fix computation of percentf for 3DS.

* introduce simple skin-test +some findings.

* fix compiler warnings.

* ignoring invalid normals and uvs indices instead of canceling the import completely

* In ColladaLoader in version 3.2.0 (release est. 2015) the name assignment was based on name attribute (xml) with optional fallbacks to id and sid. Over time this was changed to fix a bug and support for names was removed, only to be later (re)added using an optional `useColladaName` setting. We discovered a problem that with when using the name based assignment it doesn't assign automatically generated names like what it did in the logic in v3.2.0 and on the id based approach on current master.

We discovered this causes problems with matching the aiCamera and aiLight. So we rectified this problem by auto generating names also on the name based method.

* Ensure our include directories get added in the correct order

If you have assimp installed already and in the include path (e.g. I have it via homebrew), it can pick up the wrong headers.

This forces the include order so our local ones are found first when building assimp.

* Add aiNode::mName to ValidateDataStructure error reporting to ease debugging

* Make syntax used to call ReportError & ReportWarning a bit more consistent

* Typo

Fix a typo in a comment.

* ValidateDataStructure.cpp:
* Fixed warnings introduced by last commit (hopefully)
* Fixed case fallthrough (due to exception flow, it didn't make a practical difference, but hopefully will remove a warning)
* Minor formatting consistency improvements

* Initial pass

* Hopefully fix all warnings?

* remove 1 more of the warnings

* remove last warning?

* Reenable vs2015 and vs1017

* Update appveyor.yml

Fix build image.

* Update appveyor.yml

Fix cmake generation.

* Fix compiler warnings.

* Fix compiler warnings: var declarations hides other var.

* closes assimp#934: introduce material keys for shader types.

* add missing changes.

* Add short documentation.

* fix: change ScaleProcess priority

* Fix some coverity findings.

* fix loading 3D uvs from obj

* Update MD3Loader.cpp

Fix typo.

* Adds a way to select which exporters you want to compile

Mimics the ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT / ASSIMP_BUILD_XXX_IMPORTER code but for exporters.

This works exactly the same way with one exception - ASSIMP_NO_EXPORT still overrides everything and turns off all exporting.

Fixes assimp#2377

* Fix 3MF importer

* INSTALL: Out of source build and improve Windows

* INSTALL: update bullet point numbers

* Update Readme.md

Add the HAXE-port.

* {cmake} Explicitly turn off ASM686 and AMD64 cmake options when ASSIMP_BUILD_ZLIB is on

The AMD64 option causes a build failure on MSVC (assimp#1760) and the ASM builds seem to have problems:

   madler/zlib#41 (comment)

This change also prevents these from "polluting" the cmake options if assimp is being included as a submodule.
download8866 pushed a commit to download8866/Tortoise-SVN that referenced this issue May 25, 2019
* Patch from Sergey Azarkevich: Pass the peg revision to the revert command. (Fixes issue #584) : Revert from log dialog bottom pane fails if the file was deleted 
* Do not use assembly optimized zlib build since it's buggy: madler/zlib#41 http://svn.haxx.se/dev/archive-2013-08/0386.shtml
BlazesRus added a commit to BlazesRus/zlib that referenced this issue Jun 4, 2022
BlazesRus added a commit to BlazesRus/zlib that referenced this issue Jun 4, 2022
fhanau referenced this issue in fhanau/zlib Feb 27, 2023
Make the note about the use of "deflate" to refer to the "zlib" format
more prominent by rendering it as a note.

Also regenerate index.html, which has the side-effect of adding MDN
annotations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@weltling @pcordes @madler @rhuijben @ch3cooli and others