libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.21k stars 889 forks source link

"Error reading from the zlib stream"-Exception on Fetch/ Clone/ Push with custom transport #1594

Open WolfThomas opened 6 years ago

WolfThomas commented 6 years ago

I wrote a custom smarttransport according to a ssh sample. After fetch, pull or clone I get valid data but the method throws LibGit2Sharp Exception with "error reading from the zlib stream".

Transport with upload-pack read->write->read->write works, see dump below.

The error message: "error reading from the zlib stream" occurs in libgit2 within pack.c in method git_packfile_stream_read() after calling inflate(&obj->zstream, Z_SYNC_FLUSH); Error will be called if the result is !=Z_OK && !=Z_STREAM_END. After setting pack.compression=0 the zlib stream contains uncompressed data. But the error message is still there.

STDIN/ STDOU

READ:

00fc5daa747d4ca7905ff8996f770ef74d1b894be3d2 HEAD multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master agent=git/2.18.0.windows.1 003f5daa747d4ca7905ff8996f770ef74d1b894be3d2 refs/heads/master 003e5daa747d4ca7905ff8996f770ef74d1b894be3d2 refs/heads/test2 0000

WRITE:

0074want 5daa747d4ca7905ff8996f770ef74d1b894be3d2 multi_ack_detailed side-band-64k include-tag thin-pack ofs-delta 0032want 5daa747d4ca7905ff8996f770ef74d1b894be3d2 00000009done

READ:

0008NAK 0023Enumerating objects: 9, done. Counting objects: 100% (9/9), done. Compressing objects: 100% (6/6), done. 002bTotal 9 (delta 0), reused 0 (delta 0) 02e7PACK òx£ì-1-0 +=»+ÄälºNc !6Ìß$NAé+­x-m763[AÁ+sª$C+!7eì[å$í¦Àn÷^A&ã:Cÿ+-T#&Ö+BfàªäëKê+Úg·µ»}+²i¨yi·¦Ò+ï«gÅÉä+Ç \Ú¤þ}¹©]ks.k8¬òx£ì-=-0@ß=º+ÄäþºÄäþpº ZéZszûÀ}z¦ëÏ\KpêÈUqòÉk+=-Ç U8O àú¨­&oÁëÿ=óª=d+AÊ4qóÏÇ:+ã-áß»>ãf´cÌÝe>zٳƾ2*/WÙó?«ô-hOÇ ªÄu}¬- -¿ýj~Ç@9[ÿ

x£ì-1-0@Ð=º­ÄäLLöTBê¡þpmÀDñDj-²¦#¦³7}¯¦@°nël8eÔR-ª¿ëSûY'UM%IÓƒ+¹c_vx,g_3ý+¦p{--ûé4d©DÊÎÁ¦¦ G¿¯Ûò[8 Ë-õ¿x£343 ¢Éd¸¦åîUFzÜ--£+²Ê½2.Þr³ê]ÙdhfbóPöÜÿÆø¬WRQ-ã»Ã¤J¦_Ðß¾ØKMº¥à 3Sã¦x£-¦-,+L¦QH+¤--,I,NIa.-à-3©îí+ §Ó-¿x£343 ¢Éd¸¦åîUFzÜ--£+²Ê½2.Þr³ê]ÙdhfbóPöÜÿÆø¬WRQ-­=âìBnï§+=ƒ º=¦|[c N+ô¦x£-¦-,+L¦QH+¤--,I,NIa.-ò +®*ªx£340031Q(JML+Mi+®(a+§u¦sQ?-§î¦O´¢¹¦,²Û+. H>x£-¦-,+L¦QH+¤--, )-öP¸ãyô

WRITE:

0000

Exception

An unhandled exception of type 'LibGit2Sharp.LibGit2SharpException' occurred in LibGit2Sharp.dll Additional information: error reading from the zlib stream

Callstack

bei LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:Zeile 136. bei LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable1 refSpecs, GitFetchOptions fetchOptions, String logMessage) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:Zeile 2268. bei LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable1 refspecs, FetchOptions options, String logMessage) in C:\projects\libgit2sharp\LibGit2Sharp\Commands\Fetch.cs:Zeile 76. bei GitFunction.Test.Beta2.button1_Click(Object sender, EventArgs e) in C:\TFS\DS\ThomasZ\BeckhoffGitAdsService\GitAdsServicePackage\GitFunction.Test\Beta2.cs:Zeile 62. bei System.Windows.Forms.Control.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.ButtonBase.WndProc(Message& m) bei System.Windows.Forms.Button.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei GitFunction.Test.Program.Main() in C:\TFS\DS\ThomasZ\BeckhoffGitAdsService\GitAdsServicePackage\GitFunction.Test\Program.cs:Zeile 19. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart()

Versions LibGit2Sharp 0.24.0.0 LibGit2Sharp 0.25.0.0 with VS 2017 and .Net Standard 2.0 git version 2.18.0.windows.1 Win 10 x64 .Net 4.5

bj25x commented 5 years ago

Were you able to correct the error? I have a Flare project in Azure I am cloning to a coworker's machine, and get: error reading from the zlib stream - could not authenticate.

WolfThomas commented 5 years ago

Hello, I used the Microsoft Command Prompt (cmd) within C# Code on two different devices. I had to set the encoding of the string to solve my issue. Perhaps you have an encoding issue too.