unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Help with new Windows 98 crash
       [not found] <87o7sindcl.fsf.ref@yahoo.com>
@ 2022-12-05 14:18 ` Po Lu
  2022-12-05 14:52   ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Po Lu @ 2022-12-05 14:18 UTC (permalink / raw)
  To: emacs-devel

Emacs 30 (with unexec) is crashing on Windows 98 again, this time during
GC.

I cannot find a version of GDB that reads DWARF generated by GCC 9,
but here is the backtrace from GDB 5, which cannot read the debug
information in emacs.exe:

  #0 0x011e5491
  #1 0x00a44b68
  #2 0x00160070
  #3 0x00343030

the backtrace stops here, after which GDB complains it cannot access
memory at address 0x30303030.

addr2line says the first address belongs to line 606 of w32heap.c.  The
rest are garbage.  Could it be that something is trying to free dumped
memory?

(and if anyone can find a copy of GDB that works on Windows 98 and can
read the debuginfo, that would be best.  Thanks in advance.)



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

* Re: Help with new Windows 98 crash
  2022-12-05 14:18 ` Help with new Windows 98 crash Po Lu
@ 2022-12-05 14:52   ` Eli Zaretskii
  2022-12-05 16:59     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-12-05 14:52 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Date: Mon, 05 Dec 2022 22:18:18 +0800
> 
> Emacs 30 (with unexec) is crashing on Windows 98 again, this time during
> GC.

I tried to build it on X, but the build fails:

  xfns.c:46:10: fatal error: xcb/xcb_aux.h: No such file or directory
   #include <xcb/xcb_aux.h>
	    ^~~~~~~~~~~~~~~
  compilation terminated.

can you please fix that?  Then I could see if the problem is not only
Windows specific.

> I cannot find a version of GDB that reads DWARF generated by GCC 9,
> but here is the backtrace from GDB 5, which cannot read the debug
> information in emacs.exe:
> 
>   #0 0x011e5491
>   #1 0x00a44b68
>   #2 0x00160070
>   #3 0x00343030
> 
> the backtrace stops here, after which GDB complains it cannot access
> memory at address 0x30303030.
> 
> addr2line says the first address belongs to line 606 of w32heap.c.  The
> rest are garbage.  Could it be that something is trying to free dumped
> memory?

Could be, I have no idea yet.  But then FREEABLE_P doesn't do its job,
right?

> (and if anyone can find a copy of GDB that works on Windows 98 and can
> read the debuginfo, that would be best.  Thanks in advance.)

Did you try building with -gstabs+ instead?

P.S. And maybe we should try fixing the problem that requires to use unexec
on Windows 9X to begin with.



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

* Re: Help with new Windows 98 crash
  2022-12-05 14:52   ` Eli Zaretskii
@ 2022-12-05 16:59     ` Eli Zaretskii
  2022-12-06  1:29       ` Po Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-12-05 16:59 UTC (permalink / raw)
  To: luangruo; +Cc: emacs-devel

> Date: Mon, 05 Dec 2022 16:52:28 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > From: Po Lu <luangruo@yahoo.com>
> > Date: Mon, 05 Dec 2022 22:18:18 +0800
> > 
> > Emacs 30 (with unexec) is crashing on Windows 98 again, this time during
> > GC.
> 
> I tried to build it on X, but the build fails:
> 
>   xfns.c:46:10: fatal error: xcb/xcb_aux.h: No such file or directory
>    #include <xcb/xcb_aux.h>
> 	    ^~~~~~~~~~~~~~~
>   compilation terminated.
> 
> can you please fix that?

Never mind, I already fixed this.

> Then I could see if the problem is not only Windows specific.

Seems to be: the build on GNU/Linux doesn't crash.  Unless there's something
special that I need to do to crash it.



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

* Re: Help with new Windows 98 crash
  2022-12-05 16:59     ` Eli Zaretskii
@ 2022-12-06  1:29       ` Po Lu
  2022-12-06 12:12         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Po Lu @ 2022-12-06  1:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Mon, 05 Dec 2022 16:52:28 +0200
>> From: Eli Zaretskii <eliz@gnu.org>
>> Cc: emacs-devel@gnu.org
>> 
>> > From: Po Lu <luangruo@yahoo.com>
>> > Date: Mon, 05 Dec 2022 22:18:18 +0800
>> > 
>> > Emacs 30 (with unexec) is crashing on Windows 98 again, this time during
>> > GC.
>> 
>> I tried to build it on X, but the build fails:
>> 
>>   xfns.c:46:10: fatal error: xcb/xcb_aux.h: No such file or directory
>>    #include <xcb/xcb_aux.h>
>> 	    ^~~~~~~~~~~~~~~
>>   compilation terminated.
>> 
>> can you please fix that?
>
> Never mind, I already fixed this.
>
>> Then I could see if the problem is not only Windows specific.
>
> Seems to be: the build on GNU/Linux doesn't crash.  Unless there's something
> special that I need to do to crash it.

I think I have figured it out.

init_bignum must be called before make_initial_frame, because that
allocates a bignum in temacs (as set_window_buffer calls
bset_display_time and Fcurrent_time, which go through the time
arithmetic stuff), before our own allocator has been set up, which ends
up in the dumped Emacs, leading to a free of a pointer from the wrong
heap once the bignum is garbage collected.

I have installed the change on the Emacs 30 branch because I am not sure
it is safe for Emacs 29.  Can you think of a safer fix?



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

* Re: Help with new Windows 98 crash
  2022-12-06  1:29       ` Po Lu
@ 2022-12-06 12:12         ` Eli Zaretskii
  2022-12-06 12:53           ` Po Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-12-06 12:12 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 06 Dec 2022 09:29:04 +0800
> 
> init_bignum must be called before make_initial_frame, because that
> allocates a bignum in temacs (as set_window_buffer calls
> bset_display_time and Fcurrent_time, which go through the time
> arithmetic stuff), before our own allocator has been set up, which ends
> up in the dumped Emacs, leading to a free of a pointer from the wrong
> heap once the bignum is garbage collected.
> 
> I have installed the change on the Emacs 30 branch because I am not sure
> it is safe for Emacs 29.  Can you think of a safer fix?

There's nothing unsafe in what you did, but:

  . the call to init_bignum inside the !initialized block should be
    conditioned on HAVE_UNEXEC
  . the call to init_bignum that is a few lines below that, and outside of
    the !initialized condition should be conditioned using HAVE_UNEXEC and
    initialized such that we don't invoke this function twice in any case,
    whether this is during dumping or not and whether this is a pdumper
    build or not

If you do these two changes, we can have the result on the release branch.

Please show the patch before installing.

Thanks.



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

* Re: Help with new Windows 98 crash
  2022-12-06 12:12         ` Eli Zaretskii
@ 2022-12-06 12:53           ` Po Lu
  2022-12-06 14:32             ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Po Lu @ 2022-12-06 12:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Po Lu <luangruo@yahoo.com>
>> Cc: emacs-devel@gnu.org
>> Date: Tue, 06 Dec 2022 09:29:04 +0800
>> 
>> init_bignum must be called before make_initial_frame, because that
>> allocates a bignum in temacs (as set_window_buffer calls
>> bset_display_time and Fcurrent_time, which go through the time
>> arithmetic stuff), before our own allocator has been set up, which ends
>> up in the dumped Emacs, leading to a free of a pointer from the wrong
>> heap once the bignum is garbage collected.
>> 
>> I have installed the change on the Emacs 30 branch because I am not sure
>> it is safe for Emacs 29.  Can you think of a safer fix?
>
> There's nothing unsafe in what you did, but:
>
>   . the call to init_bignum inside the !initialized block should be
>     conditioned on HAVE_UNEXEC

But doesn't it have to come before init_window_once in any case?
Otherwise, the wrong malloc will be used even on pdumper builds.

>   . the call to init_bignum that is a few lines below that, and outside of
>     the !initialized condition should be conditioned using HAVE_UNEXEC and
>     initialized such that we don't invoke this function twice in any case,
>     whether this is during dumping or not and whether this is a pdumper
>     build or not

Okay, that's fine by me.



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

* Re: Help with new Windows 98 crash
  2022-12-06 12:53           ` Po Lu
@ 2022-12-06 14:32             ` Eli Zaretskii
  2022-12-07  0:59               ` Po Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-12-06 14:32 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 06 Dec 2022 20:53:53 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > There's nothing unsafe in what you did, but:
> >
> >   . the call to init_bignum inside the !initialized block should be
> >     conditioned on HAVE_UNEXEC
> 
> But doesn't it have to come before init_window_once in any case?
> Otherwise, the wrong malloc will be used even on pdumper builds.

You mean, in the pdumper build?  In that build, what init_bignum does is not
dumped, so I don't think we need it.  Otherwise, why didn't we see any
problems until now?

But if you want to call it in the pdumper build as well, I won't mind.  Just
let's make sure it is called only once upon each invocation.



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

* Re: Help with new Windows 98 crash
  2022-12-06 14:32             ` Eli Zaretskii
@ 2022-12-07  0:59               ` Po Lu
  0 siblings, 0 replies; 8+ messages in thread
From: Po Lu @ 2022-12-07  0:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> You mean, in the pdumper build?  In that build, what init_bignum does is not
> dumped, so I don't think we need it.  Otherwise, why didn't we see any
> problems until now?
>
> But if you want to call it in the pdumper build as well, I won't mind.  Just
> let's make sure it is called only once upon each invocation.

OK, please see the patch I attached in my reply in the other thread.



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

end of thread, other threads:[~2022-12-07  0:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87o7sindcl.fsf.ref@yahoo.com>
2022-12-05 14:18 ` Help with new Windows 98 crash Po Lu
2022-12-05 14:52   ` Eli Zaretskii
2022-12-05 16:59     ` Eli Zaretskii
2022-12-06  1:29       ` Po Lu
2022-12-06 12:12         ` Eli Zaretskii
2022-12-06 12:53           ` Po Lu
2022-12-06 14:32             ` Eli Zaretskii
2022-12-07  0:59               ` Po Lu

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).