在Embarcadero C++Builder 12.3中使用ASAN搭配VCL遇阻求助
求助:在Embarcadero C++Builder 12.3的VCL表单中使用Address Sanitizer(ASAN)失败
当启用ASAN(Win64X目标)运行项目时,IDE中会抛出(0xc0000005 encountered at address...)这类异常,在Windows命令提示符下执行则弹出"The application was unable to start correctly (0xc0000142)"错误。已尝试静态/动态链接、启用/禁用运行时包等多种配置,但问题依旧。
请问有人成功在Embarcadero C++Builder 12.3的VCL表单中使用ASAN吗?能否提供相关技巧?
IDE回调堆栈
:00007FFF1EB63F80 __asan::PoisonShadow(unsigned long long, unsigned long long, unsigned char)() :00007FFF1EB4A62E __sanitizer::SizeClassAllocator64<__asan::AP64<__sanitizer::LocalAddressSpaceView>>::MapWithCallbackOrDie(unsigned long long, unsigned long long, char const*)() :00007FFF1EB4A520 __sanitizer::SizeClassAllocator64<__asan::AP64<__sanitizer::LocalAddressSpaceView>>::Init(int, unsigned long long)() :00007FFF1EB47FEC __asan::Allocator::InitLinkerInitialized(__asan::AllocatorOptions const&)() :00007FFF1EB6B7A0 __asan::AsanInitInternal()() :00007FFF1EB7414F __do_global_ctors() :00007FFF1EB741A0 __main() :00007FFF1EB213F5 __DllMainCRTStartup() :00007FFF1EB212C2 DllMainCRTStartup() :00007FFFA0CD8B8F RtlActivateActivationContextUnsafeFast() :00007FFFA0D1D63D RtlEnumerateEntryHashTable() :00007FFFA0D1D3EE RtlEnumerateEntryHashTable() :00007FFFA0D1D460 RtlEnumerateEntryHashTable() :00007FFFA0D8EE69 LdrInitShimEngineDynamic() :00007FFFA0D7AB16 EtwLogTraceEvent() :00007FFFA0D24523 LdrInitializeThunk() :00007FFFA0D2444E LdrInitializeThunk()
测试示例代码
#include <vcl.h> #pragma hdrstop #include "MyAsanTest.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { MyCB->Checked = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::TestButtonClick(TObject *Sender) { if (MyCB->Checked) { Memo1->Lines->Append("MyCB is checked"); } else { Memo1->Lines->Append("MyCB is not checked"); } }
头文件示例
//--------------------------------------------------------------------------- #ifndef MyAsanTestH #define MyAsanTestH //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TCheckBox *MyCB; TMemo *Memo1; TCheckBox *My2ndCB; TButton *TestButton; void __fastcall TestButtonClick(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif
示例表单

内容的提问来源于stack exchange,提问作者JonT
相关产品推荐
相关产品推荐

