From: George Koehler Date: 2012-01-31T06:28:31+09:00 Subject: [ruby-core:42275] [ruby-trunk - Bug #5901] OpenBSD "[FATAL] failed to allocate memory" Issue #5901 has been updated by George Koehler. File smaller-heap-3.diff added I reverted my own changes. Then I tried to apply patch by Narihiro Nakamura, but I got patch conflict with svn r34399. After I solved conflict, I can compile and run Ruby, 'make test' passes all tests, and 'make test-all' has 0 failures and 0 errors. My system is OpenBSD 5.0/amd64. After I solved conflict, patch looks like this: Index: configure.in =================================================================== --- configure.in (revision 34399) +++ configure.in (working copy) @@ -1292,7 +1292,12 @@ CFLAGS="$save_CFLAGS"]) AC_DEFINE_UNQUOTED(GC_MARK_STACKFRAME_WORD, $rb_cv_gc_mark_stackframe_word) +AS_CASE(["$target_os"], +[openbsd*], [ + AC_DEFINE_UNQUOTED(HEAP_ALIGN_LOG, 12) + ]) + dnl Checks for library functions. AC_TYPE_GETGROUPS AC_TYPE_SIGNAL Index: gc.c =================================================================== --- gc.c (revision 34399) +++ gc.c (working copy) @@ -536,8 +536,11 @@ } #endif -/* tiny heap size: 16KB */ +#ifndef HEAP_ALIGN_LOG +/* default tiny heap size: 16KB */ #define HEAP_ALIGN_LOG 14 +#endif + #define HEAP_ALIGN (1UL << HEAP_ALIGN_LOG) #define HEAP_ALIGN_MASK (~(~0UL << HEAP_ALIGN_LOG)) #define REQUIRED_SIZE_BY_MALLOC (sizeof(size_t) * 5) ---------------------------------------- Bug #5901: OpenBSD "[FATAL] failed to allocate memory" https://bugs.ruby-lang.org/issues/5901 Author: George Koehler Status: Assigned Priority: Normal Assignee: Narihiro Nakamura Category: Target version: ruby -v: ruby 2.0.0dev (2012-01-16 trunk 34316) [x86_64-openbsd5.0] =begin Ruby trunk fails to build with OpenBSD. During the build, miniruby fails with message [FATAL] failed to allocate memory OpenBSD has a broken posix_memalign(). Ruby fails in gc.c, because posix_memalign() fails and aligned_malloc() returns NULL. OpenBSD's manual for posix_memalign (()) says: BUGS Only alignments up to the page size can be specified. Ruby wants alignment of 16 kilobytes, but my page size is only 4 kilobytes. I tried to edit gc.c. My first attempt (bad-fix-never-apply.diff) was good enough to build Ruby, but it did not always work, and some tests failed. So I reverted gc.c and tried again. My second attempt (smaller-heap-for-openbsd.diff) was much simpler. I changed the values of HEAP_ALIGN*, shrinking the heap size from 16 kilobytes to 4 kilobytes, which is not larger than my page size. More tests pass. The only failures in 'make test' are in bootstraptest/test_thread.rb. Those tests seem to create an infinite loop in Ruby, and I needed to kill -9 those processes. Some tests in 'make test-all' failed the same way, with the infinite loop. =end -- http://bugs.ruby-lang.org/