unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fix for Mac OS X Garbage Collection Crashes
@ 2003-10-12 23:57 Andrew Choi
  2003-10-14 21:31 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Choi @ 2003-10-12 23:57 UTC (permalink / raw)


If you've updated and built Emacs from CVS on OS X within the past few
weeks, you may have experienced crashes while Emacs is doing garbage
collection. The following patch, just checked into CVS, solves the
problem. I highly recommend updating to include it.

Index: darwin.h
===================================================================
RCS file: /cvs/emacs/src/s/darwin.h,v
retrieving revision 1.12
diff -r1.12 darwin.h
319a320,323
> /* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method for marking the
>    stack.  */
> #define GC_MARK_STACK   GC_MAKE_GCPROS_NOOPS
> 

The problem is caused by a change to src/alloc.c about a month ago that
causes garbage collection to crash under certain circumstances (when
LISP_INT values are on the gcprolist) if GC_MARK_STACK is set to
GC_USE_GCPROS_AS_BEFORE. The best way to fix the problem is probably to
fix the bug introduced. I don't want to work on that. Instead I have now
set GC_MARK_STACK to GC_MAKE_GCPROS_NOOPS. This option for GC has been
chosen on nearly all other platforms. So by following suit on OS X, we
may actually be using better-maintained code in the future. This is
probably a better solution.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for Mac OS X Garbage Collection Crashes
  2003-10-12 23:57 Fix for Mac OS X Garbage Collection Crashes Andrew Choi
@ 2003-10-14 21:31 ` Stefan Monnier
  2003-10-14 22:33   ` Andrew Choi
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2003-10-14 21:31 UTC (permalink / raw)
  Cc: emacs-devel

>> #define GC_MARK_STACK   GC_MAKE_GCPROS_NOOPS

This is probably a good change indeed.

> The problem is caused by a change to src/alloc.c about a month ago that
> causes garbage collection to crash under certain circumstances (when
> LISP_INT values are on the gcprolist) if GC_MARK_STACK is set to
> GC_USE_GCPROS_AS_BEFORE. The best way to fix the problem is probably to
> fix the bug introduced. I don't want to work on that. Instead I have now

That's interesting.  It needs definitely to be fixed.  Could you
give us as much info about this problem as you've encountered during
your debugging effort ?


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for Mac OS X Garbage Collection Crashes
  2003-10-14 21:31 ` Stefan Monnier
@ 2003-10-14 22:33   ` Andrew Choi
  2003-10-15 15:08     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Choi @ 2003-10-14 22:33 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> The problem is caused by a change to src/alloc.c about a month ago that
>> causes garbage collection to crash under certain circumstances (when
>> LISP_INT values are on the gcprolist) if GC_MARK_STACK is set to
>> GC_USE_GCPROS_AS_BEFORE. The best way to fix the problem is probably to
>> fix the bug introduced. I don't want to work on that. Instead I have now
>
> That's interesting.  It needs definitely to be fixed.  Could you
> give us as much info about this problem as you've encountered during
> your debugging effort ?

I haven't spent much time on it.  Sorry I cannot be any more specific
than this: it crashed at line 5014 of src/alloc.c and at that time `obj'
seemed to contain a LISP_INT value.  I don't have a recipe for repeating
the error.  Sorry.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for Mac OS X Garbage Collection Crashes
  2003-10-14 22:33   ` Andrew Choi
@ 2003-10-15 15:08     ` Stefan Monnier
  2003-10-15 15:45       ` Andrew Choi
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2003-10-15 15:08 UTC (permalink / raw)
  Cc: emacs-devel

>>> The problem is caused by a change to src/alloc.c about a month ago that
>>> causes garbage collection to crash under certain circumstances (when
>>> LISP_INT values are on the gcprolist) if GC_MARK_STACK is set to
>>> GC_USE_GCPROS_AS_BEFORE. The best way to fix the problem is probably to
>>> fix the bug introduced. I don't want to work on that. Instead I have now
>> 
>> That's interesting.  It needs definitely to be fixed.  Could you
>> give us as much info about this problem as you've encountered during
>> your debugging effort ?
> I haven't spent much time on it.  Sorry I cannot be any more specific
> than this: it crashed at line 5014 of src/alloc.c and at that time `obj'
> seemed to contain a LISP_INT value.  I don't have a recipe for repeating
> the error.  Sorry.

Is this `line 5014' the `if (CONS...)' line in mark_object in the
code below ?

    case Lisp_Cons:
      {
	register struct Lisp_Cons *ptr = XCONS (obj);
	if (CONS_MARKED_P (ptr)) break;
	CHECK_ALLOCATED_AND_LIVE (live_cons_p);

and in the earlier email you mention it's linked to `when
LISP_INT values are on the gcprolist'.  What gave you this impression ?

I understand you don't have time to work on this and I'm better
placed to do the work, but any additional hint can be helpful: this is
otherwise very difficult to track down.


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for Mac OS X Garbage Collection Crashes
  2003-10-15 15:08     ` Stefan Monnier
@ 2003-10-15 15:45       ` Andrew Choi
  2003-10-15 17:05         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Choi @ 2003-10-15 15:45 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> Is this `line 5014' the `if (CONS...)' line in mark_object in the
> code below ?
>
>     case Lisp_Cons:
>       {
> 	register struct Lisp_Cons *ptr = XCONS (obj);
> 	if (CONS_MARKED_P (ptr)) break;
> 	CHECK_ALLOCATED_AND_LIVE (live_cons_p);
>
> and in the earlier email you mention it's linked to `when
> LISP_INT values are on the gcprolist'.  What gave you this impression ?
>
> I understand you don't have time to work on this and I'm better
> placed to do the work, but any additional hint can be helpful: this is
> otherwise very difficult to track down.

Yes, it was very hard to repeat the error.  The following shows the top
of the call stack in one of my crash logs.

Thread 0 Crashed:
 #0   0x000c6aec in mark_object (alloc.c:5014)
 #1   0x000c5e20 in Fgarbage_collect (alloc.c:4400)
 #2   0x000dc710 in Feval (eval.c:1978)
 #3   0x000d99a0 in Fprogn (eval.c:409)
 #4   0x000de81c in unbind_to (eval.c:3083)
 #5   0x0010de14 in Fbyte_code (bytecode.c:893)
 #6   0x000de1f4 in funcall_lambda (eval.c:2916)
 #7   0x000ddcb8 in Ffuncall (eval.c:2781)
 #8   0x0010d70c in Fbyte_code (bytecode.c:691)
 #9   0x000de1f4 in funcall_lambda (eval.c:2916)
 ...

So the call to mark_object that causes the problem was made from line
4400, in the code here:

#if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \
     || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS)
  mark_stack ();
#else
  {
    register struct gcpro *tail;
    for (tail = gcprolist; tail; tail = tail->next)
      for (i = 0; i < tail->nvars; i++)
        mark_object (tail->var[i]);
  }
#endif

That's what gave me the idea that perhaps I should change the definition
of GC_MARK_STACK for the OS X build.  Then I ran Emacs under gdb and
after a long time was able to get the crash again (running Gnus, Tramp,
BlogMax, and possibly other stuffs).  I discovered that `obj' contains
an integer value (0x1fff0000, -32768?, I think) but strangely the case
for Lisp_Cons (line 5014) was reached.  Unfortunately I don't have that
process any more.  Perhaps one can try to repeat this on another
platform too.  It seems that this may not be a Mac-specific problem.
Hope this is enough information.  The change to alloc.c last month
wasn't that big, was it?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix for Mac OS X Garbage Collection Crashes
  2003-10-15 15:45       ` Andrew Choi
@ 2003-10-15 17:05         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2003-10-15 17:05 UTC (permalink / raw)
  Cc: emacs-devel

> Yes, it was very hard to repeat the error.  The following shows the top
> of the call stack in one of my crash logs.

> Thread 0 Crashed:
>  #0   0x000c6aec in mark_object (alloc.c:5014)
>  #1   0x000c5e20 in Fgarbage_collect (alloc.c:4400)
>  #2   0x000dc710 in Feval (eval.c:1978)
>  #3   0x000d99a0 in Fprogn (eval.c:409)
>  #4   0x000de81c in unbind_to (eval.c:3083)
>  #5   0x0010de14 in Fbyte_code (bytecode.c:893)
>  #6   0x000de1f4 in funcall_lambda (eval.c:2916)
>  #7   0x000ddcb8 in Ffuncall (eval.c:2781)
>  #8   0x0010d70c in Fbyte_code (bytecode.c:691)
>  #9   0x000de1f4 in funcall_lambda (eval.c:2916)
>  ...

> So the call to mark_object that causes the problem was made from line
> 4400, in the code here:

> #if (GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \
>      || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS)
>   mark_stack ();
> #else
>   {
>     register struct gcpro *tail;
>     for (tail = gcprolist; tail; tail = tail->next)
>       for (i = 0; i < tail->nvars; i++)
>         mark_object (tail->var[i]);
>   }
> #endif

> That's what gave me the idea that perhaps I should change the definition
> of GC_MARK_STACK for the OS X build.  Then I ran Emacs under gdb and
> after a long time was able to get the crash again (running Gnus, Tramp,
> BlogMax, and possibly other stuffs).  I discovered that `obj' contains
> an integer value (0x1fff0000, -32768?, I think) but strangely the case
> for Lisp_Cons (line 5014) was reached.

I've seen very strange things happen as well in other circumstances.

> Unfortunately I don't have that
> process any more.  Perhaps one can try to repeat this on another
> platform too.  It seems that this may not be a Mac-specific problem.
> Hope this is enough information.  The change to alloc.c last month
> wasn't that big, was it?

Thanks.  I'll try running with GCPROs for a while.


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-10-15 17:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-12 23:57 Fix for Mac OS X Garbage Collection Crashes Andrew Choi
2003-10-14 21:31 ` Stefan Monnier
2003-10-14 22:33   ` Andrew Choi
2003-10-15 15:08     ` Stefan Monnier
2003-10-15 15:45       ` Andrew Choi
2003-10-15 17:05         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).