From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by sourceware.org (Postfix) with ESMTPS id 8159A3858CDB for ; Fri, 7 Oct 2022 18:01:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8159A3858CDB Received: by mail-io1-xd33.google.com with SMTP id e205so4220182iof.1 for ; Fri, 07 Oct 2022 11:01:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9g/Zdv4XjYhOlbHFJjTgTCAdICmJA+mq2IlCif48btk=; b=Ukq9k5UK7Q4ky/d001OqC5XOyAGcnIskZp9O+KNMliWKsgNXm+rTrslvAr8fw3jT0T pE1HJP53XDBaextlJ1wmCTt8iBTNJZsZfeiNYg7aa2EI2IJ3kS22qW1zx/w2dpTK5wGm 5OtE/0Po+XKDtVTYpicrNViEuHFxyZaa2dBefulhVjNUKDj/7i+fh5mkutssDT4jiOLj qEu0bsL72IFRxQTkNvq1d4k90D8nKxTlM6+MdYUn/Th+VE8KO+AM/xvcYn566rFoiWNo 0tr+bZNkJT9c+B7NXcMOx+TpVGNGOa2ckFLlMal9fKRq39jeRgNfUloZIwnfMxNYf0Ww aa3A== X-Gm-Message-State: ACrzQf1UsLkF+zLojZhWnDZ+F4kEOr7iszqrVZWluMXPEhZV3NjamN5E 6ZNgFbnTca+/uGRJSJy3/ac/HHtxcOwNWw== X-Google-Smtp-Source: AMsMyM5dB3QwFCuq2BrS2kCGVgtWItAf/VMXIDB/SbqQIGM5by3OBOo2clAEs76LBK9csHASZGoI9w== X-Received: by 2002:a05:6638:2046:b0:35a:7735:1435 with SMTP id t6-20020a056638204600b0035a77351435mr3307143jaj.122.1665165690783; Fri, 07 Oct 2022 11:01:30 -0700 (PDT) Received: from localhost.localdomain (71-211-160-49.hlrn.qwest.net. [71.211.160.49]) by smtp.gmail.com with ESMTPSA id h11-20020a056602154b00b006814fd71117sm1203228iow.12.2022.10.07.11.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 11:01:30 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/9] Fix crash in amd64-tdep.c Date: Fri, 7 Oct 2022 12:01:12 -0600 Message-Id: <20221007180120.1866772-2-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221007180120.1866772-1-tromey@adacore.com> References: <20221007180120.1866772-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2022 18:01:35 -0000 amd64-tdep.c could crash when 'finish'ing from a function whose return type had variable length. In this situation, the value will be passed by reference, and this patch avoids the crash. (Note that this does not fully fix the bug reported, but it does fix the crash, so it seems worthwhile to land independently.) --- gdb/amd64-tdep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index ea2b3b1ecc3..22d69c85387 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -666,7 +666,8 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2]) loc_bitpos attributes, which will cause an assert to trigger within the unaligned field check. As classes with virtual bases are not trivially copyable, checking that first avoids this problem. */ - if (type->length () > 16 + if (TYPE_HAS_DYNAMIC_LENGTH (type) + || type->length () > 16 || !language_pass_by_reference (type).trivially_copyable || amd64_has_unaligned_fields (type)) { -- 2.34.3