Guard error exception message at end of program


#1

Hi, I have been using ChaiScript for awhile, and it’s been great thus far. I have run into a problem, in visual studio 2015, where multiple messages of
"Exception thrown at 0x75E6C41F in ChaiScripting.exe: Microsoft C++ exception: chaiscript::exception::guard_error at memory location 0x001ACA88." outputs after the program is ended.

I was able to reduce the problem down to this form:

#include <chaiscript\chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>
#include <functional>

int main(void)
{
	chaiscript::ChaiScript chai(chaiscript::Std_Lib::library());
	chai.eval(R"(
class A
{
    var value;
    def A()
    {
    }
}
)");
	chai.eval(R"(
class B
{
    var value;
    def B()
    {
        print("B constructor called");
    }
}
def setValue(object, new_value)
{
    print("Set value called");
    object.value = new_value;
}
)");
	
	chaiscript::Boxed_Value m_value = chai.eval<chaiscript::Boxed_Value>("B();");
	auto function = chai.eval < std::function<void(chaiscript::Boxed_Value&, int)>  >("setValue");
	function(m_value, 10);

	return 0;
}

Additionally, if I were to switch the order of the evalulation, the error message goes away. Do advise if there’s anything I’m doing wrong, thanks!

Weekiat


#2

So, to be clear, the exceptions are happening internally, they do not crash the application, correct?

Can you by any chance post a screenshot of a stack trace or anything when this happens?

-Jason


#3

Hi Jason,

Sorry for the late reply! The exceptions do not crash the program, but they look worrying when the program closes. Here’s the output screenshot of the above test case! This was done on visual studio 2015, chai script 5.8.1

Cheers!
-Weekiat