Commits (14)
tarball=gc-VERSION.tar.gz
sha1=f4d079bd4e5ecc1f1eba2fd9a7220da42b1f8dc5
md5=37edd40ebd0b4fe9ce13d27fcf4e5902
cksum=3026257534
sha1=55fc1fe8e0d81acdf6cc29455b151ab74c77c4f2
md5=66854af096fcd23b97dd7e1b829215c0
cksum=960172039
# no dependencies
libatomic_ops
----------
All lines of this file are ignored except the first.
......
On Cygwin, use mprotect to set PROT_NONE on a memory-mapped region, instead
of trying to reuse mmap on an existing region, which breaks. Use the
allocation granularity for determining allocation sizes/offsets, rather
than the actual page size (as Cygwin itself does). See
https://trac.sagemath.org/ticket/23973
diff --git a/os_dep.c b/os_dep.c
index e6283ac..a1bb9e4 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -698,7 +698,11 @@ GC_INNER word GC_page_size = 0;
GC_INNER void GC_setpagesize(void)
{
GetSystemInfo(&GC_sysinfo);
- GC_page_size = GC_sysinfo.dwPageSize;
+# if defined(CYGWIN32) && defined(USE_MUNMAP)
+ GC_page_size = GC_sysinfo.dwAllocationGranularity;
+# else
+ GC_page_size = GC_sysinfo.dwPageSize;
+# endif
# if defined(MSWINCE) && !defined(_WIN32_WCE_EMULATION)
{
OSVERSIONINFO verInfo;
@@ -2404,12 +2408,18 @@ GC_INNER void GC_unmap(ptr_t start, size_t bytes)
/* We immediately remap it to prevent an intervening mmap from */
/* accidentally grabbing the same address space. */
{
- void * result;
- result = mmap(start_addr, len, PROT_NONE,
- MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
- zero_fd, 0/* offset */);
- if (result != (void *)start_addr)
- ABORT("mmap(PROT_NONE) failed");
+# ifdef CYGWIN32
+ if (mprotect(start_addr, len, PROT_NONE))
+ ABORT("mprotect(PROT_NONE) failed");
+# else
+ void * result;
+
+ result = mmap(start_addr, len, PROT_NONE,
+ MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
+ zero_fd, 0/* offset */);
+ if (result != (void *)start_addr)
+ ABORT("mmap(PROT_NONE) failed");
+# endif
}
GC_unmapped_bytes += len;
# endif
@@ -2515,13 +2525,18 @@ GC_INNER void GC_unmap_gap(ptr_t start1, size_t bytes1, ptr_t start2,
}
# else
if (len != 0) {
+# ifdef CYGWIN32
+ if (mprotect(start_addr, len, PROT_NONE))
+ ABORT("mprotect(PROT_NONE) failed");
+# else
/* Immediately remap as above. */
- void * result;
- result = mmap(start_addr, len, PROT_NONE,
- MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
- zero_fd, 0/* offset */);
- if (result != (void *)start_addr)
- ABORT("mmap(PROT_NONE) failed");
+ void * result;
+ result = mmap(start_addr, len, PROT_NONE,
+ MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
+ zero_fd, 0/* offset */);
+ if (result != (void *)start_addr)
+ ABORT("mmap(PROT_NONE) failed");
+# endif
}
GC_unmapped_bytes += len;
# endif
--
2.8.3
From dd2044eefdd01d58863eef3a49789ed962eaeec3 Mon Sep 17 00:00:00 2001
From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
Date: Mon, 12 Sep 2016 00:14:17 -0700
Subject: [PATCH] Workaround missing getcontext() in Docker osrf/ubuntu_32bit
* mach_dep.c [NO_GETCONTEXT] (GC_with_callee_saves_pushed): Call WARN
instead of ABORT if getcontext() failed; do not set context variable
if getcontext() failed; fallback to other register retrieval methods
(__builtin_unwind_init or setjmp) if context variable is NULL.
* mach_dep.c (GC_with_callee_saves_pushed): Reformat code.
(Backported from a62e6fc5808e8f4739adb842ec55958acfbdb338.
From: Ivan Maidanski <ivmai@mail.ru>
Date: Thu, 11 Aug 2016 11:56:44 +0300)
---
mach_dep.c | 59 +++++++++++++++++++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 26 deletions(-)
diff --git a/mach_dep.c b/mach_dep.c
index a4cf08f..3d51cca 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -190,9 +190,10 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
volatile int dummy;
void * context = 0;
-# if defined(HAVE_PUSH_REGS)
+# if defined(HAVE_PUSH_REGS)
GC_push_regs();
-# elif defined(UNIX_LIKE) && !defined(NO_GETCONTEXT)
+# else
+# if defined(UNIX_LIKE) && !defined(NO_GETCONTEXT)
/* Older versions of Darwin seem to lack getcontext(). */
/* ARM and MIPS Linux often doesn't support a real */
/* getcontext(). */
@@ -204,13 +205,20 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
/* We manipulate FPU control word here just not to force the */
/* client application to use -lm linker option. */
unsigned short old_fcw;
+
__asm__ __volatile__ ("fstcw %0" : "=m" (*&old_fcw));
# else
int except_mask = fegetexcept();
# endif
# endif
- if (getcontext(&ctxt) < 0)
- ABORT ("getcontext failed: Use another register retrieval method?");
+
+ if (getcontext(&ctxt) < 0) {
+ WARN("getcontext failed:"
+ " using another register retrieval method...\n", 0);
+ /* E.g., to workaround a bug in Docker ubuntu_32bit. */
+ } else {
+ context = &ctxt;
+ }
# ifdef GETCONTEXT_FPU_EXCMASK_BUG
# ifdef X86_64
__asm__ __volatile__ ("fldcw %0" : : "m" (*&old_fcw));
@@ -226,25 +234,22 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
if (feenableexcept(except_mask) < 0)
ABORT("feenableexcept failed");
# endif
-# endif
- context = &ctxt;
+# endif /* GETCONTEXT_FPU_EXCMASK_BUG */
# if defined(SPARC) || defined(IA64)
/* On a register window machine, we need to save register */
/* contents on the stack for this to work. This may already be */
/* subsumed by the getcontext() call. */
GC_save_regs_ret_val = GC_save_regs_in_stack();
-# endif /* register windows. */
-# elif defined(HAVE_BUILTIN_UNWIND_INIT) \
- && !(defined(POWERPC) && defined(DARWIN)) \
- && !(defined(I386) && defined(RTEMS))
- /* This was suggested by Richard Henderson as the way to */
- /* force callee-save registers and register windows onto */
- /* the stack. */
- /* Mark Sibly points out that this doesn't seem to work */
- /* on MacOS 10.3.9/PowerPC. */
- __builtin_unwind_init();
-# else /* !HAVE_BUILTIN_UNWIND_INIT && !UNIX_LIKE */
- /* && !HAVE_PUSH_REGS */
+# endif
+ if (NULL == context) /* getcontext failed */
+# endif /* !NO_GETCONTEXT */
+ {
+# if defined(HAVE_BUILTIN_UNWIND_INIT)
+ /* This was suggested by Richard Henderson as the way to */
+ /* force callee-save registers and register windows onto */
+ /* the stack. */
+ __builtin_unwind_init();
+# else
/* Generic code */
/* The idea is due to Parag Patel at HP. */
/* We're not sure whether he would like */
@@ -267,14 +272,16 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
/* SUSV3, setjmp() may or may not save signal mask. */
/* _setjmp won't, but is less portable. */
# endif
-# endif /* !HAVE_PUSH_REGS ... */
- /* FIXME: context here is sometimes just zero. At the moment the */
- /* callees don't really need it. */
- fn(arg, context);
- /* Strongly discourage the compiler from treating the above */
- /* as a tail-call, since that would pop the register */
- /* contents before we get a chance to look at them. */
- GC_noop1((word)(&dummy));
+# endif /* !HAVE_BUILTIN_UNWIND_INIT */
+ }
+# endif /* !HAVE_PUSH_REGS */
+ /* FIXME: context here is sometimes just zero. At the moment the */
+ /* callees don't really need it. */
+ fn(arg, context);
+ /* Strongly discourage the compiler from treating the above */
+ /* as a tail-call, since that would pop the register */
+ /* contents before we get a chance to look at them. */
+ GC_noop1((word)(&dummy));
}
#if defined(ASM_CLEAR_CODE)
--
2.9.1
--- a/include/gc.h 2012-08-09 16:25:13.000000000 -0400
+++ b/include/gc.h 2013-04-22 13:10:01.101686000 -0400
@@ -1385,7 +1385,14 @@
/* THREAD_LOCAL_ALLOC defined and the initial allocation call is not */
/* to GC_malloc() or GC_malloc_atomic(). */
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
+#ifdef __x86_64__
+ extern int __data_start__[], __data_end__[], __bss_start__[], __bss_end__[];
+#define GC_DATASTART (__data_start__ < __bss_start__ ?\
+ (void *)__data_start__ : (void *)__bss_start__)
+#define GC_DATAEND (__data_end__ < __bss_end__ ?\
+ (void *)__data_end__ : (void *)__bss_end__)
+#else
/* Similarly gnu-win32 DLLs need explicit initialization from the */
/* main program, as does AIX. */
extern int _data_start__[], _data_end__[], _bss_start__[], _bss_end__[];
@@ -1393,6 +1400,7 @@
(void *)_data_start__ : (void *)_bss_start__)
# define GC_DATAEND (_data_end__ > _bss_end__ ? \
(void *)_data_end__ : (void *)_bss_end__)
+#endif
# define GC_INIT_CONF_ROOTS GC_add_roots(GC_DATASTART, GC_DATAEND); \
GC_gcollect() /* For blacklisting. */
/* Required at least if GC is in a DLL. And doesn't hurt. */
--- a/include/private/gcconfig.h 2012-08-09 16:25:13.000000000 -0400
+++ b/include/private/gcconfig.h 2013-04-21 12:52:28.024399600 -0400
@@ -432,10 +432,20 @@
# endif
# define mach_type_known
# endif
-# if defined(__CYGWIN32__) || defined(__CYGWIN__)
+# if defined(__CYGWIN32__)
# define I386
# define CYGWIN32
# define mach_type_known
+#if defined(__CYGWIN__)
+# if defined(__LP64__)
+# define X86_64
+# define mach_type_known
+# else
+# define I386
+# endif
+# define CYGWIN32
+# define mach_type_known
+#endif
# endif
# if defined(__MINGW32__) && !defined(mach_type_known)
# define I386
@@ -502,6 +512,16 @@
# define mach_type_known
# endif
+#if defined(__CYGWIN__)
+# if defined(__LP64__)
+# define X86_64
+# define mach_type_known
+# else
+# define I386
+# endif
+# define CYGWIN32
+# define mach_type_known
+#endif
/* Feel free to add more clauses here */
/* Or manually define the machine type here. A machine type is */
@@ -2259,6 +2279,19 @@
# define GWW_VDB
# define DATAEND /* not needed */
# endif
+
+# ifdef CYGWIN32
+# define OS_TYPE "CYGWIN32"
+# define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
+# define DATAEND ((ptr_t)GC_DATAEND)
+# define ALIGNMENT 8
+# undef STACK_GRAN
+# define STACK_GRAN 0x10000
+# ifdef USE_MMAP
+# define NEED_FIND_LIMIT
+# define USE_MMAP_ANON
+# endif
+# endif
# endif /* X86_64 */
# ifdef HEXAGON
--- a/os_dep.c 2014-06-01 19:00:48.000000000 +0200
+++ b/os_dep.c 2015-12-15 15:22:08.236909098 +0100
@@ -765,9 +765,13 @@
GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb)
{
void * _tlsbase;
-
+#ifdef __x86_64__
+ PNT_TIB pTib = NtCurrentTeb();
+ _tlsbase = pTib->StackBase;
+#else
__asm__ ("movl %%fs:4, %0"
: "=r" (_tlsbase));
+#endif
sb -> mem_base = _tlsbase;
return GC_SUCCESS;
}