From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sa-prd-fep-044.btinternet.com (mailomta28-sa.btinternet.com [213.120.69.34]) by sourceware.org (Postfix) with ESMTPS id 186AA3AA842D for ; Thu, 17 Nov 2022 14:33:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 186AA3AA842D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=dronecode.org.uk Received: from sa-prd-rgout-001.btmx-prd.synchronoss.net ([10.2.38.4]) by sa-prd-fep-044.btinternet.com with ESMTP id <20221117143322.JWAR23588.sa-prd-fep-044.btinternet.com@sa-prd-rgout-001.btmx-prd.synchronoss.net>; Thu, 17 Nov 2022 14:33:22 +0000 Authentication-Results: btinternet.com; auth=pass (PLAIN) smtp.auth=jonturney@btinternet.com; bimi=skipped X-SNCR-Rigid: 62E573CC110DD2C0 X-Originating-IP: [81.153.98.246] X-OWM-Source-IP: 81.153.98.246 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvgedrgeekgdehkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepffekiefgudejheetudeigfejledtleegleetkeduteeftdfffefhueefgfeutedtnecukfhppeekuddrudehfedrleekrddvgeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurddutdeingdpihhnvghtpeekuddrudehfedrleekrddvgeeipdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopehguggsqdhprghttghhvghssehsohhurhgtvgifrghrvgdrohhrghdprhgtphhtthhopehtrhhomhgvhiesrggurggtohhrvgdrtghomh X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from [192.168.1.106] (81.153.98.246) by sa-prd-rgout-001.btmx-prd.synchronoss.net (5.8.716.04) (authenticated as jonturney@btinternet.com) id 62E573CC110DD2C0; Thu, 17 Nov 2022 14:33:22 +0000 Message-ID: Date: Thu, 17 Nov 2022 14:33:21 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH 2/2] Implement target async for Windows To: Tom Tromey , gdb-patches@sourceware.org References: <20220803130822.735057-1-tromey@adacore.com> <20220803130822.735057-3-tromey@adacore.com> <87bkph46uf.fsf@tromey.com> Content-Language: en-GB From: Jon Turney In-Reply-To: <87bkph46uf.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3570.2 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NONE,TXREP,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 08/11/2022 18:52, Tom Tromey via Gdb-patches wrote: >>>>>> "Jon" == Jon Turney writes: > >>> Thread 1 "gdb" received signal SIGSEGV, Segmentation fault. >>> ops=ops@entry=0x100abfca0 , open_name=open_name@entry=0x0) at ../../gdb/serial.c:249 >>> 249 if (!serial_logfile.empty ()) >>> (top-gdb) p serial_logfile >>> $1 = >>> (top-gdb) bt >>> #0 0x000000010071e755 in serial_open_ops_1 (ops=ops@entry=0x100abfca0 , open_name=open_name@entry=0x0) at ../../gdb/serial.c:249 >>> #1 0x000000010071ec77 in serial_open_ops (ops=ops@entry=0x100abfca0 ) 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 ) 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.