From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 064693858CD1; Thu, 21 Mar 2024 08:46:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 064693858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711010792; bh=yKPDViXbwypTpZnYov6Y7fZ74loMtIvlJac3Cuq92l4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RrEzu1B/RGk1SXL6rPAZfy2qYbHMgUOPfwPP5wb00q+ydOmWMnnxBuKC5W+b0wy02 iTWEwyhDj47iYhE21pBio2oO4iVIUz3JKNArJL+vlmj7zdTTvU0K5GjrVexfnVDiAf ZaHcumVDcUGjDvsYoPMiTiiS6dcAVc2veeanVk7c= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/111736] Address sanitizer is not compatible with named address spaces Date: Thu, 21 Mar 2024 08:46:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: addr-space, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 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://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111736 --- Comment #18 from Jakub Jelinek --- (In reply to rguenther@suse.de from comment #17) > On Thu, 21 Mar 2024, ubizjak at gmail dot com wrote: >=20 > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111736 > >=20 > > --- Comment #16 from Uro? Bizjak --- > > (In reply to Richard Biener from comment #13) > > > The original testcase is fixed, appearantly slapping 'extern' on the = int > > > makes it not effective. > > >=20 > > > Possibly better amend the > > >=20 > > > if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) > > > return; > > >=20 > > > check though. As indicated my fix fixed only VAR_DECL cases, there's > > > still pointer-based accesses (MEM_REF) to consider. So possibly even > > > the following is necessary > >=20 > > I must admit that to create the patch from Comment #11 I just mindlessly > > searched for DECL_THREAD_LOCAL_P in asan.cc and amended the location wi= th > > ADDR_SPACE_GENERIC_P check. >=20 > It might be that the DECL_THREAD_LOCAL_P handling is similarly broken > in that >=20 > int foo (int *p) > { > return *p; > } No, that is not broken. __thread/thread_local is something that applies so= lely to variables. If you take address of a TLS variable, the result is a normal address space pointer even if TLS uses separate address spaces. Pointer to= TLS var is e.g. on x86-64 load from %gs:0 with offset added to it, while load/s= tore of a TLS var is load/store from %gs:offset. So, we actually wouldn't need to punt on DECL_THREAD_LOCAL_P variables, we = can just check their addresses. We actually don't insert red zones in between the TLS var, so doing it woul= dn't make significant sense.=