From patchwork Wed Oct 11 12:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 77526 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 3142F3857B93 for ; Wed, 11 Oct 2023 12:03:16 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@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 C89D33858D1E for ; Wed, 11 Oct 2023 12:03:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C89D33858D1E 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=1697025790; 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; bh=jlk2YKdi82SoA8HFbxMWffcsCfIiT9dqtG41D/OyQ68=; b=hrlyFT6GXaO3cGRtZjkvYm5q8eBuKjC+AO0qPqepykH+Kj52FO08/4oWa4Mdq8jsYtLOrh oOw8MsCn79QbQW8N68Tx3pbg7WBQf28q2M7+JT2Mcpuu8tKa/ARfh+QdywrKs1ylDetttq 1SvB9G5lEqJ5jX1CWhzcFpgY2+fc7aQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-jlVdy9TTNjKpfglE-b4EEw-1; Wed, 11 Oct 2023 08:02:54 -0400 X-MC-Unique: jlVdy9TTNjKpfglE-b4EEw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7740c0e88ffso827088385a.1 for ; Wed, 11 Oct 2023 05:02:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697025773; x=1697630573; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jlk2YKdi82SoA8HFbxMWffcsCfIiT9dqtG41D/OyQ68=; b=gSpmc2NQoqYs70Jbioy40y2WW7LlQsr6HZZpOoMlCfMjx2dHtps3q0SQfJNLxIlnzt 6Rl/r7RuKACRpLSVG5hoKduTsQXkSGFUX4igeG1A/iHrjXIAuXUBFpJ2zmdbn25HzZZU etocCGpwIGWG7UoP16eMJxoRU2JAQnDFWob6qu2P/00Xuq6NNl6xcRgec0uq2uPD1sSQ +zif2PEs4F3jApUvm9BYe1MS2IALZmIOUbCyYuev16TCQhxvpXvOvqk6mBQNxR5lKI3L JqAxsWneSscnQ2vfg9bVDoWEDnVtA/b1alichxCqWs/1Ddw2pErTeV7qIeKEFjudagSV lT5g== X-Gm-Message-State: AOJu0YxE3VdTWVCHZXhN2aSAZn7PrYotnGZu4VwIzLg+m5RIjYv91bGN 7fOx6sZs/4QfGibZKljwHZepV7NASCG96agUJZneWOsYOz1N+JXu7duGDw6i15vP9XAXy4HN7eY CG7Pk2N09fTbjR4rh6M5QTG2hwrOe X-Received: by 2002:a05:620a:f0e:b0:76c:ba10:4973 with SMTP id v14-20020a05620a0f0e00b0076cba104973mr24374164qkl.37.1697025773495; Wed, 11 Oct 2023 05:02:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwCP2C7/Pqfq/rgS0PuxCd/EDlB9SO5m+3R22w7aT7V7qbyFrdu2IiIqNBhve3stP9HwwfbA== X-Received: by 2002:a05:620a:f0e:b0:76c:ba10:4973 with SMTP id v14-20020a05620a0f0e00b0076cba104973mr24374130qkl.37.1697025773114; Wed, 11 Oct 2023 05:02:53 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id j30-20020a05620a001e00b00767d2870e39sm5167611qki.41.2023.10.11.05.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:02:52 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 768205042F2C; Wed, 11 Oct 2023 14:02:50 +0200 (CEST) From: Dodji Seketeli To: libabigail@sourceware.org Cc: dodji@redhat.com Subject: [PATCH, applied] Bug 30959 - Crash on malformed fn call expression Organization: Red Hat / France X-Operating-System: AlmaLinux 9.2 X-URL: http://www.redhat.com Date: Wed, 11 Oct 2023 14:02:50 +0200 Message-ID: <87wmvtpdsl.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Hello, The code fails to ignore a function call expression that is considered malformed by the type suppression parser. Fixed thus. * src/abg-suppression.cc (type_suppression::insertion_range::eval_boundary): If the function call expression is considered malformed, then do not crash. * tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt: New reference test output. * tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v{0,1}.c: Source code of the new input binaries. * tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v{0,1}.o: New input binaries. * tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.1.suppr: New test suppression specification. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the new tests to this harness. Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-suppression.cc | 9 +++++---- tests/data/Makefile.am | 6 ++++++ ...-has-data-member-inserted-at-1-report-1.txt | 17 +++++++++++++++++ .../test-has-data-member-inserted-at-1-v0.c | 10 ++++++++++ .../test-has-data-member-inserted-at-1-v0.o | Bin 0 -> 3232 bytes .../test-has-data-member-inserted-at-1-v1.c | 11 +++++++++++ .../test-has-data-member-inserted-at-1-v1.o | Bin 0 -> 3240 bytes .../test-has-data-member-inserted-at-1.1.suppr | 3 +++ tests/test-diff-suppr.cc | 10 ++++++++++ 9 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.c create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.o create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v1.c create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v1.o create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.1.suppr new file mode 100644 index 00000000..d0ddcd2e new file mode 100644 index 00000000..49ae2f76 diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index 26d19217..254d6ae4 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -1468,10 +1468,11 @@ type_suppression::insertion_range::eval_boundary(const boundary_sptr boundary, else if (fn_call_expr_boundary_sptr b = is_fn_call_expr_boundary(boundary)) { ini::function_call_expr_sptr fn_call = b->as_function_call_expr(); - if ((fn_call->get_name() == "offset_of" - || fn_call->get_name() == "offset_after" - || fn_call->get_name() == "offset_of_first_data_member_regexp" - || fn_call->get_name() == "offset_of_last_data_member_regexp") + if (fn_call + && (fn_call->get_name() == "offset_of" + || fn_call->get_name() == "offset_after" + || fn_call->get_name() == "offset_of_first_data_member_regexp" + || fn_call->get_name() == "offset_of_last_data_member_regexp") && fn_call->get_arguments().size() == 1) { if (fn_call->get_name() == "offset_of" diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 0569af34..7b07236e 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -1880,6 +1880,12 @@ test-diff-suppr/test-has-data-member-inserted-between-1-v3.o \ test-diff-suppr/test-has-data-member-inserted-between-1-v4.c \ test-diff-suppr/test-has-data-member-inserted-between-1-v4.o \ test-diff-suppr/test-has-data-member-inserted-between-1.suppr \ +test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt \ +test-diff-suppr/test-has-data-member-inserted-at-1-v0.c \ +test-diff-suppr/test-has-data-member-inserted-at-1-v0.o \ +test-diff-suppr/test-has-data-member-inserted-at-1-v1.c \ +test-diff-suppr/test-has-data-member-inserted-at-1-v1.o \ +test-diff-suppr/test-has-data-member-inserted-at-1.1.suppr \ \ test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1 \ test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi \ diff --git a/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt new file mode 100644 index 00000000..d0fac818 --- /dev/null +++ b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt @@ -0,0 +1,17 @@ +Functions changes summary: 0 Removed, 0 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable +Unreachable types summary: 0 removed, 1 changed, 0 added type + +1 changed type unreachable from any public interface: + + [C] 'struct foo' changed: + type size hasn't changed + 1 data member insertion: + 'int x', at offset 0 (in bits) at test-has-data-member-inserted-at-1-v1.c:3:1 + 1 data member change: + type of 'char p[8]' changed: + type name changed from 'char[8]' to 'char[4]' + array type size changed from 64 to 32 + array type subrange 1 changed length from 8 to 4 + and offset changed from 0 to 32 (in bits) (by +32 bits) + diff --git a/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.c b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.c new file mode 100644 index 00000000..237d0d06 --- /dev/null +++ b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.c @@ -0,0 +1,10 @@ +struct foo +{ + char p[8]; +}; + +int +main(void) +{ + return 0; +} diff --git a/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.o b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..fb70318ec911a4d03502aa82ecd02d37eba4863b GIT binary patch literal 3232 zcmcgu&2Jl35TECbW4GJ5NnAlgK-r?AHi);5Lsddcicv(LY(*ykT{kz2bfvUbGI*BH3Er|_RY+1KHsN(_szF2 z7lZ&!0xrQrO``z!N)P2mDmLH*RN>Z@FMq#J`g=cpfnyOwnY028&(V-2JEK_L;SkC~ zl(!L_8G*1;2~)g}z&rTO(on*LX=x#5QAHg|l*DJmnRHt5U3sSHhY32I2HU=5TNUhN zLA+3@+SbbQ%7R!d%|8ubRk4_DU$8IQuiB!D<>$aEPt=|22Bs?tu~Q|>>?zo()(|PV z@cNQfnK+$U+Nn~q#>qQN0A(&l6MqT6bncKYgYFP?i&KDwtH_J!`yz57#9x&;VzdGH zp|FzfMM10-j!)92aYX?~rs`7h=+&Zlw@^U;?Q6H3t@^ZU<4y79SfggH_lH+h3 ztB&lb*0?8={gH|x@ca-4!?5R!!`SbIScTTV-S;A>^@o9~b%vb}{aVjYY6HLJwfvsv z4{BY1PsO!F#YtT2c!`&avg3EVG9Hgc5s*pty;zb}1}bQ&Ncv%{q69ne5?PnKYi|30 zsd3m|V0&xpf^!zPVD%8|pY9_LCs+`7Zi3j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