How to get started? Access violation


Hi all,

I’ve downloaded chai for Win32. My program will be a Win32 app but I’m developing on Win64 (8.1 unfortunately…)

I’m using VS2013 and after installing chai I can build the example from the main chai page but I can’t run it. I get an access violation during creation of the chai object in the example. The av seems to come from xutility a vc file.

Just wondering how to proceed to get going with this? I’m developing under Qt creator and using VS2013 compiler. I can’t even build in that environment. I get errors in the chai engine include.

A little guidance would be much appreciated. If I need to dev a Win32 app should I install the win32 version of chai or the 64 since my dev system is 64 bit?


VS2013, VS2015, and many versions of MinGW and Cygwin should work fine.

If you are making a debug build, the system should give you more information than just an access violation. Can you please provide all of the details?

Please check the following:

  • Do you have the latest update for Visual Studio installed? Update 3 is absolutely required, as Microsoft has fixed many compiler bugs, and Update 4 is suggested.
  • Have you tried configuring and building the CMake configuration, to make sure that works properly?
  • Which example exactly are you trying to compile in and run?


For the sake of reference, you can see here the compilers that are checked with each commit:


I appear to be having the same problem. (Reviving this because it’s where google directs the search for chaiscript access violation).
Looks like it’s happening when chai tries to load the stdlib module. The throw occurs inside the lambda expression of apply(…).
Below is the call stack from VS2013 (building for win32 with toolset v120). Hope this sheds some light on the situation.

Project.exe!std::_Iterator_base12::_Adopt(const std::_Container_base12 * _Parent) Line 166	C++
Project.exe!std::_Iterator_base12::operator=(const std::_Iterator_base12 & _Right) Line 129	C++
Project.exe!std::_Iterator_base12::_Iterator_base12(const std::_Iterator_base12 & _Right) Line 121	C++
Project.exe!std::_Iterator012<std::random_access_iterator_tag,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,int,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const *,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const &,std::_Iterator_base12>::_Iterator012<std::random_access_iterator_tag,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,int,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const *,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const &,std::_Iterator_base12>(const std::_Iterator012<std::random_access_iterator_tag,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,int,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const *,std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > const &,std::_Iterator_base12> & __that)	C++
Project.exe!std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > >::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > >(const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > > & __that)	C++
Project.exe!chaiscript::Module::apply<chaiscript::detail::Dispatch_Engine,std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > > >(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > > begin, const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<std::pair<chaiscript::Type_Info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > > end, chaiscript::detail::Dispatch_Engine & t) Line 228	C++
Project.exe!chaiscript::Module::apply<chaiscript::ChaiScript,chaiscript::detail::Dispatch_Engine>(chaiscript::ChaiScript & t_eval, chaiscript::detail::Dispatch_Engine & t_engine) Line 190	C++
Project.exe!chaiscript::ChaiScript::add(const std::shared_ptr<chaiscript::Module> & t_p) Line 731	C++
Project.exe!chaiscript::ChaiScript::load_module(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & t_module_name, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & t_filename) Line 814	C++
Project.exe!chaiscript::ChaiScript::load_module(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & t_module_name) Line 770	C++
Project.exe!chaiscript::ChaiScript::ChaiScript(std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > t_modulepaths, std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > t_usepaths) Line 515	C++
Project.exe!main() Line 26	C++
[External Code]


Almost certainly you are trying to load a stdlib that was compiled with different settings then the executable you are running.

If you are using the stdlib that shipped with the windows download, be aware that it is a release build. It is always best to compile the stdlib yourself to make sure you don’t run into issues like this.

Please verify what happens if you run the “compiled in stdlib” example from here


You are exactly right.
Compiling the stdlib myself fixed the problem entirely.
I should have realized that when the stdlib include method worked flawlessly.