basyura's blog

あしたになったらほんきだす。

unable to remap

windows7 + cygwin + rvm の組み合わせにしてから出始めた unable to remap

446892 [main] ruby 9992 fork: child 8044 - died waiting for dll loading, errno 11
4511203 [main] ruby 10036 C:\cygwin\home\Administrator\.rvm\rubies\ruby-1.9.2-p180\bin\ruby.exe: 
*** fatal error - unable to remap \\?\C:\cygwin\home\Administrator\.rvm\rubies\ruby-1.9.2-p180
\lib\ruby\1.9.1\i386-cygwin\etc.so 
to same address as parent: 0x330000 != 0x3B0000
Stack trace:
Frame     Function  Args
00228698  6102796B  (00228698, 00000000, 00000000, 00000000)
00228988  6102796B  (6117EC60, 00008000, 00000000, 61180977)
002299B8  61004F1B  (611A7FAC, 6124587C, 00330000, 003B0000)
End of stack trace

少しググると、cmd.exe から

run ash rebaseall -v

すれば直るよ記事がヒットするのだけどうまくいかず。
どうも、単純にコマンドを打つだけでは rvm で入れた環境を認識してくれないらしい。

rebaseall does not know about any DLLs or SOs they install.
But it is possible to provide a list of objects that need to be rebased
in addition to the default list when you run rebaseall.

unable to remap to same address as parent - despite rebaseall

修正方法

cygwin にログインして、.rvm フォルダ配下の so ファイル一覧を適当な場所に作る。

find ~/.rvm -iname '*.so' > /tmp/ruby.gems.local.so.lst 

cygwin で動かしているプロセスやサービスを全て停止してターミナルも閉じる。
cmd.exe を起動して、生成した so リストのファイルを指定して rebaseall を実行する($CYGWIN_HOME を cygwin のインストールフォルダとする)。ファイルのパスは windows 上のパスではなくて cygwin 上のパスを指定するのがポイント。

cd $CYGWIN_HOME/bin
run ash rebaseall -T /tmp/ruby.gems.local.so.lst -v

するとログが流れ始める。

/home/Administrator/.rvm/src/ruby-1.9.2-p180/.ext/i386-cygwin/stringio.so: new base =679c0000, new size = 20000
/home/Administrator/.rvm/src/ruby-1.9.2-p180/.ext/i386-cygwin/strscan.so: new base = 679a0000, new size = 20000
/home/Administrator/.rvm/src/ruby-1.9.2-p180/.ext/i386-cygwin/syck.so: new base = 67960000, new size = 40000
/home/Administrator/.rvm/src/ruby-1.9.2-p180/.ext/i386-cygwin/syslog.so: new base = 67940000, new size = 20000
/home/Administrator/.rvm/src/ruby-1.9.2-p180/.ext/i386-cygwin/win32ole.so: new base =67910000, new size = 30000
/home/Administrator/.rvm/src/ruby-1.9.2-p180/.ext/i386-cygwin/zlib.so: new base = 678e0000, new size = 30000
・・・・

ログが止まったら Enter を押下すれば入力に戻るので、終了。
cygwin のターミナルを立ち上げて Ruby プログラムを実行しても問題なし!

さらば unable to remap