Tuesday, April 21, 2009

*** fatal error - unable to remap to same address as parent : Cygwin, Ruby on Rails, System calls


I was trying to run system commands from the Ruby console in my Cygwin environment today (since that's part of how I'm integrating with Python). I was running into a helluva problem. I was getting a fatal error, unable to remap .dll to same address as parent. It took a while to track this down and even longer to actually figure out what is happening.

Let me tell you what you can do if you don't care what's actually happening.

1) Close out of Cygwin (and all cygwin processes).
2) Open a Windows command prompt (start -> run - > type 'cmd' or on vista : start -> type 'cmd' in the start search window)
3) Go to your cygwin bin directory. For me it is c:\cygwin\bin.
4) Type ash
5) Type '/usr/bin/rebaseall'
6) Resolve any errors (I had a warning that went unresolved and it still worked fine)
7) Reboot...and you should be good.

So what actually is happening? Well, in this case, the problem was a result of the way windows manages their .dll's. Windows uses ASLR (address space layout randomization) to manage its .dll's. It loads your dll's into different areas of memory every time you boot your computer. If this gets out of whack then the next time you look for that .dll - you can crash your system. Or if you look in the wrong place, you can crash your system. So how can this system get out of whack? Well, running your cygwin setup program can affect record keeping, especially if the ASLR has changed but Cygwin is holding on to an older copy (this can happen when setup doesn't complete).

ASLR is great for malware or hacker defense. Hackers can't constantly try new addresses for your .dll's without crashing your system.

37 comments:

Sam Stokes said...

This post helped me out - thanks! I was getting the same error running "git svn" on Cygwin under Vista, and found this via Google. The fix worked and the explanation was useful.

Anonymous said...

Thanks, this helped me out! I was having a problem with svn.

Jim Goltz said...

This eliminates that problem, but now Emacs won't start.

sha said...

Thanks! I also had problems with svn in cygwin, and doing this fixed it. In my case however, it took 2 reboots to fix all problems though.

Gregory said...

Thank you! Your post saved me a good half hour of screwing around with the cygwin installer again.

Having run into this before I'm certain I will see it again.

Again, great info!

P.S. Didn't take a reboot to address my issue -- well... so far anyway :)

Anonymous said...

thx man!

Brandon Thomson said...

Worked perfectly... but I hope I don't have to do this often! Got this 30 minutes after my first cygwin install :(

Anonymous said...

worked perfectly thanks, life saver.

Unknown said...

This looked really good until I ran it and got:

$ /usr/bin/rebaseall
ReBaseImage (/usr/lib/perl5/5.10/i686-cygwin/auto/Compress/Raw/Bzip2.dll)
failed with last error = 6

I don't have a clue what I need to do to resolve this.

Bimme said...

I've got the same problem as Scott, has anyone got a solution for this?

Chris said...

It worked! Thank you very much!

Kip said...

Thanks! This solved my problem running a django tutorial using Cygwin.

Anonymous said...

Thanks! This helped me get a working Python2.6 install in Cygwin.

Anonymous said...

Thanks! That completely fixed my issue.

mikew said...

Outstanding, thanks. Needed these steps to get python installed.

Anonymous said...

Thanks a lot! Your article helped to resolve the problem.

Max

Anonymous said...

Just to add to the +1s - yes, this works.

I also noticed that if your TMP variable points to a directory that doesn't exist or can't be written to that creates a problem.

Just type in TMP= at the prompt to solve this.

Nate said...

Thanks! Solved a problem with python!

Anonymous said...

This was a big help. Thanks!

Roman said...

Thanks a lot. I have tried to solve the problem for a hour already :)

eGaTS said...

I'm getting the same error with the WLMP 1.4.28-1 package. I tried the rebaseall, and it seemed to complete successfully (returned me to the prompt with no errors), then rebooted twice. Still getting the same remap error. If I run lighttpd with the -D parameter it does not produce this error and the server runs smoothly, but that isn't really a solution. Are there further steps I can take to troubleshoot this?

Anonymous said...

Thank you sir, you are a true gentleman.

Anonymous said...

I second that. Much obliged Sir!

Anonymous said...

You are a god among men, sir.
This saved our asses today; thanks a lot!

msl said...

Thanks!

Unknown said...

Wow, this fixed my issue like magic!!!

THANKS!!!

I saw this error the very first time I ran my script, but never seen it again

cygwin warning:
MS-DOS style path detected: %CommonProgramFiles%\System\ado\msado20.tlb
Preferred POSIX equivalent is: %CommonProgramFiles%/System/ado/msado20.tlb
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

Anonymous said...

@Scott with that Bzip2.dll it probably needs to have write permissions. I fix min by chmod 755 on the file. Exit shell, rebaseall again, now change Zlib.dll, etc.

Anonymous said...

thanks a lot, very helpful. clicked a few of your ads.

Ɓukasz Wachowicz said...

Great man ! Thanks a lot for this article.

Alejandra S said...

Nice post but what happens when, while trying 'rebaseall' you get all dll files giving errors stating "skipped because not writable"? My problem is I really have no admin access at all.

Brett said...

Thanks a ton, very helpful to explain what's going on as well as the fix.

Jim Van Zandt said...

The first several times I tried this, I got "rebaseall: only ash or dash processes are allowed during rebasing", even though I thought I'd stopped everything. I finally discovered I could use "./ps" to list the Cygwin processes, which included one bash process besides the ash I knew about. I don't know where it was - I could find no such window. kill failed. But the Windows task manager let me kill it. Then rebaseall worked.

James Star said...

Sweeet, thanks! Massive help :)

Mark said...

Thanks for the info... fixed my issue with Cygwin, Ruby and Rake.

Anonymous said...

thank you for taking the time to post this info. this made all the difference.

Anonymous said...

Can we automate this using shell script ? I need help to automate cygwin rebasing if anyone have any idea or script that would be greatly appreciated

Steven Gardiner said...

Great solution! Thanks!