diff options
author | Aaron Patterson <[email protected]> | 2021-05-25 16:20:52 -0700 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2021-05-25 17:37:21 -0700 |
commit | fc832ffbfaf581ff63ef40dc3f4ec5c8ff39aae6 (patch) | |
tree | ac528ef22bbf535b005956d6d813cc36ddcd4500 /gc.c | |
parent | 2a29a5311ce34bcbd0186455df2d5b724dcc501c (diff) |
Disable compaction on platforms that can't support it
Manual compaction also requires a read barrier, so we need to disable
even manual compaction on platforms that don't support mprotect.
[Bug #17871]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4528
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -9998,6 +9998,24 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data) static VALUE gc_compact(rb_execution_context_t *ec, VALUE self) { +#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) + /* If Ruby's heap pages are not a multiple of the system page size, we + * cannot use mprotect for the read barrier, so we must disable compaction. */ + int pagesize; + pagesize = (int)sysconf(_SC_PAGE_SIZE); + if ((HEAP_PAGE_SIZE % pagesize) != 0) { + rb_raise(rb_eNotImpError, "Compaction isn't available on this platform"); + } +#endif + + /* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for + * the read barrier, so we must disable compaction. */ +#if !defined(__MINGW32__) && !defined(_WIN32) + if (!USE_MMAP_ALIGNED_ALLOC) { + rb_raise(rb_eNotImpError, "Compaction isn't available on this platform"); + } +#endif + /* Run GC with compaction enabled */ gc_start_internal(ec, self, Qtrue, Qtrue, Qtrue, Qtrue); |