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

Remove shared libraries before copying them into place #1038

Merged
merged 1 commit into from Nov 30, 2014

Conversation

pushrax
Copy link
Contributor

@pushrax pushrax commented Oct 7, 2014

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.

A test for this would be fairly complicated, but if necessary I can add one.

@dylanahsmith @camilo @csfrancis

Fixes issue rubygems#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.
@camilo
Copy link

camilo commented Oct 7, 2014

👍 tried on liquid-c right ?

@pushrax
Copy link
Contributor Author

pushrax commented Oct 7, 2014

@camilo yep, fixes the issue.

@tenderlove
Copy link
Contributor

Patch looks good to me! 👍

@drbrain drbrain added this to the 2.5 milestone Nov 30, 2014
drbrain added a commit that referenced this pull request Nov 30, 2014
Remove shared libraries before copying them into place
@drbrain drbrain merged commit edd595d into rubygems:master Nov 30, 2014
drbrain added a commit that referenced this pull request Nov 30, 2014
@pushrax pushrax deleted the fix-ext-reloading-segfault branch November 30, 2014 23:40
@pushrax pushrax restored the fix-ext-reloading-segfault branch June 25, 2018 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants