From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 BFBD23857C60 for ; Mon, 10 May 2021 21:57:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BFBD23857C60 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-CZuep7kfP2ahSW8duIVOtQ-1; Mon, 10 May 2021 17:57:02 -0400 X-MC-Unique: CZuep7kfP2ahSW8duIVOtQ-1 Received: by mail-qv1-f71.google.com with SMTP id l19-20020a0ce5130000b02901b6795e3304so13734479qvm.2 for ; Mon, 10 May 2021 14:57:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=e+0aKPzZkAKulYlsl99K6MpOgEwoJlUUtsJubu9qw2E=; b=HXsTfbzRAzmsrZvihzyh578j17UCRkwRHMJOHH0mtJUT3H/36aNmBXVHhLJq8X4nGH 6t0oTvgqoogtKXWXgpvrOm8+WbXZk4bU9iMukdS9ogbGYdqLIGiDCTB4HwX1GCCpCm7X uyaCsZSUvzaifJLtb4iGiNTyD1tdQIQjxyHilmLG2SOgQEjmoEMo9ymFlYJAht6vekBh Pij7+4yLuIfBcx50ypScRA/ckg7Au0Himqq++0d/2BQeEZi5Brp5Te7XpgFxr1fpStzC q3j4GdoKXvmYP2sm32+LB3Bzx7CRIa9YtU9UNVp0Te7VeDOIVa/v6LNtKggab5SI8+Nm hWCw== X-Gm-Message-State: AOAM531oRWV/8GasrXmLXhJ99PrOXQAErJ7QwN+ZSJox5y4uGUXbzk6k YJymZiq4zayQbt0xEqY3kiz2KGg5kEdNadm0eJEgeOM1MyhJebm2FaurxJqy3Jnsn/LYVnJwUsd VmKvDgNugIzrDcLzPU5piG3LQVajCrT4w08tCjQFSVTb+aqkhbTKRAiQ6fT9YZ7X2vg== X-Received: by 2002:a37:65ca:: with SMTP id z193mr24191758qkb.409.1620683822141; Mon, 10 May 2021 14:57:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlcyZYO13PaDTZ/kmUOAT2CqMq69tbu9gzYinxGi+FNiAhAZ39BeSoNWxBq9AHpki1pAlcGg== X-Received: by 2002:a37:65ca:: with SMTP id z193mr24191740qkb.409.1620683821869; Mon, 10 May 2021 14:57:01 -0700 (PDT) Received: from [192.168.86.23] ([136.56.129.226]) by smtp.gmail.com with ESMTPSA id a187sm12208829qkd.69.2021.05.10.14.57.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 14:57:01 -0700 (PDT) To: Sultan Alsawaf Cc: systemtap@sourceware.org From: Stan Cox Subject: tls access fails after runtime fix symbol lookups change Message-ID: <09ad40e1-86b6-f8f9-3626-ab31f0f41e7a@redhat.com> Date: Mon, 10 May 2021 17:57:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: systemtap@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Systemtap mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 21:57:06 -0000 Sultan, The thread local storage access stopped working after: runtime: fix symbol lookups when the first section isn't executable Some binaries are linked in such a way that there are VMA address range gaps, indicated by non-zero load offsets. The runtime needs to not lose those offsets to enable a proper mapping back & forth from addresses to symbols. runtime/sym.c | 12 ++++++------ runtime/task_finder_vma.c | 9 +++++++-- runtime/unwind.c | 2 +- runtime/vma.c | 31 ++++++++++--------------------- 4 files changed, 24 insertions(+), 30 deletions(-) More specifically, what fails is accessing the module list; which is the list of executable and libraries. That list is used to find the correct entry for a given module. A quick way to test this is: RUNTESTFLAGS='tls.exp' make installcheck After the above is run, a more specific check can be done by executing this (access module list directly) in the testsuite directory. % ../../install/bin/stap -DTIF_IA32=99 --disable-cache --runtime=kernel -g -c /work/scox/systemtap/bld/testsuite/tls1.x -e 'probe process.function("main") {printf("%#lx\n",user_long_error(&@var("_rtld_global","/usr/lib64/ld-linux-x86-64.so.2")->_dl_ns[0]->_ns_loaded));}' ; ../../install/bin/stap -DTIF_IA32=99 --disable-cache --runtime=kernel -g -c /work/scox/systemtap/bld/testsuite/tls1.x -e 'probe process.function("main") {printf("%#s\n",(@var("_rtld_global","/usr/lib64/ld-linux-x86-64.so.2")->_dl_ns[0]->_ns_loaded$));}' tls counter for 1: 2/3 tls counter for 2: 3/4 0x7efc51d761a0 tls counter for 1: 2/3 tls counter for 2: 3/4 {.l_addr=0, .l_name="", .l_ld=0x403dd8, .l_next=0x7f11692c5750, .l_prev=0x0, .l_real=0x7f11692c51a0, .l_ns=0, .l_libname=0x7f11692c5728, .l_info=[...], .l_phdr=0x400040, .l_entry=4198496, .l_phnum=12, .l_ldnum=0, .l_searchlist={...}, .l_symbolic_searchlist={...}, .l_loader=0x0, .l_versions=0x7f1169272530, .l_nversions=4, .l_nbuckets=1, .l_gnu_bitmask_idxbits=0, .l_gnu_shift=0, .l_gnu_bitmask=0x400350, ={...}, ={...}, .l_direct_opencount=1, .l_type=0, .l_relocated=1, .l_init_called=1, .l_globa... Failing result: tls counter for 1: 2/3 tls counter for 2: 3/4 ERROR: read fault [man error::fault] at 0x7f84a4ac9000 near identifier 'user_long_error' at /work/scox/teststap/bld/../install/share/systemtap/tapset/uconversions.stp:687:10 WARNING: Number of errors: 1, skipped probes: 0 WARNING: /work/scox/teststap/bld/../install/bin/staprun exited with status: 1 Pass 5: run failed. [man error::pass5] tls counter for 1: 2/3 tls counter for 2: 3/4 ERROR Change to user mode (--runtime=dyninst), and it works okay.