Fix incorrect stack count warnings
authorNeil Jerram <neil@ossau.uklinux.net>
Wed, 16 Sep 2009 23:05:06 +0000 (00:05 +0100)
committerNeil Jerram <neil@ossau.uklinux.net>
Wed, 16 Sep 2009 23:19:47 +0000 (00:19 +0100)
* libguile/stacks.c (stack_depth): Decrement depth count for a
  macro-expansion frame.  (Missing this decrement will cause a "stack
  count incorrect" warning but is actually benign, as it only means
  that scm_make_stack allocates a bit more space for the stack than it
  really needs.)

  (read_frames): Increment count of remaining unused frames, when
  cutting out a macro transformer application frame.  (Missing this
  increment could cause the "stack count incorrect" warning, and could
  make read_frames think it's filled up all the available stack frames
  when there's actually still one frame unused; this wasn't benign,
  because it could cause information to be missing from a stack
  trace.)

libguile/stacks.c

index 5c8d1a5..a701863 100644 (file)
@@ -143,6 +143,11 @@ stack_depth (scm_t_debug_frame *dframe, scm_t_ptrdiff offset, SCM vmframe,
        {
          scm_t_debug_info *info = RELOC_INFO (dframe->info, offset);
          scm_t_debug_info *vect = RELOC_INFO (dframe->vect, offset);
+         /* If current frame is a macro during expansion, we should
+            skip the previously recorded macro transformer
+            application frame.  */
+         if (SCM_MACROEXPP (*dframe) && n > 0)
+           --n;
          n += (info - vect) / 2 + 1;
          /* Data in the apply part of an eval info frame comes from previous
             stack frame if the scm_t_debug_info vector is overflowed. */
@@ -280,6 +285,7 @@ read_frames (scm_t_debug_frame *dframe, scm_t_ptrdiff offset,
            {
              *(iframe - 1) = *iframe;
              --iframe;
+             ++n;
            }
          info =  RELOC_INFO (dframe->info, offset);
          vect =  RELOC_INFO (dframe->vect, offset);