From: xtkoba+ruby@... Date: 2021-02-26T01:23:26+00:00 Subject: [ruby-core:102612] [Ruby master Bug#17652] GC compaction crash on mprotect Issue #17652 has been updated by xtkoba (Tee KOBAYASHI). Changes made for this issue seem to break the Cygwin builds (for both i686 and x86_64). A backtrace for `miniruby` (without any options) from GDB: ``` Thread 1 received signal SIGSEGV, Segmentation fault. heap_page_allocate (objspace=0x800053110) at ../gc.c:1883 1883 page_body->header.page = page; (gdb) bt #0 heap_page_allocate (objspace=0x800053110) at ../gc.c:1883 #1 heap_page_create (objspace=0x800053110) at ../gc.c:1923 #2 heap_assign_page (objspace=objspace@entry=0x800053110, heap=heap@entry=0x800053138) at ../gc.c:1948 #3 0x0000000100467ef1 in heap_add_pages (objspace=objspace@entry=0x800053110, heap=heap@entry=0x800053138, add=24) at ../gc.c:1961 #4 0x00000001004681be in Init_heap () at ../gc.c:3190 #5 0x000000010045653b in ruby_setup () at ../eval.c:87 #6 0x0000000000000000 in ?? () (gdb) p page_body $1 = (struct heap_page_body *) 0x6fffffee4000 (gdb) p *page_body Cannot access memory at address 0x6fffffee4000 (gdb) ``` I have not yet started to investigate what is wrong. ---------------------------------------- Bug #17652: GC compaction crash on mprotect https://bugs.ruby-lang.org/issues/17652#change-90600 * Author: peterzhu2118 (Peter Zhu) * Status: Open * Priority: Normal * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- # 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 ```ruby 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) -- https://bugs.ruby-lang.org/ Unsubscribe: