From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id si6ELjm+OmorIhUAWB0awg (envelope-from ) for ; Tue, 23 Jun 2026 13:11:21 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=J+RHFaRl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AA07F1E024; Tue, 23 Jun 2026 13:11:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C98761E024 for ; Tue, 23 Jun 2026 13:11:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E846C4BA2E22 for ; Tue, 23 Jun 2026 17:11:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E846C4BA2E22 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=J+RHFaRl Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 43DE34BA2E04 for ; Tue, 23 Jun 2026 17:10:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43DE34BA2E04 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43DE34BA2E04 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782234654; cv=none; b=d4SdAWHWXq9o90a3NSCU39VTLKSkCcSWf3zbp4BfOW0Sd5z+S5mEKdEqbKXyuzdZL6UsFkKH1Ur0UpslVXo8UAjcyrBZU8P5iMn1ArnTKRzz6IV5WqUo24rxU5jTWvhv/94X+BamGzadjnvIvQM2LloD6wYOKTiAe26kcstJbyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782234654; c=relaxed/simple; bh=UWwfDT42ZSk5dPk9vQVVR3OnvzJN4jEDYzW9HPwjctY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=k6Gv0DvEIe9ZNNKw/IEWC4Ms30CUOdklxG7P4RE8l6u6pmNoI611wmVuo4+8VET3ghlNwJAI80IribaBC2o13SLHp6gxd6JTCLh4GzDyBg9pjj1pkn6sMwoi6W4N7ro1JYXcGvmDUiqeuy0mhZjyraq6W4OJ3A4lsryfmZuWsQg= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=J+RHFaRl DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43DE34BA2E04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782234653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3sAIoJ1yl21oSKg2OirfFx37mdI7KoE6IvZq666ioLY=; b=J+RHFaRlQuCDZS2FRv2L0ri6vNY6H+jEs+D2NNZj2v/FApo6mHeUzMMexKRr3cOrCtLtma Uerh+7rVVrm4tqGuqxe9jY1+Oxvuk+YRCDr66lY0JDyZyOcaWL9dLMbQza8GYAdLpZN3nB N9Kn2Q9A/UFXRg1f917tXtl3ugj9iPM= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-343-qUtvb-mFNcmDrXq9e9c1FQ-1; Tue, 23 Jun 2026 13:10:53 -0400 X-MC-Unique: qUtvb-mFNcmDrXq9e9c1FQ-1 X-Mimecast-MFC-AGG-ID: qUtvb-mFNcmDrXq9e9c1FQ_1782234651 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2c0d0516ad7so490425ad.0 for ; Tue, 23 Jun 2026 10:10:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782234651; x=1782839451; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3sAIoJ1yl21oSKg2OirfFx37mdI7KoE6IvZq666ioLY=; b=kWPamVDi3inBmfN3f0nIO/BXksNPAQesVtT80diMe0QlEERZ48xziKzRNC6x/HcOso Ybe0sFjrDRqsm/erYhLnonwXfAHtNuwlqK6BDlXB/wJZAdM0Zet8FxvctHoSGuGdyQCJ c/LW03zUX5eMCI5WL+c9XEWq+hZB7flSXeOJ95av4XrR2AumGbY0TfkNRtidEFV7Sfz3 0iJGT7mqmKTGa/08XbruzrXprFvGPm1zFUVShwhLc6XfkqnAItUXYzaMkFrGtu1p+VNU a8HS4Xhfr6gUqW0qIhKFDQ5AA52YMMXHfXHhWkd7J7BjQjYm0XF3nDKcg+FZKAnpujQk lh/Q== X-Gm-Message-State: AOJu0YxY/MRKXLTlri1bqsB1NB5gY6WJ2rBv4fi143zBU0FiEqrHEQ5T Y+Ec0ZVpyCPFn44w5R1LqcDfBd/jz6Pv/mWQecvkRG9e2IdsKwcPrq+4VaW2e77+xAtTdXIgrC4 q6Ry+a/sAZnwAe8/19WsS4DWfG+R5bdMApPchy3rteyncdCz4NYx82xiroJ4RS7U= X-Gm-Gg: AfdE7ckLOLi5pVcy/6bp/wi9Z80ES2d/mYyJv2kqzKiySm/Av6OygrAWxQbx5puMQBz 0/uuAG6Uqku/QSBDI/MO722Hvh1iJb8e8HOck3T0OLEMPujcw0BxQNe+C2G6m1jGdkChabnF904 YW0KIDAy9iwRi/NO0/9Nu995/oC2vpFzdiAOi55qB4/cvlyQ/HM1KDdIVxbq4xXsvpHBio2PH9W or/3BvC/Ih20/zp2oS1P0/ucyZsO7ngSvi3p5Vqgi7kHUU0JPFf/b+cnVNwAQz8H0bXXqpUEerC TvUeJ9U7OMXByKAF/ZDb2zzLXbGFRYD8rIQ8ie0R5J9zoIdFUlFmwp6eE202jsWNWUTvZgC/uvk cEUa3HUALY53us4S7Rg== X-Received: by 2002:a17:902:dad1:b0:2c0:cb90:1e08 with SMTP id d9443c01a7336-2c7c97eb6famr35256375ad.0.1782234650728; Tue, 23 Jun 2026 10:10:50 -0700 (PDT) X-Received: by 2002:a17:902:dad1:b0:2c0:cb90:1e08 with SMTP id d9443c01a7336-2c7c97eb6famr35256105ad.0.1782234650168; Tue, 23 Jun 2026 10:10:50 -0700 (PDT) Received: from [150.1.200.157] ([172.56.105.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7439f8d11sm119402765ad.43.2026.06.23.10.10.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2026 10:10:49 -0700 (PDT) Message-ID: <3ae0f8af-b88a-4f51-bce8-19be9b404fa0@redhat.com> Date: Tue, 23 Jun 2026 10:10:48 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fix crash in AIX when current working directory is NULL To: Aditya Vidyadhar Kamath Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com References: <20260622091114.18783-2-akamath996@gmail.com> From: Keith Seitz In-Reply-To: <20260622091114.18783-2-akamath996@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: nqvcxgq-gJJgBtR8xG_JqniKmMDLqz9SUokTd8hzHaM_1782234651 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi, On 6/22/26 2:11 AM, Aditya Vidyadhar Kamath wrote: > From: Aditya Kamath > > In AIX if we cannot read in the current directory we get, > Thank you for the patch. I can confirm that this is independent of architecture/OS. On x86_64 Fedora 43, we can also demonstrate the issue: term1$ pwd /home/keiths/tmp term1$ mkdir gone && cd gone term2$ rm -rf ~/tmp/gone term1$ gdb -nx -q ~/tmp/simple /home/keiths/gdb: ⚠️ warning: error finding working directory: No such file or directory Reading symbols from /home/keiths/tmp/simple... terminate called after throwing an instance of 'std::logic_error' what(): basic_string: construction from null is not valid We've seen a number of similar issues throughout the years. Is it possible to write a test for this? > The reason for the same above is that in AIX, the variable current_directory in dwarf2/read.c > can be NULL if getcwd () fails during GDB initialisation. When this happens the dwarf2_per_bfd > construction initialisation list captured_cwd to NULL resulting in this segmentation fault shown above. I apologize for being pedantic, but this is more accurately described as a (abort due to a) std::logic_error. > There are two reasons this happened: > 1: The current working directory got deleted in another terminal. > 2: Insufficient permission to read the current directory or its parent/predicissor directory. Typo "predicissor". Did you mean "predecessor?" > > This patch is a fix to the same. > > Afer this fix we get GDB loaded correctly. Typo "After" > gdb ~/gdb_tests/simple_test > gdb: warning: error finding working directory: A parameter must be a directory. > GNU gdb (GDB) 18.0.50.20260619-git > Copyright (C) 2026 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > Type "show copying" and "show warranty" for details. > This GDB was configured as "powerpc64-ibm-aix7.2.0.0". > Type "show configuration" for configuration details. > For bug reporting instructions, please see: > . > > +------------------------------------------------------------------------------+ > | Find the GDB manual online at: | > | http://www.gnu.org/software/gdb/documentation/. | > | For help, type "help". | > | Type "apropos word" to search for commands related to "word". | > +------------------------------------------------------------------------------+ > > Reading symbols from //gdb_tests/simple_test... > (gdb) q > --- > gdb/dwarf2/read.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index 84b1480dbcb..7962acc784d 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -859,7 +859,7 @@ dwarf2_per_bfd::dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, > bool can_copy_) > : obfd (obfd), > can_copy (can_copy_), > - captured_cwd (current_directory), > + captured_cwd (current_directory == NULL ? "" : current_directory), Please use "nullptr" instead. > captured_debug_dir (debug_file_directory) > { > if (names == NULL) While this fix does catch this one specific place, I wonder if this bug lurks elsewhere. For example, in main.c, when getcwd() is called and returns NULL, gdb warns the user and leaves current_directory as NULL. Changing that so that current_directory isn't NULL also fixes this problem and could prevent(?) other similar problems. Of course, that kind of change could introduce some sort of API semantic inconsistencies with current_directory which likely would require more (invasive) changes. In any case, I am just asking. Your patch is simple and minimally invasive. Nonetheless, if it is possible, I would really like a test for this. Keith