Advertisement Jump to content
Sign in to follow this  

Lua in SDL causing a crash...

This topic is 4881 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having an annoying problem trying to get an SDL program to use lua. I init lua like in the article here on gamedev and everything seems to init fine. But the second I try to use lua_dostring or lua_dofile the program crashes with an SDL error that says Fatal signal: Segmentation Fault (SDL Parachute Deployed) not exectly a lot of help. when I comment the dostring and dofile out it works just fine. I've heard that Lua isn't thread safe but I'm not doing any thread work here... can someone point me in the right direction here? I init Lua with:
	// open lua
	g_luaVM = lua_open();

	// check lua opened correctly
	if (NULL == g_luaVM)
		fprintf(stderr, "Error initializing lua.\n");
		return false;

	// initialize lua standard lib functions

and I try to execute lua code scripts with : lua_dostring(g_luaVM, "a = 5;"); I'm just trying to execute the simplest code I can think of. (this same exact code works just fine in a win console application (quite frustrating))

Share this post

Link to post
Share on other sites
Segmentation Faults occur when you're pointing to a null pointer using SDL. Start up your debugger and check all of your pointers over again, you're pointing to something that hadn't been initialized (or you initialized it incorrectly). It's not Lua's problem, it's SDL's [cool].

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!