Project

General

Profile

Actions

Bug #17652

closed

GC compaction crash on mprotect

Added by peterzhu2118 (Peter Zhu) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:102585]

Description

GitHub PR: https://github.com/ruby/ruby/pull/4221 https://github.com/ruby/ruby/pull/4227

Issue

GC compaction will crash on some pages due to a failing mprotect call. According to the mprotect documentation:

POSIX says that the behavior of mprotect() is unspecified if it is applied to a region of memory that was not obtained via mmap(2).

This causes mprotect to sometimes fail.

Reproduction

GC.auto_compact = true

times = 20_000_000
arr = Array.new(times)
times.times do |i|
  arr[i] = "#{i}"
end

arr = Array.new(1_000_000, 42)
GC.start

puts "ok"

Expected output

Program runs and prints "ok".

Actual output

Crashes on Ubuntu 18.04. See crash.log for the crash log (note that the log file has been truncated because it's too big).


Files

crash.log (6.26 KB) crash.log peterzhu2118 (Peter Zhu), 02/23/2021 09:34 PM
ruby-cygwin-rb_aligned_malloc.patch (840 Bytes) ruby-cygwin-rb_aligned_malloc.patch xtkoba (Tee KOBAYASHI), 02/27/2021 12:13 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0