Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: could not fork child process: Resource temporarily unavailable (-1) #6

Closed
rinyre opened this issue Sep 29, 2016 · 44 comments
Closed
Labels

Comments

@rinyre
Copy link

rinyre commented Sep 29, 2016

Hello! I'm getting the following when I attempt to start the process:

Error: could not fork child process: Resource temporarily unavailable (-1).
DLL rebasing may be required. See 'rebaseall / rebase --help'.

Obviously there is no rebase binary packaged with this like Cygwin would typically have. Is there another way to rebase this?

@mintty
Copy link
Owner

mintty commented Sep 30, 2016

Did you install from the release package (installer) or did you build yourself?
If you built yourself, what's the output of uname -a?

@rinyre
Copy link
Author

rinyre commented Sep 30, 2016

I downloaded a release package. However, rebooting fixed the issue for me
for now, but I imagine I may run into that in the future.

On Sep 30, 2016 1:56 AM, "mintty" notifications@github.com wrote:

Did you install from the release package (installer) or did you build
yourself?
If you built yourself, what's the output of uname -a?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB1yiPliU32JOIkNAAWNvXNJiI10KAAMks5qvLKagaJpZM4KKkOP
.

@mintty
Copy link
Owner

mintty commented Sep 30, 2016

According to common wisdom, any Windows system should be rebooted at least every 42 days, anyway:)

@mintty mintty closed this as completed Oct 21, 2016
@wtchappell
Copy link

I just got hit with this immediately after a reboot - I installed using the installer.

@mintty
Copy link
Owner

mintty commented Oct 23, 2016

Unfortunately, cygwin has always had occasional problems with forking, see https://cygwin.com/faq.html#faq.using.fixing-fork-failures
This seems to be occuring more often with current builds of the Windows Technical Preview release (or even much more often with one specific build).
It's not a mintty issue.

@adam42a
Copy link

adam42a commented Aug 23, 2017

I am getting it all the time when I launch cygwin from a Windows taskbar launcher with mintty.exe - (the default launcher created by the cygwin installation).

But I can double-click mintty.exe in the File Explorer or launch from cmd, and cygwin runs happily, or I can run it as administrator.

Windows 10 is obviously doing some shenanigans with the taskbar.

@mintty
Copy link
Owner

mintty commented Aug 23, 2017

Is this Cygwin 64- or 32-bit? With taskbar launcher you mean an application icon docked to the taskbar?

@adam42a
Copy link

adam42a commented Aug 23, 2017

64-bit. Yes - an application icon pinned to the taskbar.

@mintty
Copy link
Owner

mintty commented Aug 24, 2017

Cannot reproduce, works here. Have you tried "rebasing"? Can you try with a fresh (parallel, minimal) Cygwin installation?

@adam42a
Copy link

adam42a commented Sep 23, 2017

Problem gone away now. Typical Windows.

@pequalsmp
Copy link

For those passing from Google - Encountered the same problem with a new (correct me if im wrong) feature in Windows 10:

Force randomization for images (Mandatory ASLR)
Force relocation of images not compiled with /DYNAMICBASE

Turning it off (as its by default) resolves the problem.

@mintty
Copy link
Owner

mintty commented Dec 29, 2017

Thanks for this information. We should share it on the cygwin mailining list.
Is this with Cygwin 64 Bit?
Can you provide details about how to turn off that Windows feature?

@pequalsmp
Copy link

pequalsmp commented Dec 29, 2017

Sure.

I'm using Cygwin x64 on Windows 10 build 1709.

To disable this feature you'll have to:

  • Press Win + S
  • Type in Windows Defender Security Center
  • Click App & browser control
  • Scroll down and click Exploit protection settings
  • Find the Force randomization for images section and select Off by default
  • Reboot

It should be off by default, but i think Microsoft will switch that on by default in the future as more and more programs become compatible.

@embray
Copy link

embray commented Jan 9, 2018

Has this been brought up on the Cygwin mailing list yet? I don't see any reference to it but I wanted to make sure. This is actually pretty severe problem IMO.

@mintty
Copy link
Owner

mintty commented Jan 9, 2018

No, I had the intention to report it but you are welcome to do it yourself, please.
I agree this sounds like important to be discussed there.

@embray
Copy link

embray commented Jan 9, 2018

Will do, thanks.

@Structed
Copy link

I've just encountered this issue. However, Force randomization of for images (Mandatory ASLR) was already set to Off by default. Also, rebooting did not solve the problem.

@embray
Copy link

embray commented Jan 10, 2018

There's also a "randomize memory allocations (Bottom-up ASLR) that I suspect might be a problem for Cygwin's fork, but I'm not sure.

@gamitech
Copy link

gamitech commented Jan 29, 2018

Here is the fix.
1 Go to you Windows Defender Security Center settings
2 Click on App & Browser Control
3 At the bottom click on the "Exploit Protection Settings" link
4 Go to "Program Settings" and click on the "Add program to customize" -> "Choose exact file path"
5 Navigate to "C:\Program Files\Git\usr\bin\sh.exe" and add it
6 Override and turn off the following:
Mandatory ASLR
Randomize memory allocations (Bottom-up ASLR)
7 Click "Apply" and now everything should work fine.

Also add these other binaries from the same folder: expr.exe, uname.exe, grep.exe, rm.exe

Good luck,
Gabriel

Repository owner deleted a comment from ArnolFokam Jun 2, 2018
Repository owner deleted a comment from embray Jun 2, 2018
Repository owner deleted a comment from ArnolFokam Jun 2, 2018
@acinnes
Copy link

acinnes commented Aug 25, 2018

I just hit this issue today trying to launch WSL Terminal on Windows 10 (build 17134.228), and then found it affected Git Bash and msys2 as well. However changing the ASLR settings for just mintty.exe or bash.exe wasn't enough. I found I also had to change them for wslbridge.exe, in the case of WSL Terminal, and other files in the case of Git Bash and msys2.

If you have msys2 installed, you can user PowerShell (in Admin mode) to script the changes for all of the binaries as follows:

$files = Get-ChildItem C:\msys64\usr\bin*.exe
$files | ForEach-Object {Set-ProcessMitigation -name $_.fullname -disable ForceRelocateImages, BottomUp, HighEntropy}

With Git for Windows, do the same but change the line for setting $files as follows:

$files = Get-ChildItem -recurse "C:\Program Files\Git*.exe"

Note that this may be disabling the ASLR settings for more binaries than strictly necessary; I'm not sure which aspects of the msys2/cygwin runtime are affected by ASLR.

@TheBestF22
Copy link

TheBestF22 commented Sep 7, 2018

@acinnes

For Future Reference:

That code can be even more Simplified/Shortened to something like this:

$files = (Get-ChildItem 'C:\msys64\usr\bin\*.exe').FullName
$files.ForEach({Set-ProcessMitigation $_ -Disable ForceRelocateImages})

And for Git (for Windows), to something like this:

$files = (Get-ChildItem 'C:\Program Files\Git\usr\bin\*.exe').FullName
$files.ForEach({Set-ProcessMitigation $_ -Disable ForceRelocateImages})

IMPORTANT NOTES (for consideration):

  • This will NEVER be needed for non-64-bit versions of Windows (but who is still using 32-bit Windows, right?...)
  • It's ONLY necessary for 64-bit versions of Windows 10 (or Windows 7/8/8.1 with a recent EMET) that has the Force randomization for images (Mandatory ASLR) option in the On by default System-Wide Setting (Or something Equivalent by other Security Suite's Vendors)
  • ForceRelocateImage (AKA "Mandatory ASLR") is the only Mitigation that has to be explicitly -Disabled --> Without this Mitigation, ASLR will NOT be Enforced since the Applications don't "request" it (like the ones prepared for it do) --> Without ASLR, the other Mitigations @acinnes -Disabled there - BottomUp,HighEntropy - aren't necessary since they're NOT "applicable" since they're ASLR-Enhancing (further in-depth) Mitigations.

I'll include a "ScreenShot" of the "System Settings" Tab of the "Exploit Protection" Section of the "Windows Security Center" System App (Windows 10 x64 - Version 1803 - Build 17134.228 - Full Build/Version Name 17134.rs4_release.180410-1804) just for good measure - though it also explains a bit about these settings --> if it has "ASLR" in the Mitigation Name, it won't apply if there's NO "ASLR" applied to a Process/Application/Executable.

Windows Security Center - Exploit Protection

Cheers.

EDIT

Here's some

  • Handy,
  • Handmade,
  • Brand-New,
  • "Double-Click"able,
  • Step-by-Step Self-Explained/Documented
    PowerShell Script Files!.

Just make sure the "$installPath" variable (near the top of the Script) Points to the "Right Path" and Change the extension by removing the ".txt" at the end... (should be ".ps1" after that...)

MSys64 - Default Path .ps1.txt
Git for Windows 64-Bit - Default Path .ps1.txt

Bye then.

@TheBestF22
Copy link

TheBestF22 commented Sep 8, 2018

@gamitech

While not a bad attempt...

With the Latest Versions of both Windows (Upgrades + Updates) and Git (for Windows) (which obviously includes an Updated MSys2/MinTTY), if the System-Wide Setting of Mandatory ASLR is in the On by default Option (for Security reasons, etc.), it's "more the exception than the rule":

  • it's rare the executable in the C:\Program Files\Git\usr\bin\ Path/Folder that doesn't need to be added to the "Exceptions List" and the "Windows Security Center" App is just awful/dreadful to add 200+ ".exe"s and change the Mitigations Overrides, one by one...

(apparently this "Bug" has something to do with with direct references/accesses to msys-2.0.dll's "Image-based entry point Memory Addresses" -- instead of the more Normalized and almost/mostly obligatory way of loading DLLs by way of the several "Windows API"s... Probably a side effect of some Cross-Compiling/Assembling/Linking Tools used in the process of "Porting" the code to Windows... And not really a problem unless those "Addresses" are "Randomised" -- as per what "ASLR", "Address Space Layout Randomisation", is ALL About after all...)

Example of a VERY SIMPLE ASLR with a Google Search Link:

(Note: in a good ASLR implementation EVERYTHING moves around, not just the `Code´...)

ASLR

Cheers!.

@mintty
Copy link
Owner

mintty commented Sep 10, 2018

In the latter case, mintty is not even involved (starting bash directly from a shortcut)! Even if it were, it would not be a mintty issue if it happens inside the shell.

@TheBestF22
Copy link

TheBestF22 commented Sep 10, 2018 via email

@mintty
Copy link
Owner

mintty commented Sep 11, 2018

I appreciate your script and additional explanations, for anyone interested in the background. I do not have the capacity to study it fully myself right now. If you'd like to contribute further, the following would be great:

  • (as I outlined in my previous response to you) a more generic script that can be started from either of cygwin, msys, git-for-windows, whereever installed
  • as the command still does not run for me after the $_ fix, and Mandatory ASLR is disabled in my Windows, which might be related, some error handling in the script that handles this with a proper message
  • maybe the ASLR configuration is available at the Windows API? If you find such information, somebody could make a small tool, to be independent from heavy-weight Powershell
  • maybe you or me could then inform the cygwin mailing list about this solution

@user29387
Copy link

Since I posted a couple of days ago, I though I would do a followup, even though the issue doesn't seem connected with mintty.

I generated a couple of null C programs, with this code in each:

int main() {return 0;}

These are 'np1' and 'np2'.

I put the first in a script:

#!/bin/bash
np1
exit 0

and then run the script and the second program using a pipe:

script | np2

This sometimes works, but typically freezes, with a dramatic change with Windows 10 version 1803. The script and pipe seem to be required. The programs do no I/O, and thus the pipe is not actually used.

I tried a lot of things, including peflags/rebase, without any success. One thing that does seem to work is to run the top-level shell as an Administrator. I don't know why this works, but it should be a big hint to someone out there who is more astute than I in the workings of Cygwin and Msys.

The other approach that seems to work is to change the first line of the script to this:

##!/bin/bash

The extra '#' has the effect of making the first line into a comment, and thus the shell invokes a standard tool like /bin/bash or /bin/sh to interpret the script commands. This is conceptually similar to the '#!' notation, but presumably is processed in a somewhat different way.

@deebugz
Copy link

deebugz commented Nov 16, 2018

For anybody who arrives here after trying to install git for windows under Win10 amd64: I'm running all exploit protections plus full software restriction policies. There seems to be some bug in mingw64, and I had to explicitly add the path "C:\Program Files\Git*" to the SRP and set it to unrestricted. Perhaps the installer is using some nonstandard way of specifying file paths.

So, to install git without having to turn of exploit protections and reboot, first, do the install and it will fail after copying all (most?) of the files. Then run the above powershell scripts to disable aslr for the git binaries. Now install git again into the same folder, and it will say that it wasn't able to uninstall the previous installation. Continue, and after the install gets going installing files, you change "C:\Program Files\Git*" to "Unrestricted". That way, at the end of the installation process, git.exe will be able to do things like changing the default editor.

@RvBVakama
Copy link

Avast fix:
Go Avast interface -> settings -> general -> exclusions -> add your folder directory where your "git-bash.exe" lives.

@AnrDaemon
Copy link

For me, this was ADB shell daemon running after one command in terminal.

@jrmoserbaltimore
Copy link

What about fixing the application so it works with the exploit mitigations?

@mutageneral
Copy link

@jrmoserbaltimore

What about fixing the application so it works with the exploit mitigations?

The cygwin people talked about it in this thread : https://sourceware.org/pipermail/cygwin/2020-August/245973.html
Also, the git for windows people talked about implementing all git commands natively without using fork() and more : git-for-windows/git#1412 (comment)

Looking at these it seems like it is a very tough job to do, but we might get it one day.

@aaravrav
Copy link

aaravrav commented Mar 3, 2021

You can just turn of ASLR for all the .exe in GitHub bin, run this script in powershell as admin. You must restart your PC after you have ran. Also replace X with the actual drive letter (probably C).

Get-Item -Path "X:\Program Files\Git\usr\bin*.exe" | %{ Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }

@mintty
Copy link
Owner

mintty commented Mar 3, 2021

Thanks for the suggestion. My first impression was it would help, even without rebooting, but then I had a lot of trouble fiddling with these options, so I'd better not touch them again...

@Biswa96
Copy link
Contributor

Biswa96 commented Mar 3, 2021

There is a recent discussion about it here https://cygwin.com/pipermail/cygwin/2021-February/247922.html. The solution is to disable ASLR option in binutils ld. The issue is only with fork() in cygwin based binaries. mingw toolchain is OK.

@rubenheymans
Copy link

Sure.

I'm using Cygwin x64 on Windows 10 build 1709.

To disable this feature you'll have to:

  • Press Win + S
  • Type in Windows Defender Security Center
  • Click App & browser control
  • Scroll down and click Exploit protection settings
  • Find the Force randomization for images section and select Off by default
  • Reboot

It should be off by default, but i think Microsoft will switch that on by default in the future as more and more programs become compatible.

I got this error when I lost power to my pc, this fixed it for some reason, thanks! So random

@vamshichintu
Copy link

Error: Could not fork child process: Resource temporarily unavailable (-1).
DLL rebasing may be required; see 'rebaseall / rebase --help

@Biswa96
Copy link
Contributor

Biswa96 commented Dec 22, 2022

Try to reinstall wsltty and/or exclude wsltty install directory in antivirus scanning operation.

@iamABHIK123
Copy link

Sure.

I'm using Cygwin x64 on Windows 10 build 1709.

To disable this feature you'll have to:

  • Press Win + S
  • Type in Windows Defender Security Center
  • Click App & browser control
  • Scroll down and click Exploit protection settings
  • Find the Force randomization for images section and select Off by default
  • Reboot

It should be off by default, but i think Microsoft will switch that on by default in the future as more and more programs become compatible.

thankxx a ton

@jrmst28
Copy link

jrmst28 commented Jun 7, 2024

I don't know where else to put this. I'm a noob so I hope this even makes sense, and maybe helps someone. I tried all of the tips I could find about disabling ASLR. I tried globally, and then I tried for selected git exe's, and then I tried for all of the git exe's. Still got the git bash startup error. Tried reinstalling Git. No luck.

Finally I tried running the installer as admin. This is what worked. It installed git under my admin profile, but it now works for my regular profile too.

@mintty
Copy link
Owner

mintty commented Jun 7, 2024

You're posting this in the wsltty repository but you mention Git. Please describe your environment (Git for Windows?).
Also, which mintty version do you run? (Options - About)

@Aminnak
Copy link

Aminnak commented Oct 21, 2024

Sure.

I'm using Cygwin x64 on Windows 10 build 1709.

To disable this feature you'll have to:

  • Press Win + S
  • Type in Windows Defender Security Center
  • Click App & browser control
  • Scroll down and click Exploit protection settings
  • Find the Force randomization for images section and select Off by default
  • Reboot

It should be off by default, but i think Microsoft will switch that on by default in the future as more and more programs become compatible.

Bro I love youuu you're such a life saver!.I was getting crazy by this error ,it took me 2 days and still couldnt fix it.ThanQ man.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests