Jump to content
The simFlight Network Forums

Lua causing crash to desktop


Recommended Posts

Hi All.

I've developed this script to perform a cold an dark startup and to issue key presses if the hat switch is moved. The keys then change cameras defined in EzCam Views. In the main section I enable a series of button events and key events.

This is fine when I select an aircraft for the first time, but if I change aircraft after that, I get a crash to desktop.

The only solutions to this CTD are either to use Lua Kill All at the end of every flight or to remove the lines between startColdAndDark(0, 0, 0) and setowndisplay("PRE-FLIGHT BRIEFING", 5, 10, 30, 25).

It seems that the Lua thread is not terminating on change of aircraft for some reason, (possibly a problem on Windows 10?).

Is there any kind of destructor method I can use to kill lua automatically if I change aircraft?

Thanks

Pontius.

hat_fore_and_aft.lua

Link to comment
Share on other sites

How is the script being loaded?

The "Kill All" facility simply loops terminating all running plug-ins, each in exactly the same  way as killing them individually by any means.

So, what is this crash? Where are the details? And why do you think it is anything to do with whether the Lua is terminated or not? Why do you think that it not terminating would cause any sort of crash?

Without the lines between startColdAndDark and setowndisplay there are no Events pending to keep the plug-in running in any case, so it simply loads, runs once, and terminates.

Pete

 

Link to comment
Share on other sites

How is the script being loaded? - The script is loaded via the following entries in FSUIPC.ini:

[LuaFiles]
1=hat_fore_and_aft

[Auto]
1=lua hat_fore_and_aft

So, what is this crash? - FSX Freezes and then I get a crash to desktop. Occasionally I get  generic message from Windows that FSX has stopped working but usually nothing.There is no record of a crash in the lua log file but there are two .mdump files left in the FSX main directory.

Where are the details? - The only details are in two .mdump files that are too big to be uploaded. There is nothing in hat_fore_and_aft.log.

And why do you think it is anything to do with whether the Lua is terminated or not? - If I kill any lua threads manually before changing aircraft I don't get a crash. I don't understand what else this could mean except that either a Lua plug in is still running or that the events are not being cancelled when the plug in is terminated by changing aircraft.

Why do you think that it not terminating would cause any sort of crash? - I can only guess that it is failing when it tries to create the button events a second time because they're still there. But this is guess work as I can't look inside lua to see what's happening.

But what I do know is that manually killing the plug in before changing aircraft prevents the crash.

So what I need to know is how I access the destructor method of the lua hat_fore_and_aft and either kill the script or cancel the button and key events.

Pontius.

Link to comment
Share on other sites

10 hours ago, Pontiusthepilot said:

How is the script being loaded? - The script is loaded via the following entries in FSUIPC.ini:

[LuaFiles]
1=hat_fore_and_aft

[Auto]
1=lua hat_fore_and_aft.

The first part, the [LuaFiles] section, is entirely automatic, and is not relevant.

The [Auto] section loads the plug-in for the entire session. Only profile-specific Auto sections will load and kill plug-ins according to the aircraft loaded. Were you expecting your plug-in to close and reopen across each aircraft reload?

10 hours ago, Pontiusthepilot said:

So, what is this crash? - FSX Freezes and then I get a crash to desktop. Occasionally I get  generic message from Windows that FSX has stopped working but usually nothing.There is no record of a crash in the lua log file but there are two .mdump files left in the FSX main directory.

Where are the details? - The only details are in two .mdump files that are too big to be uploaded. There is nothing in hat_fore_and_aft.log.

Windows crashes are recorded in the Windows error logs. That is the information needed. There is no way I can help without that. Go to the START menu in Windows and enter "Event Viewer", then find your crash.

10 hours ago, Pontiusthepilot said:

And why do you think it is anything to do with whether the Lua is terminated or not? - If I kill any lua threads manually before changing aircraft I don't get a crash. I don't understand what else this could mean except that either a Lua plug in is still running or that the events are not being cancelled when the plug in is terminated by changing aircraft

The way you are starting the plug-in is universal, it is meant to continue for the entire session.  There is something else causing the crash when changing aircraft. I have many plug-ins running for whole sessions.

10 hours ago, Pontiusthepilot said:

Why do you think that it not terminating would cause any sort of crash? - I can only guess that it is failing when it tries to create the button events a second time because they're still there.

No, the whole plug-in is still running. There is nothing about changing aircraft which would influence it. It is much more likely to do with your view options. But I can't tell anything with no crash data.

Pete

Link to comment
Share on other sites

Ok

I've managed to get this from the windows event viewer.

Other than that, it looks like I will have to re factor some of this anyway, as it looks like I'll have to code cold and dark starts individually for some aircraft. But if I can get the button events set up once and for all at the beginning of the session, then all the better.

16 hours ago, Pete Dowson said:

It is much more likely to do with your view options

I've just tried removing the custom EzCam views from two aircraft and then attempted to change between them mid flight. FSX still crashes, so I can't rule these out as the cause by experiment.

Pontius.

fsx.evtx

Link to comment
Share on other sites

19 hours ago, Pontiusthepilot said:

I've managed to get this from the windows event viewer

Sorry, I can't seem to do anything with your attached file. Couldn't you simply copy and paste the details?

The only relevant parts are Module Name, Module Offset and Error Code,. If the Module name quoted is FSUIPC I can look into it with that data. If it is something else then it is unlikely.

I'll see if I can adapt the Lua code to run here so I can test on my system. I don't have EZCA but you say it happens in any case without EZCA running?

Pete

 

Link to comment
Share on other sites

By changing your Joystick number to one matching my SideWinder, I can use the hat and see the keypresses being sent. The "PRE_FLIGHT BRIEFING" is displayed okay, and throughout I can change aircraft with no problems, no crashing occurring. This is with both P3D3.3. and FSX-SE.

So I think it is some sort of interaction with something else on your setup. There is certainly no reason for such a simple Lua program thread crashing the sim -- far more complex ones that that are running continuously on my cockpoit, and many others (thanks to LINDA, on the whole).

If you do want the plug-in to terminate and restart of changing aircraft the best way is to have it loaded in a Profile dependent manner. If you wish it to just terminate you can use the ipc.exit function, making it dependent on a change in the Aircraft title offset (3D00), or, to do it on simple aircraft reloads too, the aircraft change count at 32FC.

Pete

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.