From patchwork Wed Mar 31 17:40:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 42822 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 075043857C75; Wed, 31 Mar 2021 17:40:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 075043857C75 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617212442; bh=1mPu+KwHaOYhZw1k+my1iICKIuoqXoNxRSl+fCreYJU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=xt3QmlKy5U360KAoeeI4O3fSYZlE5HXyJ4/G78RAW9dfaibbUY5cYdGfHkbIoxUV7 Jm3Smx+KRzdVRSaYOmwUUo/wsWCizNmthjApIXrgU8Vjevpf2793iCZ8zg+Sk3WrUz Huccf6HblMFcj+CEW6etzQgBWc1cBOsFGjdIpDaw= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 2F1313857C75 for ; Wed, 31 Mar 2021 17:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2F1313857C75 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-y_Erbda9NzieY9Y_Pfszdw-1; Wed, 31 Mar 2021 13:40:23 -0400 X-MC-Unique: y_Erbda9NzieY9Y_Pfszdw-1 Received: by mail-wr1-f69.google.com with SMTP id b6so1352140wrq.22 for ; Wed, 31 Mar 2021 10:40:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=1mPu+KwHaOYhZw1k+my1iICKIuoqXoNxRSl+fCreYJU=; b=cgmkkEfEDS9yRzPn8Mlicux2kM1Zm0Metus0q8GYbfobMOnvgLLdscY46AqmRxBxJE sYjzCPA4ojI0d0vh/MKwPkfMNeMmP7XxRS/RRNxHmqeovYTyJKVtm9oopPImpGspxfxf FnLw3e52nCRK2wxM5y1+NkOSuAzDYqbhlhxQ6KNkt94JS88jHEjBH+G22arBSIRkd+Km LrUB97vXxyHzOPowwUjkyZs1ojhx1yoc+fizDuun8kcBOcWT/oFonIIA90MPsDWFjrAB 736M5nKjcNRjSfRME23MwkDTEjjMrbHvbUSncCjm5M7jQFHZygyNjCpSAPIH+XaFAF/X d5eA== X-Gm-Message-State: AOAM530ikeEIeTY0Cr9FH5upePR3qylL6N0hKGRu7PcpAX0ZG9HRud93 FdRzDaCVxY0vikitzM0l/5+md/ZP2VuTQpINPH9XZONXEqAQ30H8a95FDXxI6HaBEIMG6KhpAaM z0ksMdRIawBb9/JJesZKhqAMGa6L3/f6Ihy6ZV1bX5Ba26ryDDCw86Wim60VJC51yq/s3 X-Received: by 2002:a05:600c:20d3:: with SMTP id y19mr4314219wmm.146.1617212422148; Wed, 31 Mar 2021 10:40:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykKHNTCownmYOjr6o81g4EIold+aaiJ521qhdXN4cS7gZ0EUgO1Ca0AVDrd7Xx6SQo1znbPA== X-Received: by 2002:a05:600c:20d3:: with SMTP id y19mr4314202wmm.146.1617212421854; Wed, 31 Mar 2021 10:40:21 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id j123sm4993762wmb.1.2021.03.31.10.40.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 10:40:21 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 225F2580100; Wed, 31 Mar 2021 19:40:20 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] Bug 27598 - abidiff mishandles union member functions Organization: Red Hat / France X-Operating-System: Fedora 34 X-URL: http://www.redhat.com Date: Wed, 31 Mar 2021 19:40:20 +0200 Message-ID: <87blazusqj.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Hello, abidiff segfaults when a union member function is involved in the comparison. This patch fixes that. * src/abg-default-reporter.cc (default_reporter::report): Assume the parent type of the method can be either a class or a union. * tests/data/test-diff-filter/test-PR27598-report-0.txt: New reference output for the test. * tests/data/test-diff-filter/test-PR27598-v{0,1}.cc: New source code for the input binaries below. * tests/data/test-diff-filter/test-PR27598-v{0,1}.o: New input test binaries. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the test inputs above to this test harness. Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-default-reporter.cc | 23 ++++++++++++------ tests/data/Makefile.am | 5 ++++ .../test-PR27598-report-0.txt | 0 .../data/test-diff-filter/test-PR27598-v0.cc | 14 +++++++++++ tests/data/test-diff-filter/test-PR27598-v0.o | Bin 0 -> 3992 bytes .../data/test-diff-filter/test-PR27598-v1.cc | 12 +++++++++ tests/data/test-diff-filter/test-PR27598-v1.o | Bin 0 -> 3912 bytes tests/test-diff-filter.cc | 7 ++++++ 8 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 tests/data/test-diff-filter/test-PR27598-report-0.txt create mode 100644 tests/data/test-diff-filter/test-PR27598-v0.cc create mode 100644 tests/data/test-diff-filter/test-PR27598-v0.o create mode 100644 tests/data/test-diff-filter/test-PR27598-v1.cc create mode 100644 tests/data/test-diff-filter/test-PR27598-v1.o diff --git a/src/abg-default-reporter.cc b/src/abg-default-reporter.cc index 9940fc07..a5cebef4 100644 --- a/src/abg-default-reporter.cc +++ b/src/abg-default-reporter.cc @@ -1575,19 +1575,26 @@ default_reporter::report(const function_decl_diff& d, ostream& out, << " to " << sf_vtable_offset << "\n"; } - // the classes of the two member functions. - class_decl_sptr fc = - is_class_type(is_method_type(ff->get_type())->get_class_type()); - class_decl_sptr sc = - is_class_type(is_method_type(sf->get_type())->get_class_type()); + // the parent types (classe or union) of the two member + // functions. + class_or_union_sptr f = + is_class_or_union_type(is_method_type(ff->get_type())->get_class_type()); + class_or_union_sptr s = + is_class_or_union_type(is_method_type(sf->get_type())->get_class_type()); + + class_decl_sptr fc = is_class_type(f); + class_decl_sptr sc = is_class_type(s); // Detect if the virtual member function changes above // introduced a vtable change or not. bool vtable_added = false, vtable_removed = false; - if (!fc->get_is_declaration_only() && !sc->get_is_declaration_only()) + if (!f->get_is_declaration_only() && !s->get_is_declaration_only()) { - vtable_added = !fc->has_vtable() && sc->has_vtable(); - vtable_removed = fc->has_vtable() && !sc->has_vtable(); + if (fc && sc) + { + vtable_added = !fc->has_vtable() && sc->has_vtable(); + vtable_removed = fc->has_vtable() && !sc->has_vtable(); + } } bool vtable_changed = ((ff_is_virtual != sf_is_virtual) || (ff_vtable_offset != sf_vtable_offset)); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 0b406f3b..ab3d2490 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -927,6 +927,11 @@ test-diff-filter/test-PR27331-report-0.txt \ test-diff-filter/test-PR27569-v0.abi \ test-diff-filter/test-PR27569-v1.abi \ test-diff-filter/test-PR27569-report-0.txt \ +test-diff-filter/test-PR27598-v0.cc \ +test-diff-filter/test-PR27598-v0.o \ +test-diff-filter/test-PR27598-v1.cc \ +test-diff-filter/test-PR27598-v1.o \ +test-diff-filter/test-PR27598-report-0.txt \ \ test-diff-suppr/test0-type-suppr-v0.cc \ test-diff-suppr/test0-type-suppr-v1.cc \ diff --git a/tests/data/test-diff-filter/test-PR27598-report-0.txt b/tests/data/test-diff-filter/test-PR27598-report-0.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/test-diff-filter/test-PR27598-v0.cc b/tests/data/test-diff-filter/test-PR27598-v0.cc new file mode 100644 index 00000000..b31dee45 --- /dev/null +++ b/tests/data/test-diff-filter/test-PR27598-v0.cc @@ -0,0 +1,14 @@ +union S +{ + void bar() const + { + } + + int needed; +}; + +void +fun(S s) +{ + s.bar(); +} diff --git a/tests/data/test-diff-filter/test-PR27598-v0.o b/tests/data/test-diff-filter/test-PR27598-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..146c539a484970ee6b8d541cba121b15f97cfe77 GIT binary patch literal 3992 zcmbtWO=w(I6h3!erZeeFrb$z5(khu2EvYs0lm7oY64OpmYE1}~qJ%dyuQQ|bQ)XUj ztSwzALO`M2xu_txaiM#EK#?x2AgCMHZbTO@)RkbNp6|^)$(@^5kb2mGBDyGLEcHUk;;^n{b_0j<=D ziOLw@c$^~~nBa8`lauOc5i+rbTo+98ab`}rSo&aph*7mQQ5e5AfiRonB(cwq#m0%; zj5;$`8SB|x<@iHvkwPkH=>%55jpK*CbW#ii#u<{95#+C19e;#Pks_tUxccqi|3xpFYM>j zF?WT|oLfxK?%S6?oX+PnxlArSlbgxs^80h?sd>MWE_#7hOy~Bdr<=iY%RgE5TYjfr zX3^`EYbRHZ9GX6KAU$2BrHlLd)Z`Z^sMWjF^8Jcmp=_<)^s|+A<&}E2S`V^~ddVx* zt6sg4JwHEl_~6ka*~^{4?*?5$KYb;aDVHD8%LqVcW@nG3r+9sP|HIOVwuQyyI$xb9 zwKAf14keN|x!{j7js^;M_LP7aI)^=?$l-GpMNaRgZ%{e3cIx_c4jGS?p>b%lA+56xg;#qW(40f54Hy82Mjn8V zJ^<%y8bQw5ZuKi2+S(6ji7&(k95df-)JJYDUwe+ScA ztGai;NAhN%l4kXXSq1^e97L9t0LNVSaRWWl8$x@t`tl0F9=j;IJ%&AWLMJsNc?Caj z;WaJ4Vc{3Gd_#|@@OssVJ~nXkbbh6A$%{u16n>L<1TH*qIWczpG?Yxh&G=G3+n&EK zA=&o3HIBTf*&!`IW#OKd^A_IF@^L-d@n1A>vp#8!12gAeFmThJGTqmkfmh-&==8># za2>zlWdeUCpiIRJJj#^1T?&Cr-%-tkh84fGTwSWSF16V_>Kr(6m(3vhqyLsT;rjayACcsjcT#d%W`sXYdrq)z zYKQOiD1&YLEGwewm(%r2YX{U1@2FkBMaJxy4AD^yeg?rH+qT9!8-w{@8Z1CC$hO6M z7B&C#`q3|HU(6qGjy?ZtjM*{aGNTK<3xYwm?Q5)y%Kx6upVPj`Kg7+>e~U3YCR`SD z{wf56Y}R-@? zQdiU;|GeTa?@v^2#GXP>rn`E=_@3hZwEgk#5w+Am^ha(t>rJxPkC;*Zmvy3FO=sq9 G|9=5D*dH4J literal 0 HcmV?d00001 diff --git a/tests/data/test-diff-filter/test-PR27598-v1.cc b/tests/data/test-diff-filter/test-PR27598-v1.cc new file mode 100644 index 00000000..67bb3ee2 --- /dev/null +++ b/tests/data/test-diff-filter/test-PR27598-v1.cc @@ -0,0 +1,12 @@ +union S +{ + void bar() const + { + } +}; + +void +fun(S s) +{ + s.bar(); +} diff --git a/tests/data/test-diff-filter/test-PR27598-v1.o b/tests/data/test-diff-filter/test-PR27598-v1.o new file mode 100644 index 0000000000000000000000000000000000000000..7015d7a8d0904b47f9edbe4ebc63e575c82a0f9e GIT binary patch literal 3912 zcmbtWO=w(I6h3!er!(oaY0?za7&Wf}OKZ*iB>n%3KHMUyv~eGX3ES< zjiutEDikWTh~T2G?Y0Y{ATFc}b?L@+H=+xLx+|!}^SyV^BjfJ!Q|GD z4GgmC2mQoXi~0D7M*>RWFY?=?G}{pBkw$m`t+&p%G4YCuK4S zmFhJcRJ&5eJ=aDMA)O@gKRcAzL)4d5vqROP$mS|X*~S+A2na2mLYDloXE@3rI~Q3t zC$h}XGLzK4DFKJOT!t#z0A=G7`Kx~iCRCX}X2!yTC)8MCXOu@6B$=kZuDCnte3Wq5 zIH?TO=~Kz{^`!bHR4rbZ;`1xa)8d8muNCH}_{?Xn(CqmIclzML!cn(S$mX+ocQQX& z$QP#a?*2Ky>Xy7fD<<*>+==C2rRkrp`AxswsIcg@EA`W>$Bs-KIpj{%D5y6&l&iOv z{am$GeYcUTHG9T2 z`*}YH{=-(n64LHyB6W3+)arm5-JVL{;%Yy`I6hE#tgrMBe3F>nvGoiaFa{m21t`1* zqMwWOk!ItFgWN)Yu5HxtP1l#q);a7EM-E@AIC2P`Vk0@!y>dNDhm59UXdDXPsDVVR zL)$lC037Py1RvN0AKV1zHyT4u_q2MI4(;j%w8XDr1CGqcjrz!w!0}SiR$yY60i^Q!tBvf*}Iz*ovxOofjYFy%@vw`GB0v8^*)Xk3XLdgW& zj4ySw?WGml_TyocsLrU(5iP%H;hvTY7QUqAlX|w}<3|x>=i`QGR5LUGqJf+Bq-^K? z<-jZR9JHgkE?nDR^0I-y8c??C1s-L~oeqUSw&zM_L&K_HUa2iMnipGa9`atf-1e`K zsrK4lv*vRY!=>Gn8v^d%1GBP`&>P_DF=m;ENE)@%iSmV56+C-5qlbP&J3 zc(Ls*bBJ2IwQ^Z+{(npl**C6h6m?8_Z+I`Tlg=r#%NWkeyn`%K2?LYdqezNug~vR~ zA7T~xGwGo|Wc*zKVSSvh=|24+!m~i<=gL@$uWZS;Sy14aA`o|@&eX&0J zoxT2T#_X7Ic~0Ml8U%xE+ncP5TYpurzp8z)KK>2Z>*IV7Q}Sdsq>uIbbpiA&>&twX z@i_lKv_I-&lK9DdpOta`RsEoHrn9yMB>vwSJaD1U><6h8;wN@LGXu