From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 8B039385782D for ; Fri, 15 Jan 2021 16:15:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8B039385782D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10FGFRC8031215 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Jan 2021 11:15:31 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10FGFRC8031215 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id ED3421E590; Fri, 15 Jan 2021 11:15:26 -0500 (EST) Subject: Re: GDB loading incorrect version library To: noloader@gmail.com, gdb@sourceware.org References: From: Simon Marchi Message-ID: <547cf0c9-1585-07c6-8565-bd2a2048eecf@polymtl.ca> Date: Fri, 15 Jan 2021 11:15:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 15 Jan 2021 16:15:27 +0000 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 16:15:34 -0000 On 2021-01-15 2:30 a.m., Jeffrey Walton via Gdb wrote: > Hi Everyone, > > I'm trying to investigate a Bash crash when Bash is instrumented with > Asan. I've got Bash and all of its dependencies built/installed at > ~/ok2delete-asan. All of them are built with Asan. > > GDB startup shows: > > $ gdb ~/ok2delete-asan/bin/bash > gdb: /usr/local/lib/libncursesw.so.6: no version information > available (required by gdb) > > It appears GDB is not loading the proper version of Ncurses: > > (gdb) shell readelf -d ~/ok2delete-asan/bin/bash | grep -E 'RPATH|RUNPATH' > 0x000000000000001d (RUNPATH) Library runpath: > [$ORIGIN/../lib:/home/jwalton/ok2delete-asan/lib] > > And (slightly trimmed): > > (gdb) shell ldd ~/ok2delete-asan/bin/bash > linux-vdso.so.1 (0x00007ffde6bfc000) > libasan.so.5 => /usr/lib/x86_64-linux-gnu/libasan.so.5 > libiconv.so.2 => /home/jwalton/ok2delete-asan/bin/../lib/libiconv.so.2 > libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 > libtinfow.so.6 => /home/jwalton/ok2delete-asan/bin/../lib/libtinfow.so.6 > libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 > libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 > librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 > libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 > libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 > /lib64/ld-linux-x86-64.so.2 > > All of the warez built use the same RUNPATH. > > How do I tell GDB to use the RUNPATH set in the binary? > > Thanks in advance. > >From what I understand, the problem appears to be with the library required by GDB itself (GDB uses ncurses to implement the text user interface, or TUI) and not with ncurses loaded by your bash executable. As we can see by your ldd command, your bash doesn't even require ncurses. So maybe you built GDB against some ncurses library (the one in /usr/lib perhaps) but now there's another, incompatible ncurses library in the library path (in /usr/local/lib). Additionally, you get the error message just when loading the bash executable in GDB. At this point, GDB makes no attempt to load any of the shared libraries, that only happens when you run, and the process actually loads the shared libraries. And when this happens, GDB simply gets the absolute path of the library that the process actually loaded from the dynamic loader. As a result, GDB doesn't need to implement any RPATH / LD_LIBRARY_PATH / whatever logic to find libraries. Simon