Skip to content

Allow false autorelease to set unmanaged = true#6331

Merged
headius merged 1 commit intojruby:jruby-9.2from
headius:fix_unmanaged_memory
Jul 16, 2020
Merged

Allow false autorelease to set unmanaged = true#6331
headius merged 1 commit intojruby:jruby-9.2from
headius:fix_unmanaged_memory

Conversation

@headius
Copy link
Member

@headius headius commented Jul 16, 2020

This appears to be long-broken logic for setting autorelease to false, since the only value that will change the unmanaged bit is passing autorelease = true. The change here allows toggling both ways.

This may not have been seen before because this version of MemoryIO is only used when the requested size is greater than 256 bytes, and typically structs are smaller than that. In #6284, as well as #6310 and sass/sassc-ruby#208, we have reports of a double free, and sassc itself uses autorelease on a potentially large value here:

https://github.com/sass/sassc-ruby/blob/4bd764f568ad312a78181d7a3187f3715388e33e/lib/sassc/native.rb#L54-L58

This appears to be long-broken logic for setting autorelease to
false, since the only value that will change the unmanaged bit is
passing autorelease = true. The change here allows toggling both
ways.

This may not have been seen before because this version of
MemoryIO is only used when the requested size is greater than 256
bytes, and typically structs are smaller than that. In jruby#6284, as
well as jruby#6310 and sass/sassc-ruby#208, we have reports of a double
free, and sassc itself uses autorelease on a potentially large
value here:

https://github.com/sass/sassc-ruby/blob/4bd764f568ad312a78181d7a3187f3715388e33e/lib/sassc/native.rb#L54-L58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rails: After migration from ruby to jruby, app is not booting FFI::MemoryPointer autorelease issue

1 participant