Potential bug on Win32 with Zlib compression

Dear all.

For a while I am trying to debug a strange bug that appeared on Win32 32 bit while switching from VS2008 to VS2013 (VS2017 the same) and HDF 1.10.+

It seems to appear only when a certain length is compressed (i.e. small test vectors like 5 elements do not trigger it) and only on Release builds. Furthermore I cannot reproduce it under Linux (i686 or amd64) regardless of optimization.

I have a self contained unit-test that triggers it, although I am not sure how to provide it, since it is only useful when HDF5 is installed in a certain location relative to it.

The following refers to HDF5 1.10.3 and ZLIB 1.2.11

I am grateful for any advice.

The back trace is
(d0c.6f8): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=0007f260 ebx=baadf00d ecx=0099c0c6 edx=00000000 esi=0099bd50 edi=0099b230
eip=014bff7f esp=0019efcc ebp=00000024 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210206
test1!inflate_fast+0x3af:
014bff7f 8b0483 mov eax,dword ptr [ebx+eax*4] ds:0023:bacdb98d=???
0:000> k
ChildEBP RetAddr
0019f01c 014bcc36 test1!inflate_fast+0x3af
0019f0d4 012f978e test1!inflate+0xf26 [f:3rdparty\zlib\inflate.c @ 1048]
0019f110 0133ea6e test1!H5Z_pipeline+0x18e [f:3rdparty\hdf5\src\h5z.c @ 1324]
0019f1e0 01337032 test1!H5D__chunk_lock+0x56e [f:3rdparty\hdf5\src\h5dchunk.c @ 3608]
0019f360 01275452 test1!H5D__chunk_read+0x332 [f:3rdparty\hdf5\src\h5dchunk.c @ 2228]
0019f46c 01276b92 test1!H5D__read+0x512 [f:3rdparty\hdf5\src\h5dio.c @ 600]
0019f4ac 011f2b70 test1!H5Dread+0x242 [f:3rdparty\hdf5\src\h5dio.c @ 198]
0019f580 011de5e3 test1!H5::DataSet::read+0xb0 [f:3rdparty\hdf5\c++\src\h5dataset.cpp @ 430]
0019f5e0 011e40a9 test1!mexhdf5imp::Storage::copyTimes+0xa3 [f:mexhdf5imp\storage.cc @ 68]
0019f7fc 011e11f2 test1!test_storage_with_large_generated+0xf9 [f:mexhdf5imp\tests\test1.cc @ 377]
0019f800 011e4a66 test1!all_tests+0x32 [f:mexhdf5imp\tests\test1.cc @ 399]
0019f808 014c5c24 test1!main+0x6 [f:mexhdf5imp\tests\test1.cc @ 403]
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\kernel32.dll -
0019f850 76b0efac test1!__scrt_common_main_seh+0xfa [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl @ 283]
WARNING: Stack unwind information not available. Following frames may be wrong.
0019f85c 77cf3618 kernel32!BaseThreadInitThunk+0x12
0019f89c 77cf35eb ntdll!RtlInitializeExceptionChain+0xef
0019f8b4 00000000 ntdll!RtlInitializeExceptionChain+0xc2

DRMemory reports

Error #1: UNINITIALIZED READ: reading register ebx
# 0 inflate_fast
# 1 inflate                                         [f:3rdparty\zlib\inflate.c:1047]
# 2 H5Z_filter_deflate                              [f:3rdparty\hdf5\src\h5zdeflate.c:114]
# 3 H5Z_pipeline                                    [f:3rdparty\hdf5\src\h5z.c:1314]
# 4 H5D__chunk_lock                                 [f:3rdparty\hdf5\src\h5dchunk.c:3608]
# 5 H5D__chunk_read                                 [f:3rdparty\hdf5\src\h5dchunk.c:2228]
# 6 H5Dread                                         [f:3rdparty\hdf5\src\h5dio.c:198]
# 7 H5::DataSet::read                               [f:3rdparty\hdf5\c++\src\h5dataset.cpp:430]
# 8 mexhdf5imp::Storage::copyTimes                  [f:mexhdf5imp\storage.cc:67]
# 9 test_storage_with_large_generated               [f:mexhdf5imp\tests\test1.cc:376]
#10 all_tests                                       [f:mexhdf5imp\tests\test1.cc:399]
#11 KERNEL32.dll!BaseThreadInitThunk               +0x11     (0x76b0efac <KERNEL32.dll+0x4efac>)
Note: @0:00:11.281 in thread 2476
Note: instruction: mov    (%ebx,%eax,4) -> %eax

Error #2: UNADDRESSABLE ACCESS beyond top of stack: reading 0x001fc980-0x001fc984 4 byte(s)
# 0 inflate_fast
# 1 inflate                                         [f:3rdparty\zlib\inflate.c:1047]
# 2 H5Z_filter_deflate                              [f:3rdparty\hdf5\src\h5zdeflate.c:114]
# 3 H5Z_pipeline                                    [f:3rdparty\hdf5\src\h5z.c:1314]
# 4 H5D__chunk_lock                                 [f:3rdparty\hdf5\src\h5dchunk.c:3608]
# 5 H5D__chunk_read                                 [f:3rdparty\hdf5\src\h5dchunk.c:2228]
# 6 H5Dread                                         [f:3rdparty\hdf5\src\h5dio.c:198]
# 7 H5::DataSet::read                               [f:3rdparty\hdf5\c++\src\h5dataset.cpp:430]
# 8 mexhdf5imp::Storage::copyTimes                  [f:mexhdf5imp\storage.cc:67]
# 9 test_storage_with_large_generated               [f:mexhdf5imp\tests\test1.cc:376]
#10 all_tests                                       [f:mexhdf5imp\tests\test1.cc:399]