public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Implement target async for Windows
Date: Thu, 17 Nov 2022 14:33:21 +0000	[thread overview]
Message-ID: <c8475e99-8584-f614-5532-97379b851b95@dronecode.org.uk> (raw)
In-Reply-To: <87bkph46uf.fsf@tromey.com>

On 08/11/2022 18:52, Tom Tromey via Gdb-patches wrote:
>>>>>> "Jon" == Jon Turney <jon.turney@dronecode.org.uk> writes:
> 
>>> Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
>>> ops=ops@entry=0x100abfca0 <serial_event_ops>, open_name=open_name@entry=0x0) at ../../gdb/serial.c:249
>>> 249       if (!serial_logfile.empty ())
>>> (top-gdb) p serial_logfile
>>> $1 = <error reading variable: Cannot access memory at address 0xffffffffffffffe8>
>>> (top-gdb) bt
>>> #0  0x000000010071e755 in serial_open_ops_1 (ops=ops@entry=0x100abfca0 <serial_event_ops>, open_name=open_name@entry=0x0) at ../../gdb/serial.c:249
>>> #1  0x000000010071ec77 in serial_open_ops (ops=ops@entry=0x100abfca0 <serial_event_ops>) at ../../gdb/serial.c:267
>>> #2  0x000000010071d0ac in make_serial_event () at ../../gdb/ser-event.c:164
>>> #3  0x0000000100810f9e in windows_nat_target::windows_nat_target (this=0x100cdf2e0 <the_windows_nat_target>) at ../../gdb/windows-nat.c:406
>>> #4  0x00000001009d77f0 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../../gdb/windows-nat.c:390
>>> #5  _GLOBAL__sub_I__ZN18windows_nat_targetC2Ev () at ../../gdb/windows-nat.c:3311
>>> #6  0x00007fff152a6582 in do_global_ctors (force=0, in_pfunc=0x1009d8700 <___CTOR_LIST__>) at ../../../../src/winsup/cygwin/dcrt0.cc:78
>>> #7  __main () at ../../../../src/winsup/cygwin/dcrt0.cc:1084
>>> #8  0x00000001009cd7d0 in main (argc=1, argv=0x7ffffcc50) at ../../gdb/gdb.c:25
> 
> Jon> This looks like an problem with static object construction ordering:
> Jon> the serial_logfile object needs to be constructed before before
> Jon> the_windows_nat_target object, but nothing enforces that, currently.
> 
> Ugh...

I was a bit sloppy in the way I described the issue here, using 'static' 
as a shortcut for 'static storage duration'.

Using the language of the standard, the cause would probably be better 
described as "unordered dynamic initialization of non-local variables 
with static storage duration" or something like that.

> Jon> Attached is a patch I wrote to verify the issue, and applying it fixes
> Jon> the crash for me, but I'm sure there is a more elegant solution out
> Jon> there...
> 
> It seems to me that serial.c is blameless and that windows-nat should
> probably not have a static initializer with dependencies.
> 
> Could you try this change instead?

Yes, that fixes the crash, also.

Please apply, if you are happy with it.


  reply	other threads:[~2022-11-17 14:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 13:08 [PATCH 0/2] " Tom Tromey
2022-08-03 13:08 ` [PATCH 1/2] Move some Windows operations to worker thread Tom Tromey
2022-08-03 13:33   ` Eli Zaretskii
2022-08-03 18:47     ` Tom Tromey
2022-08-03 19:16       ` Eli Zaretskii
2022-08-03 13:08 ` [PATCH 2/2] Implement target async for Windows Tom Tromey
2022-11-04 14:28   ` Jon Turney
2022-11-08 18:38     ` Tom Tromey
2022-11-13 14:45       ` Jon Turney
2022-11-04 14:59   ` Jon Turney
2022-11-08 18:52     ` Tom Tromey
2022-11-17 14:33       ` Jon Turney [this message]
2022-11-17 18:38         ` Tom Tromey
2022-11-17 18:43           ` Tom Tromey
2022-08-03 13:34 ` [PATCH 0/2] " Eli Zaretskii
2022-08-03 18:54   ` Tom Tromey
2022-08-03 19:17     ` Eli Zaretskii
2022-08-22 18:03 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8475e99-8584-f614-5532-97379b851b95@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).