pitue
pitue

Reputation: 27

wxString(const std::string&) throws read access violation in debug build

Like the title suggests the wxString constructor always throws an read access violation exception when I'm running my program in debug mode (not in release mode). I guessed it has something to do with encoding, but I dont know how to fix it. The problem occured when I ported my project from Visual Studio to CMake.

This:

wxString str(std::string("Hello world!"));

throws the exception:

Exception 0xc0000005 encountered at address 0x7ffda0bd8670: Access violation reading location 0xffffffffffffffff

I've looked into the disassembly and wxWidgets throws at

wxMBConv::cMB2WC(char const *,unsigned __int64,unsigned __int64 *)const :
  [...]
  callq  *(%rax)
  [...]

The build specs are:

CMake ver. 3.20.2 in Debug mode
MSVC ver. 16.0 with architecture amd64
LLDB ver. 9.0
wxWidgets ver. 3.1.5#2

All files are encoded in UTF-8 and I would prefer to use UTF-8 with narrow strings

Upvotes: 0

Views: 217

Answers (1)

pitue
pitue

Reputation: 27

I think I found the problem myself. Thanks to vcpkg CMake links the debug build against the release build of wxwidgets, which causes the problems. The issue has been reported here: vcpkg issue 18066

but hasn't been fixed as of now

Upvotes: 1

Related Questions