From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id B39F21F934 for ; Fri, 30 Apr 2021 14:12:03 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id EA928120FEE; Fri, 30 Apr 2021 23:10:52 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1905E1210AC for ; Fri, 30 Apr 2021 23:10:48 +0900 (JST) Received: by filterdrecv-6bd97c8c5f-zvplh with SMTP id filterdrecv-6bd97c8c5f-zvplh-1-608C1023-11B 2021-04-30 14:11:47.752996575 +0000 UTC m=+147159.023918039 Received: from herokuapp.com (unknown) by ismtpd0169p1iad2.sendgrid.net (SG) with ESMTP id gNqrb2ynTL2z0w_p8QcOEQ for ; Fri, 30 Apr 2021 14:11:47.702 +0000 (UTC) Date: Fri, 30 Apr 2021 14:11:47 +0000 (UTC) From: xtkoba+ruby@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17810 X-Redmine-Issue-Author: xtkoba X-Redmine-Sender: xtkoba X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 79719 X-SG-EID: =?us-ascii?Q?75w3+RXRrinEP3ykAS=2F1WzD2vTMrJdTeEiaFbXc9IwUE38LBb26ZiZ835E4Hln?= =?us-ascii?Q?mGO0mCdyrHSF=2FYIe7IzfT+jLx3oGnNriCWWYp=2FZ?= =?us-ascii?Q?5uMQNxZ=2FSddSfmsDoyARrDsNGHLHVnADU4OFgV3?= =?us-ascii?Q?LNdyIEyogZALHQmPnCwdZuQQ6jcAiVFw7UfSqya?= =?us-ascii?Q?F1XaKmNd4pokaoJA0A9fTflJrQvgA2yvYVw=3D=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103672 Subject: [ruby-core:103672] [Ruby master Bug#17810] addr2line.c: Some symbol names missing in C backtrace with Clang/LLVM X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17810 has been updated by xtkoba (Tee KOBAYASHI). PR: https://github.com/ruby/ruby/pull/4438 The second patch is omitted from the PR, because it turns out to be not very useful. The corresponding source file name should be easily guessable from the symbol name. ---------------------------------------- Bug #17810: addr2line.c: Some symbol names missing in C backtrace with Clang/LLVM https://bugs.ruby-lang.org/issues/17810#change-91767 * Author: xtkoba (Tee KOBAYASHI) * Status: Open * Priority: Normal * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- When Clang/LLVM is used for compilation, some symbol names are missing in C level backtrace information. An example: ``` -- C level backtrace information ------------------------------------------- (...snip...) /var/tmp/ruby.debug/lib/libruby.so.3.1(vm_call_method_each_type+0x6a) [0x7f73856ac33f] ../vm_insnhelper.c:3438 /var/tmp/ruby.debug/lib/libruby.so.3.1(0x7f73856ac29a) [0x7f73856ac29a] /var/tmp/ruby.debug/lib/libruby.so.3.1(0x7f73856aadf6) [0x7f73856aadf6] /var/tmp/ruby.debug/lib/libruby.so.3.1(vm_exec_core+0xff7) [0x7f738569c3cd] ../insns.def:792 /var/tmp/ruby.debug/lib/libruby.so.3.1(rb_vm_exec+0x5c9) [0x7f73856a78d4] /var/tmp/ruby.debug/lib/libruby.so.3.1(rb_ec_exec_node+0xe5) [0x7f73855a1bec] ../eval.c:320 /var/tmp/ruby.debug/lib/libruby.so.3.1(ruby_run_node+0x5a) [0x7f73855a1acf] ../eval.c:379 /var/tmp/ruby.debug/bin/ruby(main+0x73) [0x55c15877ac4b] ../main.c:47 ``` This seems to happen because `dladdr(3)` sometimes fills `NULL` in `dli_sname` which is then overwritten to `lines[i].sname` regardless of its previous value. A patch is attached to fix this issue. It modifies `addr2line.c` so that it does not use `dli_sname` (and also `dli_fname`) when the value is `NULL`. I also attach another patch that makes `addr2line.c` print source filename even when source lineno is not available (which is the case for `rb_vm_exec` in the above example). When these two patches are applied, C level backtrace information is printed as follows. ``` -- C level backtrace information ------------------------------------------- (...snip...) /var/tmp/ruby.debug/lib/libruby.so.3.1(vm_call_method_each_type+0x6a) [0x7fb08928231f] ../vm_insnhelper.c:3438 /var/tmp/ruby.debug/lib/libruby.so.3.1(vm_call_method+0xf6) [0x7fb08928227a] ../vm_insnhelper.c:0 /var/tmp/ruby.debug/lib/libruby.so.3.1(vm_sendish+0x334) [0x7fb089280dd6] ../vm_insnhelper.c:0 /var/tmp/ruby.debug/lib/libruby.so.3.1(vm_exec_core+0xff7) [0x7fb0892723ad] ../insns.def:792 /var/tmp/ruby.debug/lib/libruby.so.3.1(rb_vm_exec+0x5c9) [0x7fb08927d8b4] ../vm.c:0 /var/tmp/ruby.debug/lib/libruby.so.3.1(rb_ec_exec_node+0xe5) [0x7fb089177bcc] ../eval.c:320 /var/tmp/ruby.debug/lib/libruby.so.3.1(ruby_run_node+0x5a) [0x7fb089177aaf] ../eval.c:379 /var/tmp/ruby.debug/bin/ruby(main+0x73) [0x557ed1e0bc4b] ../main.c:47 ``` ---Files-------------------------------- ruby-addr2line-do-not-overwrite-sname-with-null.patch (1.07 KB) ruby-addr2line-print-filename-without-lineno.patch (574 Bytes) -- https://bugs.ruby-lang.org/