[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-16 Thread ro at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

Rainer Orth  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #6 from Rainer Orth  ---
Fixed for GCC 14.0.1.

[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

--- Comment #5 from GCC Commits  ---
The master branch has been updated by Rainer Orth :

https://gcc.gnu.org/g:7c6071a66f32f43cea7aa4aa32d89b338e768307

commit r14-9030-g7c6071a66f32f43cea7aa4aa32d89b338e768307
Author: Rainer Orth 
Date:   Fri Feb 16 14:06:24 2024 +0100

libsanitizer: Intercept __makecontext_v2 on Solaris/SPARC [PR113785]

c-c++-common/asan/swapcontext-test-1.c FAILs on Solaris/SPARC:

FAIL: c-c++-common/asan/swapcontext-test-1.c   -O0  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O1  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O2  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O2 -flto  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c -O2 -flto -flto-partition=none
execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O3 -g  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -Os  execution test

As detailed in PR sanitizer/113785, this happens because an ABI change
in Solaris 10/SPARC caused the external symbol for makecontext to be
changed to __makecontext_v2, which isn't intercepted.

The following patch, submitted upstream at
https://github.com/llvm/llvm-project/pull/81588, fixes that.

Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11.

2024-02-16  Rainer Orth  

libsanitizer:
PR sanitizer/113785
* asan/asan_interceptors.cpp: Cherry-pick llvm-project revision
8c2033719a843a1880427a5e8caa5563248bce78.

[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-16 Thread ro at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

Rainer Orth  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |ro at gcc dot gnu.org
   Last reconfirmed||2024-02-16
 Status|UNCONFIRMED |NEW
URL||https://gcc.gnu.org/piperma
   ||il/gcc-patches/2024-Februar
   ||y/645798.html
 Ever confirmed|0   |1

--- Comment #4 from Rainer Orth  ---
Mine, patch posted.

[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-13 Thread ro at CeBiTec dot Uni-Bielefeld.DE via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

--- Comment #3 from ro at CeBiTec dot Uni-Bielefeld.DE  ---
Upstream pull request posted: https://github.com/llvm/llvm-project/pull/81588

[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-12 Thread ro at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

Rainer Orth  changed:

   What|Removed |Added

   Target Milestone|--- |14.0

[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-12 Thread ro at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

--- Comment #2 from Rainer Orth  ---
Created attachment 57396
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57396&action=edit
Preliminary patch

[Bug sanitizer/113785] c-c++-common/asan/swapcontext-test-1.c FAILs

2024-02-12 Thread ro at CeBiTec dot Uni-Bielefeld.DE via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113785

--- Comment #1 from ro at CeBiTec dot Uni-Bielefeld.DE  ---
I've found what's going on: as described in Solaris makecontext(3C), the
function changed starting with Solaris 10:

NOTES
   The  semantics  of the uc_stack member of the ucontext_t structure have
   changed as they apply to inputs to makecontext(). Prior to Solaris  10,
   the  ss_sp member of the uc_stack structure represented the high memory
   address of the area reserved for the stack. The ss_sp member now repre-
   sents  the  base  (low  memory  address), in keeping with other uses of
   ss_sp.

   This change in the meaning of ss_sp is now the  default  behavior.  The
   -D__MAKECONTEXT_V2_SOURCE  compilation  flag  used  in Solaris 9 update
   releases to access this behavior is obsolete.

To preserve, binary compatiblity, the old behaviour of makecontext() has
been retained, and the following snippet in  ensures that a
different function with the new behavious is called from user code
instead:

/* makecontext removed in SUSv4 (XPG7, UNIX V7) */
#if !defined(_XPG7) || defined(__EXTENSIONS__)
#ifdef __sparc
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extnamemakecontext __makecontext_v2
#else
#define makecontext __makecontext_v2
#endif
#endif  /* __sparc */
#endif  /* !defined(_XPG7) || ... */

However, libasan knows nothing about this and just intercepts unadorned
makecontext, but this interceptor is never called.

I've got a patch (attached for reference) that changes the makecontext
interceptor to call __makecontext_v2 instead on Solaris/SPARC.  With
this, the c-c++-common/asan/swapcontext-test-1.c test now PASSes on
Solaris/SPARC.

I'm going to submit it upstream soon.