Remove shared libraries before copying them into place
authorJustin Li <jli.justinli@gmail.com>
Tue, 7 Oct 2014 16:41:27 +0000 (12:41 -0400)
committerJustin Li <jli.justinli@gmail.com>
Tue, 7 Oct 2014 16:41:27 +0000 (12:41 -0400)
commitffa21165f6df292531cf01138df9b7852cdb34d9
tree04c447af5e5ba5f8942e6cec59e2a4051e2bbb18
parent942dc0b42bfe3c61e44aa29d5b9c2755069be3c1
Remove shared libraries before copying them into place

Fixes issue #1037

When building an extension that's still loaded into memory, cp_r replaces the
file contents of the same inode. Since Linux mmaps shared libs, they will get
reloaded but not relocated, leading to corruption of the GOT/PLT.

The fix is to unlink the destination before copying, which creates a new inode
and prevents the file from being reloaded.
lib/rubygems/ext/ext_conf_builder.rb