avoid potential trouble when write-barrier signals are blocked when handling SIGCHLD (seems to happen in OS X)
svn: r5961
This commit is contained in:
parent
86c466ba0a
commit
df2dbdfbc3
|
@ -2619,7 +2619,7 @@ void protect_old_mpages()
|
||||||
|
|
||||||
#if GENERATIONS
|
#if GENERATIONS
|
||||||
|
|
||||||
static int designate_modified(void *p)
|
static int designate_modified_maybe(void *p, int no_barrier_ok)
|
||||||
{
|
{
|
||||||
unsigned long g = ((unsigned long)p >> MAPS_SHIFT);
|
unsigned long g = ((unsigned long)p >> MAPS_SHIFT);
|
||||||
MPage *map;
|
MPage *map;
|
||||||
|
@ -2641,6 +2641,10 @@ static int designate_modified(void *p)
|
||||||
num_seg_faults++;
|
num_seg_faults++;
|
||||||
return 1;
|
return 1;
|
||||||
} else if (page->age) {
|
} else if (page->age) {
|
||||||
|
if (page->flags & MFLAG_MODIFIED) {
|
||||||
|
if (no_barrier_ok)
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
page->flags |= MFLAG_MODIFIED;
|
page->flags |= MFLAG_MODIFIED;
|
||||||
p = (void *)((long)p & MPAGE_START);
|
p = (void *)((long)p & MPAGE_START);
|
||||||
if (page->flags & MFLAG_BIGBLOCK)
|
if (page->flags & MFLAG_BIGBLOCK)
|
||||||
|
@ -2650,6 +2654,9 @@ static int designate_modified(void *p)
|
||||||
num_seg_faults++;
|
num_seg_faults++;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
} else if (no_barrier_ok) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
GCPRINT(GCOUTF, "Seg fault (internal error) at %lx [%ld]\n",
|
GCPRINT(GCOUTF, "Seg fault (internal error) at %lx [%ld]\n",
|
||||||
(long)p, num_seg_faults);
|
(long)p, num_seg_faults);
|
||||||
|
@ -2667,6 +2674,16 @@ static int designate_modified(void *p)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int designate_modified(void *p)
|
||||||
|
{
|
||||||
|
designate_modified_maybe(p, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GC_write_barrier(void *p)
|
||||||
|
{
|
||||||
|
designate_modified_maybe(p, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* The platform-specific signal handlers, and initialization function: */
|
/* The platform-specific signal handlers, and initialization function: */
|
||||||
# include "sighand.c"
|
# include "sighand.c"
|
||||||
|
|
||||||
|
|
|
@ -338,6 +338,12 @@ GC2_EXTERN void GC_fixup_variable_stack(void **var_stack,
|
||||||
The `stack_mem' argument indicates the start of the allocated memory
|
The `stack_mem' argument indicates the start of the allocated memory
|
||||||
that contains `var_stack'. It is used for backtraces. */
|
that contains `var_stack'. It is used for backtraces. */
|
||||||
|
|
||||||
|
GC2_EXTERN void GC_write_barrier(void *p);
|
||||||
|
/*
|
||||||
|
Explicit write barrier to ensure that a write-barrier signal is not
|
||||||
|
triggered by a memory write.
|
||||||
|
*/
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
};
|
};
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -1899,13 +1899,20 @@ int designate_modified(void *p)
|
||||||
struct mpage *page = find_page(p);
|
struct mpage *page = find_page(p);
|
||||||
|
|
||||||
if(page) {
|
if(page) {
|
||||||
|
if (!page->back_pointers) {
|
||||||
protect_pages(page, page->size, 1);
|
protect_pages(page, page->size, 1);
|
||||||
page->back_pointers = 1;
|
page->back_pointers = 1;
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
GCPRINT(GCOUTF, "Seg fault (internal error) at %p\n", p);
|
GCPRINT(GCOUTF, "Seg fault (internal error) at %p\n", p);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GC_write_barrier(void *p)
|
||||||
|
{
|
||||||
|
(void)designate_modified(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "sighand.c"
|
#include "sighand.c"
|
||||||
|
|
|
@ -6497,6 +6497,10 @@ static int MyPipe(int *ph, int near_index) {
|
||||||
|
|
||||||
# define WAITANY(s) waitpid((pid_t)-1, s, WNOHANG)
|
# define WAITANY(s) waitpid((pid_t)-1, s, WNOHANG)
|
||||||
|
|
||||||
|
#ifndef MZ_PRECISE_GC
|
||||||
|
# define GC_write_barrier(x) /* empty */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MZ_XFORM
|
#ifdef MZ_XFORM
|
||||||
START_XFORM_SKIP;
|
START_XFORM_SKIP;
|
||||||
#endif
|
#endif
|
||||||
|
@ -6533,12 +6537,18 @@ static void child_done(int ingored)
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
for (sc = scheme_system_children; sc; prev = sc, sc = sc->next) {
|
for (sc = scheme_system_children; sc; prev = sc, sc = sc->next) {
|
||||||
if (sc->id == result) {
|
if (sc->id == result) {
|
||||||
|
/* Explicit write barriers avoid triggering a write-barrier signal,
|
||||||
|
just in case we're in some context where the signal is disabled
|
||||||
|
(which seems to happen in some OS X contexts). */
|
||||||
|
GC_write_barrier(sc);
|
||||||
|
|
||||||
sc->done = 1;
|
sc->done = 1;
|
||||||
sc->status = status;
|
sc->status = status;
|
||||||
|
|
||||||
if (prev)
|
if (prev) {
|
||||||
|
GC_write_barrier(prev);
|
||||||
prev->next = sc->next;
|
prev->next = sc->next;
|
||||||
else
|
} else
|
||||||
scheme_system_children = sc->next;
|
scheme_system_children = sc->next;
|
||||||
|
|
||||||
scheme_signal_received();
|
scheme_signal_received();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user