345

Git Extensions: Everything was working fine until yesterday.

But suddenly I am get this error when I try to pull some repositories using git extensions

C:\Program Files\Git\bin\git.exe pull --progress "origin" 
Done
    0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
AllocationBase 0x0, BaseAddress 0x68560000, RegionSize 0x390000, State 0x10000
C:\Program Files\Git\bin\sh.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0

It is happening for all the repositories which I have cloned. But, my git bash is working fine. I don't have any idea what is going on. Any idea as to why this is happening?

Uchia Itachi
  • 5,207
  • 2
  • 19
  • 26
  • 5
    Cygwin is weird and uses persistent shared memory sections. Have you tried rebooting your system? – Greg Hewgill Aug 29 '13 at 05:38
  • @GregHewgill: Haven't rebooted since few days. Will do it right away. – Uchia Itachi Aug 29 '13 at 05:40
  • 1
    @GregHewgill: It worked out. Thanks, maybe if you post it as an answer it will be helpful for others too. – Uchia Itachi Aug 29 '13 at 05:58
  • Just wanted to say that this bug isn't specific to git and on bad days cygwin will crash on any executable in the same way for no apparent reason. – meneldal Jun 09 '15 at 05:22
  • 1
    OP, you should change the selected answer to @Yirkha's answer, for that one solves the *root cause* of the problem. It may save some futile attempts on future readers (as happened to me). – ysap Aug 02 '17 at 13:08

14 Answers14

382

I had the same problem. I found solution here http://jakob.engbloms.se/archives/1403

c:\msysgit\bin>rebase.exe -b 0x50000000 msys-1.0.dll

For me solution was slightly different. It was

C:\Program Files (x86)\Git\bin>rebase.exe -b 0x50000000 msys-1.0.dll

Before you rebase dlls, you should make sure it is not in use:

tasklist /m msys-1.0.dll

And make a backup:

copy msys-1.0.dll msys-1.0.dll.bak

If the rebase command fails with something like:

ReBaseImage (msys-1.0.dll) failed with last error = 6

You will need to perform the following steps in order:

  1. Copy the dll to another directory
  2. Rebase the copy using the commands above
  3. Replace the original dll with the copy.

If any issue run the commands as Administrator

Septagram
  • 8,480
  • 11
  • 46
  • 76
zainengineer
  • 10,877
  • 4
  • 35
  • 26
  • 1
    In my case I rebase.exe was in sub-directory under /mingw so the command ended up being: c:/msysgit/mingw/bin/rebase -b 0x50000000 msys-1.0.dll and I ran it while located in the c:/msysgit/bin directory. – Robert Oschler Jul 14 '14 at 02:21
  • 8
    I git this error ReBaseImage (msys-1.0.dll) failed with last error = 6 – TheJKFever Jul 16 '14 at 22:31
  • 17
    @TheJKFever you need to run it in a command prompt as Administrator, because it is going to modify the msys-1.0.dll. Make a backup of the dll first, copy it to msys-1.0.dll.bak, then run the command as Administrator. It worked for me. – Nikolaos Georgiou Aug 05 '14 at 07:15
  • I faced this issue couple of days earlier and it worked for me... I am facing the same issue again today and getting ReBaseImage (msys-1.0.dll) failed with last error = 6....any help... – Mayank Oct 31 '14 at 08:35
  • Confirmed as a fix after upgrading from 8gb to 16gb of ram, run the command as admin, no reboot required. – SSZero Jan 15 '15 at 22:31
  • 1
    windows 8.1 tells me I can't run this executable on this pc when I try to rebase – Jules G.M. Mar 07 '15 at 06:34
  • I get the ReBaseImage error even if I run as admin. – Jon Crowell Mar 30 '15 at 16:02
  • @JonCrowell I think you need make sure dll is not in use (tasklist /m msys-1.0.dll) and copy it to another directory – zainengineer Mar 30 '15 at 23:36
  • Thanks! It worked. Make sure to run CMD in administration mode. – code5 May 19 '15 at 20:16
  • It says `BaseAddress 0x68560000` in the error message. So I rebased it to 0x68560000, and now it works. Not sure why it worked for you with `0x50000000`. – Violet Giraffe Jul 21 '15 at 06:07
  • 1
    Thank you! I got the error after upading to Windows 10, but luckily it is fixed, now. – Philipp Aug 07 '15 at 12:15
  • Worked for me using windows 10. I had to do the copy .dll to another directory step. – Alex Sep 13 '15 at 12:43
  • 1
    Doesn't work for me in Windows 10. got "This app can't run on your PC" :( – Macke Sep 23 '15 at 10:07
  • This happened to me after install cygwin dev packages after already having installed sourcetree. – ccook Jan 06 '16 at 23:11
  • confirming, that you MUST perform this operation as an administrator (Windows 10 Pro 64 bit) – serge.k Feb 12 '16 at 10:42
  • it saved my life, my stash in git extentions wasnt working – DanilGholtsman Apr 11 '16 at 11:59
  • Works for me too, as above no reboot required. OK to use both rebase commands in turn. – A-Bop May 03 '17 at 08:56
  • 2
    I don't have rebase.exe on my Win10 64 Bit Pro, but calling the following did the trick (VS2010): "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\editbin.exe" /REBASE:BASE=0x50000000 msys-1.0.dll – Paul Bußmann May 05 '17 at 09:06
  • Worked perfectly (y) :). No rebooting at all! – NullPointer Sep 21 '17 at 16:18
  • I just get `msys-1.0.dll: skipped because wrong machine type.` – xorinzor Sep 25 '17 at 11:26
  • some time rebase.exe has a version number in it name e.g my rebase was **rebase-1.18-1.exe** – Thecarisma May 13 '19 at 15:15
  • some time rebase.exe has a version number in it name e.g my rebase was **rebase-1.18-1.exe** – Thecarisma May 13 '19 at 15:15
233

Cygwin uses persistent shared memory sections, which can on occasion become corrupted. The symptom of this is that some Cygwin programs begin to fail, but other applications are unaffected. Since these shared memory sections are persistent, often a system reboot is needed to clear them out before the problem can be resolved.

Dyin
  • 7,425
  • 6
  • 40
  • 60
Greg Hewgill
  • 828,234
  • 170
  • 1,097
  • 1,237
  • In case it helps anyone, I moved the GitExtensions bit in my PATH to be the very first item and it seems to have resolved the issue for me. (I put the git/cmd itself 2nd - not sure if that was part of it). A bit easier than a reboot or .dll shuffling. – jinglesthula Dec 02 '16 at 19:04
  • 7
    Isn't there an executable that can just be terminated to free the memory? A full system reboot seems like overkill. Also, an answer below (http://stackoverflow.com/a/31970708/88409) explains what the problem really is, and it has nothing to do with corrupted memory. – Triynko Feb 13 '17 at 15:48
138

tl;dr: Install 64-bit Git for Windows 2.


Technical details

      0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
AllocationBase 0x0, BaseAddress 0x68570000, RegionSize 0x2A0000, State 0x10000
PortableGit\bin\bash.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0

This symptom by itself has nothing to do with image bases of executables, corrupted Cygwin's shared memory sections, conflicting versions of DLLs etc.

It's Cygwin code failing to allocate a ~5 MB large chunk of memory for its heap at this fixed address 0x68570000, while only a hole ~2.5 MB large was apparently available there. The relevant code can be seen in msysgit source.


Why is that part of address space not free?

There can be many reasons. In my case it was some other modules loaded at a conflicting address:

Process modules in Process explorer

The last address would be around 0x68570000 + 5 MB = 0x68C50000, but there are these WOW64-related DLLs loaded from 0x68810000 upwards, which block the allocation.

Whenever there is some shared DLL, Windows in general tries to load it at the same virtual address in all processes to save some relocation processing. It's just a matter of bad luck that these system components got somehow loaded at a conflicting address this time.


Why is there Cygwin in your Git?

Because Git is a rich suite consisting of some low level commands and a lot of helpful utilities, and mostly developed on Unix-like systems. In order to be able to build it and run it without massive rewriting, it need at least a partial Unix-like environment.

To accomplish that, people have invented MinGW and MSYS - a minimal set of build tools to develop programs on Windows in an Unix-like fashion. MSYS also contains a shared library, this msys-1.0.dll, which helps with some of the compatibility issues between the two platforms during runtime. And many parts of that have been taken from Cygwin, because someone already had to solve the same problems there.

So it's not Cygwin, it's MinGW's runtime DLL what's behaving weird here.

In Cygwin, this code has actually changed a lot since what's in MSYS 1.0 - the last commit message for that file says "Import Cygwin 1.3.4", which is from 2001!

Both current Cygwin and the new version of MSYS - MSYS2 - already have different logic in place, which is hopefully more robust. It's only old versions of Git for Windows which have been still built using the old broken MSYS system.


Clean solutions:

  • Install Git for Windows 2 - it is built with the new, properly maintained MSYS2 and also has many new features, plenty of bug fixes, security improvements and so on. If at all possible, it is also recommended to use the 64-bit version. But the rebase workaround is performed automatically behind the scenes for 32-bit systems, so the chances of the problem happening there should be lower too.
  • Simply restarting the computer to clean the address space (loading these modules at a different random address) might work, but really, just upgrade to Git for Windows 2 to get the security fixes if nothing else.

Hacky solutions:

  • Changing PATH can sometimes work because there might be different versions of msys-1.0.dll in different versions of Git or other MSYS-based applications, which perhaps use different address, different size of this heap etc.
  • Rebasing msys-1.0.dll might be a waste of time, because 1) being a DLL, it already has relocation information and 2) "in any version of Windows OS there is no guarantee that a (...) DLL will always load at same address space" anyway (source). The only way this can help is if the msys-1.0.dll itself loads at the conflicting address it's then trying to use. Apparently that's the case sometimes, as this is what the Git for Windows guys are doing automatically on 32-bit systems.
  • Considering the findings above, I originally binary patched the msys-1.0.dll binary to use a different value for _cygheap_start and that resolved the problem immediately.
Community
  • 1
  • 1
Yirkha
  • 9,712
  • 5
  • 35
  • 49
  • Excuse my ignorance but does that mean it's a bug in cygwin? If so would you happen to know if it's already been reported? Ta. Great explanation. – Tim Abell Aug 17 '15 at 00:46
  • 1
    Thank you for your curious comment! It turns out it has been fixed one way or another for quite some time now and the proper solution seems to be to use Git for Windows 2 built on MSYS2 (and thus more recent Cygwin code). – Yirkha Aug 18 '15 at 04:43
  • 2
    Thanks, good to know. I'm using the version bundled with git-extensions, whatever that is. Rebooting fixed it so I'll ignore it till the update winds its way to me. :-) – Tim Abell Aug 18 '15 at 08:51
  • what is tl;dr: in the title? – George Birbilis Nov 29 '15 at 15:46
  • @GeorgeBirbilis Internet slang for "too long; didn’t read", marks a short summary of otherwise too long or detailed text. See also http://english.stackexchange.com/a/209442/149521 – Yirkha Nov 30 '15 at 00:22
  • 3
    Perfect, well documented answer! And a proper permanent solution to the problem instead of the currently accepted answer. – Søren Boisen Dec 09 '15 at 11:01
  • 2
    A little more detail on the problem - https://github.com/git-for-windows/git/wiki/32-bit-issues – Kunal Apr 12 '17 at 20:05
  • 1
    x64 Git for windows worked for me and cmder. Thank you! It has been driving me crazy, especially working with cmder. I basically copied the x64 Git folder to the `cmder/vendor/git-for-windows` directory & renamed the old folder to `git-for-windows-x86`. If you open `cmder/vendor/git-for-windows`, you'll see a folder `mingw32`, which is your clue you're using 32bit. In the x64 Git, you'll see a folder `mingw64`. – cmeza Aug 07 '17 at 20:44
  • I had a ccrypt binary and cygwin1.dll beside it which started giving me this problem, so I just replaced cygwin1.dll with the version from my more recent cygwin install (ccrypt is used separately to cygwin, hence the different dll) and that seemed to work. I have rebased in the past but now I understand the issue better. – Adam Kerz Dec 06 '17 at 21:25
32

Very simple verison of the rebase solution:

Go to the folder where git is installed, such as:

C:\Program Files (x86)\Git\bin

By holding shift and right clicking in the folder, you should be able to open a command prompt as administrator from there (thanks to https://stackoverflow.com/users/355389/darren-lewis for that comment),

Then run:

rebase.exe -b 0x50000000 msys-1.0.dll

This fixed it for me when the restart approach didn't work.

Hope it helps.

Community
  • 1
  • 1
Tisch
  • 2,508
  • 4
  • 27
  • 34
  • 1
    Worked for me. Just make sure you run the command prompt as Administrator. – Darren Lewis Feb 03 '16 at 14:29
  • This also worked for me, as a note, I don't know how you could shift right click and load cmd.exe as admin, so I launched cmd.exe right click from start select start as admin, then cd into the directory, then run the command. It worked! – edencorbin Jan 05 '17 at 18:00
13

I have seen the same error message after upgrading to git1.8.5.2:

Simply make a search for all msys-1.0.dll on your C:\ drive, and make the one used by Git comes first.

For instance, in my case I simply changed the order of:

C:\prgs\Gow\Gow-0.7.0\bin\msys-1.0.dll
C:\prgs\git\PortableGit-1.8.5.2-preview20131230\bin\msys-1.0.dll

By making the Git path C:\prgs\git\PortableGit-1.8.5.2-preview20131230\bin\ come first in my %PATH%, the error message disappeared.

No need to reboot or to even change the DOS session.
Once the %PATH% is updated in that DOS session, the git commands just work.


Note that carmbrester and Sixto Saez both report below (in the comments) having to reboot in order to fix the issue.
Note: First, also removing any msys-1.0.dll, like one in %LOCALAPPDATA%

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 2
    I didn't have msys-1.0.dll anywhere else in my path, but looks like you were right on something there - moving the git part of my path higher in the list did solve the problem for me. Thank you for that! - so tired of rebooting to fix. – carmbrester Jan 28 '14 at 21:19
  • 1
    My "extra" msys-1.0.DLL files where in the C:\Users\ **your login** \AppData\Local from another app. Removing that app **and** rebooting fixed the problem for me – Sixto Saez Sep 25 '14 at 16:46
  • @SixtoSaez Interesting. I have edited the answer to make the reboot step more visible. – VonC Sep 25 '14 at 16:51
  • probably those who also needed a reboot had needed just that (a different issue from the wrong DLL loading) – George Birbilis Nov 29 '15 at 15:50
8

If a reboot does not correct the problem (as suggested by Greg Hegwill's answer) then check your PATH for conflicting installation(s) of the msys-1.0.dll (and possibly other related DLLs).

In my particular situation MinGW's installation of msys has a copy of that DLL in its bin directory (<MinGW_Install_Path>\msys\1.0\bin), and it was listed in the PATH. Git's cmd directory was listed in the PATH, but its bin was not. (Git's version of msys-1.0.dll is in the bin directory. Apparently the default installation of MSys-Git does not add its bin to the PATH.)

A temporary fix was to add Git's bin directory to the PATH so that it appears before MinGW's paths. (A more permanent fix will likely involve sorting out the path conflicts between MinGW's msys and Git's and/or removing the duplicate msys installations.)

RobertB
  • 4,422
  • 1
  • 27
  • 29
2

Just want to share my experience here. I came across the same issue while cross compiling for MTK platform on a Windows 64 bit machine. MinGW and MSYS are involved in the building process and this issue popped up. I solved it by changing the msys-1.0.dll file. Neither rebase.exe nor system reboot worked for me.

Since there is no rebase.exe installed on my computer. I installed cygwin64 and used the rebase.exe inside:

C:\cygwin64\bin\rebase.exe -b 0x50000000 msys-1.0.dll

Though rebasing looked successful, the error remained. Then I ran rebase command inside Cygwin64 terminal and got an error:

$ rebase -b 0x50000000 msys-1.0.dll
rebase: Invalid Baseaddress 0x50000000, must be > 0x200000000

I later tried a couple address but neither of them worked. So I ended up changing the msys-1.0.dll file and it solved the problem.

radiohead
  • 369
  • 2
  • 11
1

I ran into this today. Led by Greg Hewgill's answer, I looked at running processes on my system to see if anything was "stuck" or if other users were logged into the machine doing anything with git. I then launched cygwin (installed separately) on this particular machine. It launched ok. I closed it and then tried the Git Extensions again (I was trying a pull operation) and it worked. Not sure if the launching of cygwin cleared something that was shared but this is the first time I ran into this error and this seemed to fix it for me.

P_O
  • 23
  • 3
1

I had the same problem, after some Windows 8.0 crash and update, on msys git 1.9. I didn't find any msys/git in my path, so I just added it in windows local-user envinroment settings. It worked without restarting.

Basically, similiar to RobertB, but I didn't have any git/msys in my path.

Btw:

  1. I tried using rebase -b blablabla msys.dll, but had error "ReBaseImage (msys-1.0.dll) failed with last error = 6"

  2. if you need this quickly and don't have time debugging, I noticed "Git Bash.vbs" in Git directory successfuly starts bash shell.

Koshmaar
  • 133
  • 12
  • Same situation for me. Rebasing as admin failed. Added `c:\Program Files (x86)\Git\bin` to path and now I'm golden. – Jon Crowell Mar 30 '15 at 16:01
1

This error happens very rarely on my Windows machine. I ended up rebooting the machine, and the error went away.

IgorGanapolsky
  • 23,124
  • 17
  • 109
  • 132
0

I have encountered this issue witht he LPCEXpresso building.if you have the C:\MinGW\bin in the PATH. somehow I had to remove it to get rid of this issue since some other MinGW like based too

0

To fix this issue, I simply let Tortoise Git install its update.

Jace Browning
  • 9,756
  • 8
  • 59
  • 83
0

c:\msysgit\bin>rebase.exe -b 0x50000000 msys-1.0.dll

0

Deleting old version of %USERPROFILE%\AppData\Local\SourceTree\app-x.x.x worked for me. Not sure how it was connected to command line git...

barbalion
  • 158
  • 7