Jump to content
  • Advertisement
Sign in to follow this  
Ravenshadow

Lua in SDL causing a crash...

This topic is 4809 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
	lua_baselibopen(g_luaVM);
	lua_iolibopen(g_luaVM);
	lua_strlibopen(g_luaVM);
	lua_mathlibopen(g_luaVM);

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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!