diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-19 10:15:32 -0700 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-05-20 20:18:23 +0200 |
commit | 30a8e79243084017d23f1c765d5f1cbb86564191 (patch) | |
tree | 30ea536021eef269f7fbce81f567bf3162878d50 /tests | |
parent | 8566c2db85a6f579a1a0432d0b7621633158e04c (diff) |
QCallableObject: work around VS2022 compiler bug
Address Sanitizer in Visual Studio reported:
==17744==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x11ffe2ba0760 at ...
WRITE of size 1 at 0x11ffe2ba0760 thread T0
0x11ffe2ba0760 is located 0 bytes to the right of 16-byte region [0x11ffe2ba0750,0x11ffe2ba0760) allocated ...
Disassembly of QCallableObject's constructor shows that the compiler did
emit that 1-byte store of a null byte, 16 bytes after the object start,
of an object whose size is 16 bytes. The location of this code implies
it was the initialization of the StorageEmptyBaseClassOptimization
sub-object. Without an explicit constructor, this was an aggregate
initialization.
This seems to be the same issue as [1]. The workaround is to give it an
explicit constructor, the same workaround as [2].
I suppose other people using Empty Base Optimization haven't run into
this issue because that empty base usually overlaps something inside the
object. So an alternative workaround would be to invert the order of
derivation such that StorageEmptyBaseClassOptimization was the first
base.
[1] https://developercommunity.visualstudio.com/t/address-of-empty-base-class-is-wrong-c-bad-code-ge/322444
[2] https://developercommunity.visualstudio.com/t/empty-class-derived-from-empty-base-class-causes-r/451088
Change-Id: I5f7f427ded124479baa6fffd17609adca0f8e235
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
0 files changed, 0 insertions, 0 deletions