From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 814D93858423 for ; Tue, 8 Nov 2022 09:32:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 814D93858423 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667899937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w5GnfqCDa+BjJ1Ee2ULItYZYi7oENVNyCR8OsT6gUvE=; b=bp7+oY3dWQabZ1wFNo31lo06zaQclvE4Rs++tUkyXEp08tsfbiFuznd+LsDtMBqLJzGvo8 CXbZ9HNiG0oZkzcviYhx8wQioFfqViCEUMcMUHEyc8jiuO6DXL795Vz4qVihA9b5dsPuO6 uqOinroXBWmb+EC0lVwdGGo+38j1jLg= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-97-mZx4rSvuOLm1Se0gbbcABw-1; Tue, 08 Nov 2022 04:32:16 -0500 X-MC-Unique: mZx4rSvuOLm1Se0gbbcABw-1 Received: by mail-ej1-f69.google.com with SMTP id hq18-20020a1709073f1200b007ade8dd3494so8023649ejc.2 for ; Tue, 08 Nov 2022 01:32:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w5GnfqCDa+BjJ1Ee2ULItYZYi7oENVNyCR8OsT6gUvE=; b=Gozlfpn71q0UuVi745f7etD6Dh2GiboJUXbkTZUtCliGhVsIRA3/F01s8IHDsmQerT BzcOLIxT3fE6TvJrbI1SpfnIcUlsnqJOVMlL7J6Wjg+5Qa1bVVnaF69EmZyoyI8jwBFT jj4GksCIqSDuXe94umVUcUxvCj+Xnh6oFVkf6OgS7K/sz0B0Q0bwDjvJIRjVBl3Bd5gX mFWyidb7XbroiLnRvKnGK86RcQJEN0Z46IG+pU6seZvOEwxclVwxo1JND4cZVHRIE6D0 h6NhD1pM8Cgpa6gEMQK7iZ0scf+uynnQk7h5RRU9ZsTheJQ6s1p5jfW80ZCEIPbzGazn fSgQ== X-Gm-Message-State: ACrzQf1TIAOByDiqhAfIwiSOrzwVaccMbodWvudTifMDHm/tr5xmdrNK /X+6QEJ6+G3uya5nlgagKXoKDYme7sR6JERjJ3QO6mo+O2vb+iKJ4Os2dho7etTvfQr7WippECK Dl0rEXc4VC7vjKC7RNxx+Rw== X-Received: by 2002:a05:6402:544:b0:463:beae:427f with SMTP id i4-20020a056402054400b00463beae427fmr38339691edx.29.1667899934368; Tue, 08 Nov 2022 01:32:14 -0800 (PST) X-Google-Smtp-Source: AMsMyM5MlM0dJXmo05I2KPjwbUu7Bmfs5WrfUovyDXyk5KyW5Ei8jc5V5OzmbnYZekOWlj+t96oyVA== X-Received: by 2002:a05:6402:544:b0:463:beae:427f with SMTP id i4-20020a056402054400b00463beae427fmr38339684edx.29.1667899934193; Tue, 08 Nov 2022 01:32:14 -0800 (PST) Received: from [10.43.2.105] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 18-20020a170906211200b00781ea761407sm4397435ejt.161.2022.11.08.01.32.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Nov 2022 01:32:13 -0800 (PST) Message-ID: <522f68d7-1452-e275-93c7-b6989b40e5f6@redhat.com> Date: Tue, 8 Nov 2022 10:32:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH 2/7] gdb: add prepare_reinflate/reinflate around print_frame_args in info_frame_command_core To: Simon Marchi , gdb-patches@sourceware.org References: <20221107155310.2590069-1-simon.marchi@polymtl.ca> <20221107155310.2590069-2-simon.marchi@polymtl.ca> From: Bruno Larsen In-Reply-To: <20221107155310.2590069-2-simon.marchi@polymtl.ca> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: On 07/11/2022 16:53, Simon Marchi via Gdb-patches wrote: > I noticed this crash: > > $ ./gdb --data-directory=data-directory -nx -q \ > testsuite/outputs/gdb.python/pretty-print-call-by-hand/pretty-print-call-by-hand \ > -x testsuite/outputs/gdb.python/pretty-print-call-by-hand/pretty-print-call-by-hand.py \ > -ex "b g" -ex r > (gdb) info frame > Stack level 0, frame at 0x7fffffffdd80: > rip = 0x555555555160 in g > (/home/simark/src/binutils-gdb/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c:41); saved rip = 0x5555555551a3 > called by frame at 0x7fffffffdda0 > source language c. > Arglist at 0x7fffffffdd70, args: mt=mytype is 0x555555556004 "hello world", > depth=10 > > Fatal signal: Segmentation fault > > This is another case of frame_info being invalidated under a function's > feet. The stack trace when the frame_info get invalidated looks like: > > ... many frames to pretty print the arg, that eventually invalidate the frame_infos ... > #35 0x00005568d0a8ab24 in print_frame_arg (fp_opts=..., arg=0x7ffc3216bcb0) at /home/simark/src/binutils-gdb/gdb/stack.c:489 > #36 0x00005568d0a8cc75 in print_frame_args (fp_opts=..., func=0x621000233210, frame=..., num=-1, stream=0x60b000000300) > at /home/simark/src/binutils-gdb/gdb/stack.c:898 > #37 0x00005568d0a9536d in info_frame_command_core (fi=..., selected_frame_p=true) at /home/simark/src/binutils-gdb/gdb/stack.c:1682 > > print_frame_args knows that print_frame_arg can invalidate frame_info > objects, and therefore calls prepare_reinflate/reinflate. However, > info_frame_command_core has a separate frame_info_ptr instance (it is > passed by value / copy). So info_frame_command_core needs to know that > print_frame_args can invalidate frame_info objects, and therefore needs > to prepare_reinflate/reinflate as well. Add those calls, and enhance > the gdb.python/pretty-print-call-by-hand.exp test to test that command. Can confirm that the crash is reproducible and that the patch fixes the problem. Sorry for missing it the first time. Makes me wonder if I also missed this in print_frame... Either way: Reviewed-By: Bruno Larsen -- Cheers, Bruno