blob: 3b56273dd8405d3ba442be07e627009ca1b684f6 [file] [log] [blame] [view]
andybons3322f762015-08-24 21:37:091Handling repeated failures of rebaseall to allow cygwin remaps
2
3# Introduction
4
5Sometimes DLLs over which cygwin has no control get mapped into cygwin
6processes at locations that cygwin has chosen for its libraries.
7This has been seen primarily with anti-virus DLLs. When this occurs,
8cygwin must be instructed during the rebase to avoid the area of
9memory where that DLL is mapped.
10
11# Background
12
13Some background for this is available on http://www.dont-panic.cc/capi/2007/10/29/git-svn-fails-with-fatal-error-unable-to-remap/
14
15Because of unix fork semantics (presumably), cygwin libraries must be
16mapped in the same location in both parent and child of a fork. All
17cygwin libraries have hints in them as to where they should be mapped
18in a processes address space; if those hints are followed, each
19library will be mapped in the same location in both address spaces.
20However, Windows is perfectly happy mapping a DLL anywhere in the
21address space; the hint is not considered controlling. The remapping
22error occurs when a cygwin process starts and one of its libraries
23cannot be mapped to the location specified by its hint.
24
25/usr/bin/rebaseall changes the DLL hints for all of the cygwin
26libraries so that there are no inter-library conflicts; it does this
27by choosing a contiguous but not overlapping library layout starting
28at a base address and working down. This process makes sure there are
29no intra-cygwin conflicts, but cannot deal with conflicts with
30external DLLs that are in cygwin process address spaces
31(e.g. anti-virus DLLs).
32
33To handle this case, you need to figure out what the problematic
34non-cygwin library is, where it is in the address space, and do the
35rebase all so that no cygwin hints map libraries to that location.
36
37# Details
38
39<ul>
40<li>Download the ListDLLs executable from sysinternals<br>
41(<a href='http://technet.microsoft.com/en-us/sysinternals/bb896656.aspx'>http://technet.microsoft.com/en-us/sysinternals/bb896656.aspx</a>)</li>
42<li>Run it as administrator while some cygwin commands are running.</li>
43<li>Scan the output for the cygwin process (identifiable by the command) and for DLLs in that process that do not look like cygwin DLLs (like an AV). Note the location of those libraries (there will usually only be the one). Pick an address space location lower than its starting address.</li>
44<li>Quit all cygwin processes.</li>
45<li>Run a windows command shell as administrator</li>
46<li>cd in \cygwin\bin</li>
47<li>Run "ash /usr/bin/rebaseall -b <base address>" (This command can also take a "-v" flag if you want to see the DLL layout.)</li>
48</ul>
49
50
51That should fix the problem.
52
53# Failed rebaseall
54
55If you pick a base address that is too low, you may end up with a broken cygwin install. You can reinstall it by running cygwin's setup.exe again, and on the package selection page, clicking the "All" entry to Reinstall. You may have to do this twice, as you may get errors on the first reinstall pass.