From patchwork Thu Jun 1 09:27:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 55808 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8CD69385735D for ; Thu, 1 Jun 2023 09:28:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CD69385735D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685611708; bh=IMEMNH9n/HtKmDPkGIKntVTgchpZZns3EW3RmXpi4Kw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yLI0iGfIohawov+8pdGkP73Jh+u4JwNFifHQu6Bol6jVJjqiLJZxz5hMG5MzDPte5 dnrlBlxZx60PGPxa9Co0/AecY9aP2X0o+whOtQyIRm55ZdVTgu3f5Am6Rgroas9fp1 O40cgieqOJGnS/g9lenNNinP1kGXzAuBjfWL6w4I= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 4DE5A3858C30 for ; Thu, 1 Jun 2023 09:28:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DE5A3858C30 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-ieDv0mfzNiaenV2tqPGNuw-1; Thu, 01 Jun 2023 05:28:01 -0400 X-MC-Unique: ieDv0mfzNiaenV2tqPGNuw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-30ae42628cfso322474f8f.3 for ; Thu, 01 Jun 2023 02:28:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685611680; x=1688203680; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IMEMNH9n/HtKmDPkGIKntVTgchpZZns3EW3RmXpi4Kw=; b=LpBcS6Wn7UXgqmTFskeYvGRhgiOAJImhFGZ5/IPDn60xByn9bg4Nk27Q+4AmDdEPGI cyj7XaV5xXfnWbbVfULzdxl4TW0m7UNU63kQr5L5LzGKa24HNB7mtvuya3LWhseRUOfD gMq6xTze+KBNvUlWQywncZlyuY0qKvVUih94mfdIywSuBEbWc4/m4WG1x21/ZchGjM3H OWys+JDcSD0FQU0WEAeiFmdEtifuT6QAeoNWlZGrqqycFt5h4JD3Vw1J0jOtZHaRwfbh J37riepU3Os9BfLBa6ADZrJF3b8NmHZQeCQTPPDtz+gUWm1npm3wSwuMAqZxRIsWoLj0 qvEg== X-Gm-Message-State: AC+VfDy1h7StL+kWhX75p3qcjw8dxci7AV31OtFvhaQ5bq0Vt9ksJLzT PNjfjSHkPGTI1EOF3sVQiSULVSi04ZXC0mlOgxRy7Cp/qirgabT8515SqmXL9YiRU8A9SV27UF0 y1aPfm0y4ZQEN1HOyGQd/Js3QgdpnFYUSq5cj21+0Q2mZPUtJPN1e52pMlLNBo3JyqZFIYTCpuP zADUL0jw== X-Received: by 2002:a5d:6a02:0:b0:30a:e378:76e with SMTP id m2-20020a5d6a02000000b0030ae378076emr1254445wru.64.1685611680634; Thu, 01 Jun 2023 02:28:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KIpgaRkfik3Rv/s60SSl1P7PjYgVn9QWElZg/Ul0XcEHo1LvAeReBAPMHuW2kfVHXRaCTVQ== X-Received: by 2002:a5d:6a02:0:b0:30a:e378:76e with SMTP id m2-20020a5d6a02000000b0030ae378076emr1254428wru.64.1685611680224; Thu, 01 Jun 2023 02:28:00 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id b10-20020adfee8a000000b0030aefd11892sm9468261wro.41.2023.06.01.02.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 02:27:59 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Simon Marchi , Andrew Burgess Subject: [PATCH 0/4] Some alloca removal and a printf bug fix Date: Thu, 1 Jun 2023 10:27:49 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I previously posted this series in an attempt to remove lots of alloca use: https://inbox.sourceware.org/gdb-patches/cover.1677533215.git.aburgess@redhat.com/ there was some push back against that complete series, however, I think the problem that was pointed out doesn't apply to one of the original patches, so this series started with me trying to upstream that one patch (this is patch #2 in this series). However, while reviewing the patch again I spotted a bug I'd introduced. Which means we have a gap in our testing, as the bug was not exposed during testing. So I started to write a test, and hit another bug (not one introduced by me), this is fixed in patch #1 in this series. My original series didn't remove all the uses of alloca from printcmd.c, I don't recall why. But on review it's actually pretty easy to remove the final alloca from printcmd.c, so that's what patch #3 in this series does. And finally, while working on patch #2 I realised that a badly formed inferior (e.g. one that needed debugging due to memory corruption) could cause GDB to try and allocate a huge ammount of memory, potentially crashing GDB. This is mitigated in patch #4. --- Andrew Burgess (4): gdb: fix printf of wchar_t early in a gdb session gdb: remove two uses of alloca from printcmd.c gdb: remove last alloca call from printcmd.c gdb: check max-value-size when reading strings for printf gdb/c-lang.c | 3 - gdb/gdbtypes.c | 11 ++- gdb/gdbtypes.h | 14 ++- gdb/printcmd.c | 102 +++++++++++++--------- gdb/testsuite/gdb.base/printcmds.c | 2 + gdb/testsuite/gdb.base/printcmds.exp | 5 ++ gdb/testsuite/gdb.base/printf-wchar_t.c | 28 ++++++ gdb/testsuite/gdb.base/printf-wchar_t.exp | 32 +++++++ gdb/testsuite/lib/gdb.exp | 30 +++++++ gdb/value.c | 10 ++- gdb/value.h | 5 ++ 11 files changed, 192 insertions(+), 50 deletions(-) create mode 100644 gdb/testsuite/gdb.base/printf-wchar_t.c create mode 100644 gdb/testsuite/gdb.base/printf-wchar_t.exp base-commit: e9683acf5e51c2bac8aa68d30d9ac3683dddcc7d