Bug 29829 - abidiff coredump at abg-dwarf-reader.cc when read libxul.so
Summary: abidiff coredump at abg-dwarf-reader.cc when read libxul.so
Status: RESOLVED FIXED
Alias: None
Product: libabigail
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 critical
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-26 03:43 UTC by Xiaole He
Modified: 2022-12-02 23:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xiaole He 2022-11-26 03:43:21 UTC
[Overview]
Executing 'abidiff' against to centos7.6's 'libxul.so.debug' will cause coredump, the output from 'bt' command of 'gdb' shows below:

/* command begin */
# abidiff libxul.so.debug libxul.so.debug
abidiff: abg-dwarf-reader.cc:14628: abigail::ir::function_type_sptr abigail::dwarf_reader::build_function_type(abigail::dwarf_reader::read_context&, Dwarf_Die*, abigail::ir::class_or_union_sptr, size_t): Assertion `__abg_cond__' failed.
Aborted (core dumped)
# gdb -c core abidiff
(gdb) bt
#0  0x0000fffdcc4d63d0 in raise () from /usr/lib64/libc.so.6
#1  0x0000fffdcc4d777c in abort () from /usr/lib64/libc.so.6
#2  0x0000fffdcc4cf940 in ?? () from /usr/lib64/libc.so.6
#3  0x0000fffdcc4cf9bc in __assert_fail () from /usr/lib64/libc.so.6
#4  0x0000fffdccde5358 in abigail::dwarf_reader::build_function_type (ctxt=..., die=die@entry=0xffffe5874a38, is_method=std::shared_ptr (empty) 0x0, where_offset=137951670,
    where_offset@entry=187657105818480) at abg-dwarf-reader.cc:14628
#5  0x0000fffdccdda294 in abigail::dwarf_reader::build_ir_node_from_die (ctxt=..., die=die@entry=0xffffe5874a38, scope=0xaaadc4f57760,
    called_from_public_decl=called_from_public_decl@entry=true, where_offset=187657105818480, where_offset@entry=137951670, is_declaration_only=false, is_declaration_only@entry=true,
    is_required_decl_spec=is_required_decl_spec@entry=false) at abg-dwarf-reader.cc:16413
...
#140 abigail::dwarf_reader::read_debug_info_into_corpus (ctxt=...) at abg-dwarf-reader.cc:15878
#141 0x0000fffdccdedb34 in abigail::dwarf_reader::read_corpus_from_elf (ctxt=..., status=@0xffffe588a798: abigail::elf_reader::STATUS_UNKNOWN) at abg-dwarf-reader.cc:17012
#142 0x0000aaabfac261cc in main (argc=<optimized out>, argv=0xffffe588ac48) at abidiff.cc:1207
/* command end */

The two arguments of 'abidiff' are same thing, the centos7.6's 'libxul.so.debug'. The reason to executing 'abidiff' in this way is all for reproducing problem in more clear way, expressing this problem is only caused by reading dwarf from centos7.6's 'libxul.so.debug'.

[Steps to Reproduce]
(1)download 'thunderbird' binary rpm that contains 'libxul.so.debug' from centos7.6 website:
http://debuginfo.centos.org/7/x86_64/thunderbird-debuginfo-52.9.1-1.el7.centos.x86_64.rpm
(2)unpack 'thunderbird' binary rpm to get the 'libxul.so.debug'
rpm2cpio thunderbird-debuginfo-52.9.1-1.el7.centos.x86_64.rpm | cpio -idum
(3)create symbolic link to 'libxul.so.debug' for handy access:
ln -s usr/lib/debug/usr/lib64/thunderbird/libxul.so.debug .
(4)executing 'abidiff' to reproducing problem:
abidiff libxul.so.debug libxul.so.debug

[Actual Results]
'abidiff' crashes with coredump:

/* crash output begin */
abidiff: abg-dwarf-reader.cc:14628: abigail::ir::function_type_sptr abigail::dwarf_reader::build_function_type(abigail::dwarf_reader::read_context&, Dwarf_Die*, abigail::ir::class_or_union_sptr, size_t): Assertion `__abg_cond__' failed.
Aborted (core dumped)
/* crash output end */

[Expected Results]
'abidiff' finishes normally without any message, because the 2 compared dynamic libraries are same.

[Additional Information]
the libabigail version that reproduding against:
git repo: git://sourceware.org/git/libabigail.git
branch: master
HEAD commit: 7bd69830520f2e7ce4efb989b5fd23fde316c7c1(Make Front Ends first class citizens)
Comment 1 Dodji Seketeli 2022-11-28 16:29:41 UTC
Hello,

Thank you for reporting this problem.

What version of libabigail/abidiff are you using?

Is it possible to try to reproduce the issue with the last version of libabigail from the master branch of the git repository at https://sourceware.org/git/?p=libabigail.git;a=summary?
Comment 2 Xiaole He 2022-11-29 01:01:37 UTC
(In reply to dodji from comment #1)
> Hello,
> 
> Thank you for reporting this problem.
> 
> What version of libabigail/abidiff are you using?
> 
> Is it possible to try to reproduce the issue with the last version of
> libabigail from the master branch of the git repository at
> https://sourceware.org/git/?p=libabigail.git;a=summary?

Thank you for replying, this problem was reproduced with libabigail of version 1.6, 2.0, 2.1. And we try to use the latest master branch of the git repository to see whether it can be fixed, but it was reproduced again:
- git repo: git://sourceware.org/git/libabigail.git
- branch: master
- HEAD commit that reproduce against: 7bd69830520f2e7ce4efb989b5fd23fde316c7c1(Make Front Ends first class citizens)
Comment 3 Dodji Seketeli 2022-12-01 10:31:55 UTC
I looked into this with the latest commit on the master branch:

4bdaf30b dwarf-reader: Avoid duplicating member functions


Here is the correct way to use libabigail's abidiff on this.

Create a directory named firefox-91.13.0-1.el7.centos.x86_64.
cd into that directory.

Unpack the packages firefox-91.13.0-1.el7.centos.x86_64.rpm AND firefox-debuginfo-91.13.0-1.el7.centos.x86_64.rpm into that directory.

Then, run abidiff against usr/lib64/firefox/libxul.so (not the .debug file).
You just have to tell abidiff where the debug info is using the --d{1,2} option.  Where to find the debug info is the usr/lib/debug directory.

So, here is the command line.

[dodji@box firefox-91.13.0-1.el7.centos.x86_64]$ /usr/bin/time -v build/tools/abidiff --d1 usr/lib/debug --d2 usr/lib/debug usr/lib64/firefox/libxul.so usr/lib64/firefox/libxul.so

        Command being timed: "~/git/libabigail/master/build/tools/abidiff --d1 usr/lib/debug --d2 usr/lib/debug usr/lib64/firefox/libxul.so usr/lib64/firefox/libxul.so"
        User time (seconds): 2717.90
        System time (seconds): 28.44
        Percent of CPU this job got: 99%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 45:46.45
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 45826624
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 3
        Minor (reclaiming a frame) page faults: 22636614
        Voluntary context switches: 47
        Involuntary context switches: 3442
        Swaps: 0
        File system inputs: 12728
        File system outputs: 1280
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 65536
        Exit status: 0
[dodji@box firefox-91.13.0-1.el7.centos.x86_64]$

So, things appears to work correctly as far as I can tell.

Thanks for taking time to report this.
Comment 4 Xiaole He 2022-12-02 03:44:43 UTC
(In reply to dodji from comment #3)
> I looked into this with the latest commit on the master branch:
> 
> 4bdaf30b dwarf-reader: Avoid duplicating member functions
> 
> 
> Here is the correct way to use libabigail's abidiff on this.
> 
> Create a directory named firefox-91.13.0-1.el7.centos.x86_64.
> cd into that directory.
> 
> Unpack the packages firefox-91.13.0-1.el7.centos.x86_64.rpm AND
> firefox-debuginfo-91.13.0-1.el7.centos.x86_64.rpm into that directory.
> 
> Then, run abidiff against usr/lib64/firefox/libxul.so (not the .debug file).
> You just have to tell abidiff where the debug info is using the --d{1,2}
> option.  Where to find the debug info is the usr/lib/debug directory.
> 
> So, here is the command line.
> 
> [dodji@box firefox-91.13.0-1.el7.centos.x86_64]$ /usr/bin/time -v
> build/tools/abidiff --d1 usr/lib/debug --d2 usr/lib/debug
> usr/lib64/firefox/libxul.so usr/lib64/firefox/libxul.so
> 
>         Command being timed: "~/git/libabigail/master/build/tools/abidiff
> --d1 usr/lib/debug --d2 usr/lib/debug usr/lib64/firefox/libxul.so
> usr/lib64/firefox/libxul.so"
>         User time (seconds): 2717.90
>         System time (seconds): 28.44
>         Percent of CPU this job got: 99%
>         Elapsed (wall clock) time (h:mm:ss or m:ss): 45:46.45
>         Average shared text size (kbytes): 0
>         Average unshared data size (kbytes): 0
>         Average stack size (kbytes): 0
>         Average total size (kbytes): 0
>         Maximum resident set size (kbytes): 45826624
>         Average resident set size (kbytes): 0
>         Major (requiring I/O) page faults: 3
>         Minor (reclaiming a frame) page faults: 22636614
>         Voluntary context switches: 47
>         Involuntary context switches: 3442
>         Swaps: 0
>         File system inputs: 12728
>         File system outputs: 1280
>         Socket messages sent: 0
>         Socket messages received: 0
>         Signals delivered: 0
>         Page size (bytes): 65536
>         Exit status: 0
> [dodji@box firefox-91.13.0-1.el7.centos.x86_64]$
> 
> So, things appears to work correctly as far as I can tell.
> 
> Thanks for taking time to report this.

Thans you for debugging this problem using your precious time, but the problem that related to original thunderbird's libxul.so still exists when we test against the updated master branch of git repository.
As you said, the firefox's libxul.so doesn't have this problem, but the thunderbird's libxul.so does have, even if we updated the master branch to include the commit 4bdaf30b (dwarf-reader: Avoid duplicating member functions).
Details of steps for reproducing shows below:
(1)confirm that we at the updated master branch that had the fixed commit
# git remote -v
origin  git://sourceware.org/git/libabigail.git (fetch)
origin  git://sourceware.org/git/libabigail.git (push)
# git branch
* master
# git log --oneline -10
4bdaf30b (HEAD -> master, origin/master, origin/HEAD) dwarf-reader: Avoid duplicating member functions
d222b447 dwarf-reader: Leverage ODR & DWZ
754364d5 Fix spurious deleted/added virtual destructor change report
77ae3141 ctf-reader: Fix array size representation
e33a74fb ctf-reader: Fix representation of multidimensional arrays
(2)'configure' and 'make' the master branch
# ./configure
# make
(3)reassure the newly compiled 'abidiff' is linked to the newly compiled 'libabigail.so'
# ldd tools/.libs/abidiff
        ...
        libabigail.so.1 => /root/tmp/libabigail-git/libabigail/src/.libs/libabigail.so.1 (0x0000fffe0d700000)
        ...
(4)download the binary centos7.6 rpm of 'thunderbird' and 'thunderbird-debuginfo', and then decompressing them
# mkdir thunderbird/ && cd thunderbird/
# wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/thunderbird-52.9.1-1.el7.centos.x86_64.rpm
# wget http://debuginfo.centos.org/7/x86_64/thunderbird-debuginfo-52.9.1-1.el7.centos.x86_64.rpm
# mkdir with-debug/ without-debug/
# rpm2cpio thunderbird-debuginfo-52.9.1-1.el7.centos.x86_64.rpm | cpio -idum -D with-debug/
# rpm2cpio thunderbird-52.9.1-1.el7.centos.x86_64.rpm | cpio -idum -D without-debug/
# cd ../
(5)use newly compiled 'abidiff' to reproducing the problem that causes coredump
# ./tools/.libs/abidiff --d1 thunderbird/with-debug/usr/lib/debug/ --d2 thunderbird/with-debug/usr/lib/debug/ thunderbird/without-debug/usr/lib64/thunderbird/libxul.so thunderbird/without-debug/usr/lib64/thunderbird/libxul.so
abidiff: abg-dwarf-reader.cc:13825: abigail::ir::function_type_sptr abigail::dwarf::build_function_type(abigail::dwarf::reader&, Dwarf_Die*, abigail::ir::class_or_union_sptr, size_t): Assertion `__abg_cond__' failed.
Aborted (core dumped)
Comment 5 Dodji Seketeli 2022-12-02 16:19:46 UTC
Alright, I could finally reproduce the issue.  I was indeed looking at the firefox's libxul.so, not the thunderbird's.

A fix for this issue was committed to the master branch at https://sourceware.org/git/?p=libabigail.git;a=commit;h=1f51b9e85dc42dc71caf7fe79436d64c6a3d03f3.

The fix will be available in the coming 2.2 version of libabigail.

Thank you for taking the time to file this problem report and for your dedication.

Sorry for the inconvenience.
Comment 6 Xiaole He 2022-12-02 23:46:50 UTC
(In reply to dodji from comment #5)
> Alright, I could finally reproduce the issue.  I was indeed looking at the
> firefox's libxul.so, not the thunderbird's.
> 
> A fix for this issue was committed to the master branch at
> https://sourceware.org/git/?p=libabigail.git;a=commit;
> h=1f51b9e85dc42dc71caf7fe79436d64c6a3d03f3.
> 
> The fix will be available in the coming 2.2 version of libabigail.
> 
> Thank you for taking the time to file this problem report and for your
> dedication.
> 
> Sorry for the inconvenience.

Copy that, thanks for your awesome work!