Subject: bug#49261: Segfault during loadup

From: Eli Zaretskii <[email-masked]>
Date: Sun, 11 Jul 2021 13:21:16 +0300

> Cc: [email-masked], Eli Zaretskii <[email-masked]>
> From: Paul Eggert <[email-masked]>
> Date: Sun, 11 Jul 2021 01:36:21 -0700
> 
> I worked around this particular problem changing mark_maybe_pointer so 
> that pdumper roots can also be tagged (see first attached patch). 
> However, I suspect this is not a complete fix, as it doesn't cover the 
> case where a root points to some part of a pdumper object that is not at 
> the object's start. I added a FIXME about this. Perhaps Daniel can take 
> a look at it sometime. I think the remaining bug will be hit only rarely 
> (if ever).
> 
> The second attached patch is in the same area, but is not part of the 
> fix. It causes the GC to be a bit more accurate (i.e., less 
> conservative) for roots, which can help avoid some leaks.

Thanks, but these changes don't cater to 32-bit builds --with-wide-int:

    CC       alloc.o
  In file included from alloc.c:33:
  alloc.c: In function 'mark_maybe_pointer':
  lisp.h:251:18: warning: unsigned conversion from 'long long int' to 'uintptr_t' {aka 'unsigned int'} changes value from '2305843009213693951' to '4294967295' [-Woverflow]
    251 | # define VALMASK (USE_LSB_TAG ? - (1 << GCTYPEBITS) : VAL_MAX)
	|                  ^
  alloc.c:4767:24: note: in expansion of macro 'VALMASK'
   4767 |       uintptr_t mask = VALMASK;
	|                        ^~~~~~~