Repository navigation
Description
Description
As of yesterday, whenever I try to open Desktop, it tries to sync and then crashes.
Version
GitHub Desktop version:
Unknown - (Latest I think?)
OS version:
Windows 10 (Home), Version 1703, Build 15063.296
Steps to Reproduce
- Open GitHub Desktop...
- Wait for it to try and sync...
- Watch your hopes and dreams crumble.
I have two repos cloned in Desktop; https://github.com/rivermont/spidy and https://github.com/rivermont/instagram-graph.
It opens to spidy, and it appears that there is a push that it never manages to send before crashing.
Expected behaviour:
Open GitHub Desktop without problems.
Actual behaviour:
After opening, Desktop tries to sync and then crashes.
Reproduces how often:
100% of the time.
Attempted Debugging
- Force quit Desktop from Task Manager
- Restart computer.
- Push the commit really fast before it crashes.
- Run
Update.exefrom\AppData\Local\GitHubDesktop\
###Logs
Crash Report
Displayed in a nice red box with a single Quit button:
GitHub Desktop encountered an uncaught exception, leaving it in an invalid state.
Error: "toString()" failed
at Uint8Array.Buffer.toString (buffer.js:503:11)
at StringDecoder.utf8Text [as text] (string_decoder.js:180:16)
at StringDecoder.write (string_decoder.js:64:46)
at readableAddChunk (_stream_readable.js:164:31)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:551:20)
Crash Logs
Stolen from \AppData\Roaming\GitHub Desktop\logs\:
2017-05-29T02:21:13.993Z - error: Uncaught exception on renderer process
Error: "toString()" failed
at Uint8Array.Buffer.toString (buffer.js:503:11)
at StringDecoder.utf8Text [as text] (string_decoder.js:180:16)
at StringDecoder.write (string_decoder.js:64:46)
at readableAddChunk (_stream_readable.js:164:31)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:551:20)
Activity
shiftkey commentedon May 29, 2017
@rivermont The stack trace doesn't point to anything in the GitHub Desktop source code, so let's see if we can get a repro together.
So on launch there's a good chance that it's doing a fetch against the repository. Does that sound like what you're seeing?
We shouldn't be doing a push unless it's user-initiated. You should be able to open the Dev Tools before you quit the app - anything interesting in there?
niik commentedon May 29, 2017
I believe, from looking at this stack trace, that we're dealing with reading of data from a git shell command. Looking at your repositories they themselves doesn't seem to be of a size that would cause any problems. Is there any chance you have a large file lying in one of the repositories? Committed or otherwise?
rivermont commentedon May 29, 2017
@shiftkey How can I open the developer tools window? I have maybe 10 seconds on launch before crash.
@niik There are some possibly troublesome files in my spidy folder:
crawler_done.txtis >500MBcrawler_words.txtis > 400MBcrawler_todo.txtis 24MBbut they've been bigger and it's never had a problem with them before.
I haven't touched the other repo - which *is actually https://github.com/rivermont/instagram-graph - in a while and it's pretty small.
shiftkey commentedon May 29, 2017
@niik nice call on the Git shell output being to blame!
@rivermont Node processes set a limit on the output it will accept - we're setting it to 10MB currently by default whenever we invoke Git but clearly there's some places where this still isn't enough.
Looking at the published repository, I see
crawler_done.txtandcrawler_words.txtare empty files - I gather you haven't committed local changes to those files, and it's trying to parse the diff and encountering this hard limit...shiftkey commentedon May 29, 2017
Related issues: #1686 and #997
rivermont commentedon May 30, 2017
Thanks guys! So moving the large files out of the folder before starting Desktop allowed it to sync properly. I could then place the files back in and it could process them. It seems that one needs to do this after restarting or force-quitting Desktop; once launched it can be opened just fine.
niik commentedon May 30, 2017
Thank you so much for confirming the theory @rivermont. I'm gonna keep this issue open for a little bit as we try to get to the bottom of what's happening.
@shiftkey I don't understand why that limit would produce this particular error though. Reading through some issues online it seems to me that the most likely cause of this particular error is us hitting the maximum string length as defined by V8 (256mb). Our stdout buffer cap should kick in way before that and I wouldn't expect it to throw this particular error either. In trying to reproduce this I intentionally triggered the max stdout buffer case and got this error which is what I would expect.
(Note that the fact that we're not catching this is pretty terrible in itself but it's not directly related to the stack provided by @rivermont)
I think this is related to #1524
@rivermont I'd really like to be able to reproduce this but so far I haven't been able to. Is there anything else you can tell us about your environment? How's your memory consumption? Are you running close to your maximum memory?
Would you be willing to zip up your entire repository with the offending files and let me have a look at it? I imagine since you're mostly dealing with textual content that they'd compress fairly well. We can arrange for you to send it to us privately if that would help.
shiftkey commentedon May 30, 2017
@niik yeah, the stack trace is very different to our typical error handling for the process output - I've not dug into recreating this yet but this thread from Node core does feel relevant nodejs/node#3175
rivermont commentedon May 30, 2017
Here is a screencast of the crash in action, along with Task Manager watching:
http://recordit.co/EU5MD0nquH
It seems that if anything I'm running out of CPU power first; it stops before memory usage climbs above 60%, around 30% at idle.
shiftkey commentedon May 30, 2017
@rivermont if you still have the repository in that weird state, could you open it in a
cmdwindow and run these commands (swapcrawler_done.txtfor whichever file looks interesting).To get the number of lines in the file:
To get the total size (in bytes) of the file:
This will help give an idea of the file we need to recreate to trigger this issue.
3 remaining items
shiftkey commentedon May 30, 2017
@rivermont thanks for the link. I'll try it out here and see if I can get the same issue.
I'm seeing the same thing here. Very interesting...
shiftkey commentedon Jun 1, 2017
Running this up against a debug version of Node 7.4 (the one that ships with Electron) I can get a similar error by just reading the contents of the file:
That's this code. It's following the
result = slowToString.apply(this, arguments);path, so at least know where it's failing.EDIT: looks like we're deep into node_buffer.cc to fix this.
Tweaking this to drop the
encodingparameter returns a buffer with Great Success™:I'm trying to get VS to break into
node.exewhen it errors (it seems doable) but this doesn't seem to trip as I'd hoped.shiftkey commentedon Jun 2, 2017
So I've nailed this down to the file contents and how we handle this in the app.
To begin with, let's just read the file in using
lesson Windows. We get to line 282 and it then starts spitting out garbage characters:Changing this up to use
git diffyou'll see the same thing:For reference, on MacOS this problem file is detected as binary:
I've traced this behaviour through to
string_bytes.cc.As this isn't doing any encoding detection, and just failing quietly when it encounters the corrupted bytes, we have a couple of options:
shiftkey commentedon Jun 2, 2017
For reference, I was able to trigger #1524 just now on macOS using this file. So at least we know these are inter-related...
shiftkey commentedon Jun 2, 2017
I've mirrored the problem file on Dropbox for those who want to play around with it in the app with the
spidyrepo.joshaber commentedon Jun 2, 2017
It seems like this is something we'll have to do eventually anyways, to support different encodings (cc #1607). So I'd certainly lean towards this.
shiftkey commentedon Jun 2, 2017
@joshaber yeah, that's the way I'm heading right now to make the crashes go away sooner 😛