[Bug c++/78651] Incorrect exception handling when catch clause uses local class and PIC and sanitizer are active

2018-03-14 Thread chefmax at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78651

--- Comment #5 from chefmax at gcc dot gnu.org ---
Created attachment 43652
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43652=edit
Untested fix

Simple untested fix that seems to cure the issue.

[Bug c++/78651] Incorrect exception handling when catch clause uses local class and PIC and sanitizer are active

2018-03-14 Thread chefmax at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78651

chefmax at gcc dot gnu.org changed:

   What|Removed |Added

 CC||chefmax at gcc dot gnu.org

--- Comment #4 from chefmax at gcc dot gnu.org ---
Hm, it seems that ASan is breaking internal ABI between GCC and libstdc++ by
adding redzones to global .LDFCM* symbols:

$ ~/install/master/bin/g++ /tmp/throws.cc -fsanitize=address -fPIC -S -o bad.s

...
.LLSDACSE1:
.byte   0x2
.byte   0
.byte   0x1
.byte   0x7d
.align 4
.long   DW.ref._ZTI1A-.
.long   .LDFCM0-.
.LLSDATT1:
...
...
...
.LDFCM0:
.zero   56   <== inserted by ASan
.quad   _ZTIN12_GLOBAL__N_114SomeRandomTypeE
.hidden DW.ref.__gxx_personality_v0
.weak   DW.ref.__gxx_personality_v0
.section   
.data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
.align 8
.type   DW.ref.__gxx_personality_v0, @object
.size   DW.ref.__gxx_personality_v0, 8


AFAU, during exception handling, libstdc++ tries to obtain a pointer to
`typeinfo for (anonymous namespace)::SomeRandomType' from a constant offset
from `.LDFCM0' label and gets zero, because ASan added a right redzone. I
suspect that not sanitizing `.LDFCM*' variables (and probably all other debug
vars) should resolve the issue.

[Bug c++/78651] Incorrect exception handling when catch clause uses local class and PIC and sanitizer are active

2018-03-02 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78651

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-03-02
 Ever confirmed|0   |1

--- Comment #3 from Jonathan Wakely  ---
Confirmed:

struct A { };

namespace {

  void thisThrows() {
throw A();
  }

  struct SomeRandomType {};
}

int main() {
  try {
thisThrows();
  }
  catch(SomeRandomType) {
throw;
  }
  catch(A) {
  }
}

$ g++ throws.cc && ./a.out
$ g++ throws.cc -fPIC && ./a.out
$ g++ throws.cc -fsanitize=address && ./a.out
$ g++ throws.cc -fsanitize=address -fPIC && ./a.out
terminate called after throwing an instance of 'A'
Aborted (core dumped)

[Bug c++/78651] Incorrect exception handling when catch clause uses local class and PIC and sanitizer are active

2018-03-02 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78651

Jonathan Wakely  changed:

   What|Removed |Added

 CC||mikezackles at gmail dot com

--- Comment #2 from Jonathan Wakely  ---
*** Bug 84657 has been marked as a duplicate of this bug. ***

[Bug c++/78651] Incorrect exception handling when catch clause uses local class and PIC and sanitizer are active

2016-12-02 Thread dyp-cpp at gmx dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78651

--- Comment #1 from dyp-cpp at gmx dot net ---
Same issue if the LocalException is a non-local class with internal linkage.