Bug 32086 - GZipStream throws System.EntryPointNotFoundException
Summary: GZipStream throws System.EntryPointNotFoundException
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.0.0
Hardware: PC Windows
: --- normal
Target Milestone: Future Release
Assignee: Johan Lorensson
URL:
: 38631 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-07-17 15:46 UTC by Taylor Southwick
Modified: 2017-10-13 14:25 UTC (History)
8 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Repro code (1.58 KB, text/plain)
2015-07-17 15:46 UTC, Taylor Southwick
Details
Three DLL of MonoPosixHelper: shipped, vs-built, gcc-built (480.24 KB, application/x-zip-compressed)
2015-09-10 08:37 UTC, Jun H. Jang
Details
Comparing entrypoints using Dependancy Walker (1) (124.24 KB, image/png)
2015-09-10 08:41 UTC, Jun H. Jang
Details
Comparing entrypoints using Dependancy Walker (2) (131.28 KB, image/png)
2015-09-10 08:42 UTC, Jun H. Jang
Details

Description Taylor Southwick 2015-07-17 15:46:38 UTC
Created attachment 12094 [details]
Repro code

This seemed to work on earlier Mono versions, but I just installed 4.0.2 on Windows 10 and I get the following stack trace when calling the GZipStream constructor:

Unhandled Exception:
System.EntryPointNotFoundException: CreateZStream
  at (wrapper managed-to-native) System.IO.Compression.DeflateStreamNative:CreateZStream (System.IO.Compression.CompressionMode,bool,System.IO.Compression.DeflateStreamNative/UnmanagedReadOrWrite,intptr)
  at System.IO.Compression.DeflateStreamNative.Create (System.IO.Stream compressedStream, CompressionMode mode, Boolean gzip) [0x00000] in <filename unknown>:0
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode,bool,bool)
  at System.IO.Compression.GZipStream..ctor (System.IO.Stream stream, CompressionMode mode, Boolean leaveOpen) [0x00000] in <filename unknown>:0
  at System.IO.Compression.GZipStream..ctor (System.IO.Stream stream, CompressionMode mode) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.Compression.GZipStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode)
  at ConsoleApplication1.Program.Compress (System.Byte[] data) [0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.Compress (System.String text) [0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.EntryPointNotFoundException: CreateZStream
  at (wrapper managed-to-native) System.IO.Compression.DeflateStreamNative:CreateZStream (System.IO.Compression.CompressionMode,bool,System.IO.Compression.DeflateStreamNative/UnmanagedReadOrWrite,intptr)
  at System.IO.Compression.DeflateStreamNative.Create (System.IO.Stream compressedStream, CompressionMode mode, Boolean gzip) [0x00000] in <filename unknown>:0
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode,bool,bool)
  at System.IO.Compression.GZipStream..ctor (System.IO.Stream stream, CompressionMode mode, Boolean leaveOpen) [0x00000] in <filename unknown>:0
  at System.IO.Compression.GZipStream..ctor (System.IO.Stream stream, CompressionMode mode) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.Compression.GZipStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode)
  at ConsoleApplication1.Program.Compress (System.Byte[] data) [0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.Compress (System.String text) [0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

mono --version gives the following output:

Mono JIT compiler version 4.0.2 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen
Comment 1 Alexander Köplinger 2015-07-18 18:56:05 UTC
This doesn't repro on Mono 4.0.2 on Linux/Ubuntu, so it's likely a problem with the Windows package.

@Jo: I can repro this on 3.12 on Windows, so it doesn't seem like a recent problem. Looks like CreateZStream isn't exported in MonoPosixHelper.dll.
Comment 2 Jun H. Jang 2015-09-04 05:52:04 UTC
I also can repro this on 4.03 on Windows

neither GZipStream nor DeflateStream works.
Comment 3 Jun H. Jang 2015-09-04 05:55:01 UTC
Mono JIT compiler version 4.0.3 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

Operating System : Windows 7 SP1 (64 bit)
Comment 4 Jun H. Jang 2015-09-04 06:02:57 UTC
This is not a recent problem.. very old one.

http://mono.1490590.n4.nabble.com/EntryPointNotFoundException-CreateZStream-td4661364.html

http://stackoverflow.com/questions/26662552/cant-compress-with-mono

(Unity is still stucked at 2.x)
Comment 5 Jun H. Jang 2015-09-10 08:35:26 UTC
I've built MonoPosixHelper.dll myself today both using Visual Studio and gcc and they had no problem at all.

To inspect deeper, I've run Dependancy Walker to check the symbols are
actually exported.

And shipped version really misses following functions:
- CloseZStream
- CreateZStream
- Flush
- ReadZStream
- WriteZStream

Instead, it exports all zlib functions:
- compress
- compress2
- create_z_stream
- ...

Interestingly it seems that the shipped version of the dll is not likely
to be built with visual studio. (although 'mono --version' says that it's 'Visual Studio built mono')


To compare:

Shipped version :
- Missing CreateZStream, Flush, ReadZstream, etc.
- Includes all zlib funcs (compress, create_z_stream, etc.)
- Fails when trying to load into Visual Studio
- 385 kb

Visual studio home built :
- Includes CreateZStream, Flush, ReadZstream, etc.
- Excludes zlib funcs
- Shows 'MANIFEST' when load into Visual Studio
- 59 kb (release build)

GCC home built:
- Includes CreateZStream, Flush, ReadZstream, etc.
- Includes all zlib funcs also
- Fails when trying to load into Visual Studio
- 786 kb


I don't know but just guessing that something bizarre happens
in the CI server when I look at the history of monoposixhelfer.def.

(https://github.com/mono/mono/commits/master/msvc/monoposixhelper.def)

It should be fixed already at 2010.

I hope this to be fixed.. (Maybe again)
Comment 6 Jun H. Jang 2015-09-10 08:37:02 UTC
Created attachment 12850 [details]
Three DLL of MonoPosixHelper: shipped, vs-built, gcc-built
Comment 7 Jun H. Jang 2015-09-10 08:41:07 UTC
Created attachment 12851 [details]
Comparing entrypoints using Dependancy Walker (1)
Comment 8 Jun H. Jang 2015-09-10 08:42:06 UTC
Created attachment 12852 [details]
Comparing entrypoints using Dependancy Walker (2)

Both GCC-built and Shipped has zlib functions exported.
Visual-studio-built doesn't have one.
Comment 9 Jo Shields 2015-09-10 09:20:32 UTC
(In reply to comment #5)
> Interestingly it seems that the shipped version of the dll is not likely
> to be built with visual studio. (although 'mono --version' says that it's
> 'Visual Studio built mono')

https://github.com/mono/release/blob/master/defs/mono#L83-L85

Definitely MSVC-compiled.
Comment 10 Jun H. Jang 2015-09-10 09:59:12 UTC
Thanks for the link with which I can grasp what's going on. ^_^

I've run build step one by one and found that after the building
there're no *.dll exists on 'msvc/Win32/bin/'
they're on 'msvc/Win32/bin/Release'
       and 'msvc/Win32/bin/Release_SGen' instead.
(Release_SGen is empty due to errors)

So line 78 - line 90 fails.

Is this different on CI server?
Comment 11 Jo Shields 2015-09-10 10:00:11 UTC
We don't have any Windows CI.

I should hopefully be getting that going next week.
Comment 12 Greg Toombs 2017-01-25 14:11:28 UTC
Bump. This still happens years later:

 System.EntryPointNotFoundException CreateZStream   at (wrapper managed-to-native) System.IO.Compression.DeflateStreamNative:CreateZStream (System.IO.Compression.CompressionMode,bool,System.IO.Compression.DeflateStreamNative/UnmanagedReadOrWrite,intptr)
  at System.IO.Compression.DeflateStreamNative.Create (System.IO.Stream compressedStream, System.IO.Compression.CompressionMode mode, System.Boolean gzip) [0x00050] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0 
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, System.IO.Compression.CompressionMode mode, System.Boolean leaveOpen, System.Boolean gzip) [0x00036] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0 
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream stream, System.IO.Compression.CompressionMode mode, System.Boolean leaveOpen) [0x00000] in <5071a6e4a4564e19a2eda0f53e42f9bd>:0 
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode,bool)
  at SharpCompress.Writer.Zip.ZipWriter+ZipWritingStream.GetWriteStream (System.IO.Stream writeStream) [0x00033] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at SharpCompress.Writer.Zip.ZipWriter+ZipWritingStream..ctor (SharpCompress.Writer.Zip.ZipWriter writer, System.IO.Stream originalStream, SharpCompress.Writer.Zip.ZipCentralDirectoryEntry entry) [0x0001f] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at (wrapper remoting-invoke-with-check) SharpCompress.Writer.Zip.ZipWriter+ZipWritingStream:.ctor (SharpCompress.Writer.Zip.ZipWriter,System.IO.Stream,SharpCompress.Writer.Zip.ZipCentralDirectoryEntry)
  at SharpCompress.Writer.Zip.ZipWriter.WriteToStream (System.String entryPath, System.Nullable`1[T] modificationTime, System.String comment) [0x00085] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at SharpCompress.Writer.Zip.ZipWriter.Write (System.String entryPath, System.IO.Stream source, System.Nullable`1[T] modificationTime, System.String comment) [0x00000] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at SharpCompress.Archive.Zip.ZipArchive.SaveTo (System.IO.Stream stream, SharpCompress.Common.CompressionInfo compressionInfo, System.Text.Encoding encoding, System.Collections.Generic.IEnumerable`1[T] oldEntries, System.Collections.Generic.IEnumerable`1[T] newEntries) [0x00060] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at SharpCompress.Archive.AbstractWritableArchive`2[TEntry,TVolume].SaveTo (System.IO.Stream stream, SharpCompress.Common.CompressionInfo compressionType, System.Text.Encoding encoding) [0x00043] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at System.IO.Compression.ZipArchive.Save () [0x00025] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at System.IO.Compression.ZipArchive.Dispose (System.Boolean disposing) [0x00017] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at System.IO.Compression.ZipArchive.Dispose () [0x00000] in <fb55eb86b46447399acd3b2a2a43e31c>:0 
  at NLog.Targets.ZipArchiveFileCompressor.CompressFile (System.String fileName, System.String archiveFileName) [0x00056] in <5a2d0f31189445cd9ff8c8f2c3e6e880>:0 
  at NLog.Targets.FileTarget.ArchiveFile (System.String fileName, System.String archiveFileName) [0x00037] in <5a2d0f31189445cd9ff8c8f2c3e6e880>:0 
  at NLog.Targets.FileTarget.ArchiveByDate (System.String fileName, System.String pattern, NLog.LogEventInfo logEvent) [0x0004c] in <5a2d0f31189445cd9ff8c8f2c3e6e880>:0 
  at NLog.Targets.FileTarget.DoAutoArchive (System.String fileName, NLog.LogEventInfo eventInfo) [0x000ca] in <5a2d0f31189445cd9ff8c8f2c3e6e880>:0 
  at NLog.Targets.FileTarget.TryArchiveFile (System.String fileName, NLog.LogEventInfo ev, System.Int32 upcomingWriteSize) [0x000cd] in <5a2d0f31189445cd9ff8c8f2c3e6e880>:0
Comment 13 Greg Toombs 2017-01-25 14:24:45 UTC
Successful workaround is here:
http://stackoverflow.com/a/32958861/313768
Comment 14 Marek Safar 2017-10-13 14:23:30 UTC
*** Bug 38631 has been marked as a duplicate of this bug. ***
Comment 15 Marek Safar 2017-10-13 14:25:43 UTC
Johan, could you look into fixing this

Note You need to log in before you can comment on or make changes to this bug.