From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 221193858D32; Sun, 26 Mar 2023 01:21:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 221193858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679793683; bh=oADo8qYSzG8coOkKVvq+sujSS99OTmXHgKiOr9jVJgA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dLe+tvrjl5Fu8Rv3X0+LaDqaV57vsgyLlngmV5911DeWvIQm4mNXvOUtGO3M2REO5 2EITOs/uJs7W5CYbXgE21Cbah2Z9Wrz630QxoUrqhiehN7QH3La3zzEsCzeC1KldNq 2GbEJEYycvtzoskmP3+pSl3Bil9OBgStvAxDV2Wo= From: "michal.chojnowski at scylladb dot com" To: gdb-prs@sourceware.org Subject: [Bug exp/30271] Addresses of static thread_local fields are badly calculated sometimes Date: Sun, 26 Mar 2023 01:21:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: exp X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: michal.chojnowski at scylladb dot com X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30271 --- Comment #3 from Michal Chojnowski --- I managed to boil it down to a minimal example. I've added the test case as= an attachment. As it turns out, the problem happens because `cooked_index_functions::expand_symtabs_matching` fails to expand the symta= bs which contain the definitions of the static fields, because cooked index entries corresponding to static fields don't have parent_entry set. (For th= is part of the bug, thread_local is not relevant =E2=80=94 this happens for an= y static field, but only thread_local messes up the fallback code path which happens after the lookup fails). This only happens when the test is compiled with clang, though. (I tested t= hat with clang++ 15.0.7). It doesn't seem to happen with gcc. (I tested that wi= th g++ 12.2.1). If the relevant symtab is expanded beforehand, e.g. by another lookup, then= the lookup of the static field won't fail. This makes the bug quite hard to hit= . In many cases, the relevant symtab is expanded by the lookup of the class which occurs immediately before the lookup of the field. That's why two files are needed in the test =E2=80=94 the class lookup expands one symtab, and so th= e lookup of one field doesn't fail, but it doesn't expand the other symtab and the look= up of the other field fails. Note that this problem with symtabs is orthogonal to the problem with `value_static_field` which I described in earlier comments. If this turns o= ut to be a clang bug, `value_static_field` may still deserve a fix. --=20 You are receiving this mail because: You are on the CC list for the bug.=