https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103537

--- Comment #4 from Hedayat Vatankhah <hedayat.fwd at gmail dot com> ---
Well, sorry if I should gave more logs to make it more clear.

Note that the crash happens here:
https://github.com/hedayat/powerfake/blob/a4c80d6628816656796d2e85b4422218da05ce00/powerfake.h#L257

And the problematic code doesn't use any of the parts of the code you
mentioned. 

To make the scope of the problem much less, I replaced main() function as
follows and commented out all other unrelated code:

int main()
{
    SampleClass2 sc2;
    SamplePrivate::Call(sc2);
}

This code certainly doesn't use any of the code you mentioned. It only uses
TAG_PRIVATE_MEMBER macro, which in turn uses TagBase and
PrivateFunctionExtractor structs, and no other code. 

The behavior is as follows:

* without -fstack-protector-strong, with or without any of the sanitize options
the code runs normally. No crash, and not any messages from any of the
sanitizers.

* with -fstack-protector-strong, with or without -fsanitize=undefined, you got
a segmentation fault. Logs when running with -fsanitize=undefined:

/home/hedayat/Projects/powerfake/powerfake.h:257:40: runtime error: load of
misaligned address 0x7f64004083fc for type '<unknown> *', which requires 8 byte
alignment
0x7f64004083fc: note: pointer points here
<memory cannot be printed>
zsh: segmentation fault (core dumped)  ./sample/samples

* with -fstack-protector-strong and with -fsanitize=address, you don't get a
crash, so -fsanitizer=address somehow fixes the problem caused with
-fstack-protector-strong. (Using address sanitizer only causes a crash when I
use OverloadedPrivateFloat::Call(sc2, 5);, which I will investigate. But that
issue seems completely unrelated to this bug. address sanitizer causes a crash
with that function even when -fstack-protector-strong is not used).

Reply via email to