在访问该变量时,将一个布尔变量添加到类声明应用程序崩溃之后。我所做的只是初始化变量。
Ui::SliderWidget::SliderWidget(QWidget *parrent)
: QWidget(parrent),
m_slider(nullptr),
m_main_layout(nullptr),
m_counter_lbl(nullptr)
// m_disable(false)
{
this->setObjectName("SliderWidget");
this->initialize();
// m_disable = false;
}
删除评论应用程序后,消息“AddressSanitizer:heap-buffer-overflow”和“Shadow memory range interleaves”崩溃。对m_disable的任何读或写都会导致问题。在linux中出现此问题。在Windows上一切正常。贝娄是输出。
> =================================================================
==5579==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60700014fd58 at pc 0x0000004e55c7 bp 0x7ffc0dddea70 sp 0x7ffc0dddea60
WRITE of size 1 at 0x60700014fd58 thread T0
#0 0x4e55c6 in Ui::SliderWidget::SliderWidget(QWidget*) ../livemonitornew/Ui/sliderwidget.cpp:17
#1 0x503b2f in Ui::Settings::GameOptions::create_widgets() ../livemonitornew/Ui/Settings/gameoptions.cpp:73
#2 0x503acf in Ui::Settings::GameOptions::initialize() ../livemonitornew/Ui/Settings/gameoptions.cpp:65
#3 0x503795 in Ui::Settings::GameOptions::GameOptions(QWidget*) ../livemonitornew/Ui/Settings/gameoptions.cpp:32
#4 0x50b1bf in Ui::Settings::Preferences::create_tabs() ../livemonitornew/Ui/Settings/preferences.cpp:174
#5 0x50a8fd in Ui::Settings::Preferences::initialize() ../livemonitornew/Ui/Settings/preferences.cpp:100
#6 0x50a452 in Ui::Settings::Preferences::Preferences(QWidget*) ../livemonitornew/Ui/Settings/preferences.cpp:40
#7 0x44d9ff in Ui::ControllerWidget::create_widgets() ../livemonitornew/Ui/controllerwidget.cpp:180
#8 0x44cf76 in Ui::ControllerWidget::initialize() ../livemonitornew/Ui/controllerwidget.cpp:101
#9 0x44c419 in Ui::ControllerWidget::ControllerWidget(QWidget*) ../livemonitornew/Ui/controllerwidget.cpp:35
#10 0x42c9ec in Controller::initialize() ../livemonitornew/controller.cpp:105
#11 0x42c4c5 in Controller::Controller(QSharedPointer<QSharedMemory>, QMainWindow*) ../livemonitornew/controller.cpp:74
#12 0x438399 in main ../livemonitornew/main.cpp:42
#13 0x7fbc7632f82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#14 0x42c168 in _start (/home/mher/Documents/workspace/build-LiveMonitor-Desktop_Qt_5_6_2_GCC_64bit2-Debug/LiveMonitor+0x42c168)
0x60700014fd58 is located 0 bytes to the right of 72-byte region [0x60700014fd10,0x60700014fd58)
allocated by thread T0 here:
#0 0x7fbc794d4532 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99532)
#1 0x503b1f in Ui::Settings::GameOptions::create_widgets() ../livemonitornew/Ui/Settings/gameoptions.cpp:73
#2 0x503acf in Ui::Settings::GameOptions::initialize() ../livemonitornew/Ui/Settings/gameoptions.cpp:65
#3 0x503795 in Ui::Settings::GameOptions::GameOptions(QWidget*) ../livemonitornew/Ui/Settings/gameoptions.cpp:32
#4 0x50b1bf in Ui::Settings::Preferences::create_tabs() ../livemonitornew/Ui/Settings/preferences.cpp:174
#5 0x50a8fd in Ui::Settings::Preferences::initialize() ../livemonitornew/Ui/Settings/preferences.cpp:100
#6 0x50a452 in Ui::Settings::Preferences::Preferences(QWidget*) ../livemonitornew/Ui/Settings/preferences.cpp:40
#7 0x44d9ff in Ui::ControllerWidget::create_widgets() ../livemonitornew/Ui/controllerwidget.cpp:180
#8 0x44cf76 in Ui::ControllerWidget::initialize() ../livemonitornew/Ui/controllerwidget.cpp:101
#9 0x44c419 in Ui::ControllerWidget::ControllerWidget(QWidget*) ../livemonitornew/Ui/controllerwidget.cpp:35
#10 0x42c9ec in Controller::initialize() ../livemonitornew/controller.cpp:105
#11 0x42c4c5 in Controller::Controller(QSharedPointer<QSharedMemory>, QMainWindow*) ../livemonitornew/controller.cpp:74
#12 0x438399 in main ../livemonitornew/main.cpp:42
#13 0x7fbc7632f82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
SUMMARY: AddressSanitizer: heap-buffer-overflow ../livemonitornew/Ui/sliderwidget.cpp:17 Ui::SliderWidget::SliderWidget(QWidget*)
Shadow bytes around the buggy address:
0x0c0e80021f50: 00 00 00 00 00 00 00 00 fa fa fa fa fd fd fd fd
0x0c0e80021f60: fd fd fd fd fd fa fa fa fa fa fd fd fd fd fd fd
0x0c0e80021f70: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fd
0x0c0e80021f80: fd fd fa fa fa fa 00 00 00 00 00 00 00 00 00 fa
0x0c0e80021f90: fa fa fa fa 00 00 00 00 00 00 00 00 00 fa fa fa
=>0x0c0e80021fa0: fa fa 00 00 00 00 00 00 00 00 00[fa]fa fa fa fa
0x0c0e80021fb0: 00 00 00 00 00 00 00 00 04 fa fa fa fa fa fd fd
0x0c0e80021fc0: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
0x0c0e80021fd0: fd fd fd fd fd fa fa fa fa fa 00 00 00 00 00 00
0x0c0e80021fe0: 00 00 00 fa fa fa fa fa fd fd fd fd fd fd fd fd
0x0c0e80021ff0: fd fd fa fa fa fa 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
==5579==ABORTING
SliderWidget
只有6个实例,而sizeof(SliderWidget)
只有72个字节。在m_disable
上阅读或写作之前,它们都是在堆中构建的,没有问题。 Valgrind内存分析器报告“无效写入大小1”警告。有人可以解释发生了什么吗?