Re: Bug#816077: ruby2.3: FTBFS on m68k - Segmentation fault at 0x5f583332
Hi!
Here's an updated patch which contains the actual changes that upstream
committed to the git repository to close the upstream bug 12118 [1].
Would be possible to cherry-pick this fix from upstream until the
changes have been backported to ruby2.3? I'd be happy to perform
an NMU as well to fix the issue. I assume that should be okay since
ruby2,3 is LowNMU?
Attaching the updated and cleaned up patch in any case.
Adrian
> [1] https://bugs.ruby-lang.org/issues/12118
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - glaubitz@debian.org
`. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Description: Cherry-picked updates for upstream bug 12118
Upstream has improved the stack allocator and fixed the function
prototype for rb_locale_charmap_index in localeinit.c. Both changes
are necessary to fix the build on m68k.
Upstream bug: https://bugs.ruby-lang.org/issues/12118
Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=816077
.
--- ruby2.3-2.3.0.orig/localeinit.c
+++ ruby2.3-2.3.0/localeinit.c
@@ -89,7 +89,7 @@ enc_find_index(const char *name)
}
int
-rb_locale_charmap_index(VALUE klass)
+rb_locale_charmap_index(void)
{
return (int)locale_charmap(enc_find_index);
}
--- ruby2.3-2.3.0.orig/thread_pthread.c
+++ ruby2.3-2.3.0/thread_pthread.c
@@ -690,17 +690,31 @@ reserve_stack(volatile char *limit, size
const volatile char *end = buf + sizeof(buf);
limit += size;
if (limit > end) {
- size = limit - end;
- limit = alloca(size);
- limit[stack_check_margin+size-1] = 0;
+ /* |<-bottom (=limit(a)) top->|
+ * | .. |<-buf 256B |<-end | stack check |
+ * | 256B | =size= | margin (4KB)|
+ * | =size= limit(b)->| 256B | |
+ * | | alloca(sz) | | |
+ * | .. |<-buf |<-limit(c) [sz-1]->0> | |
+ */
+ size_t sz = limit - end;
+ limit = alloca(sz);
+ limit[sz-1] = 0;
}
}
else {
limit -= size;
if (buf > limit) {
- limit = alloca(buf - limit);
- limit[0] = 0; /* ensure alloca is called */
- limit -= stack_check_margin;
+ /* |<-top (=limit(a)) bottom->|
+ * | .. | 256B buf->| | stack check |
+ * | 256B | =size= | margin (4KB)|
+ * | =size= limit(b)->| 256B | |
+ * | | alloca(sz) | | |
+ * | .. | buf->| limit(c)-><0> | |
+ */
+ size_t sz = buf - limit;
+ limit = alloca(sz);
+ limit[0] = 0;
}
}
}
Reply to: