Hello Guest it is March 28, 2024, 05:27:45 AM

Author Topic: Lua Editor Crashing  (Read 3063 times)

0 Members and 1 Guest are viewing this topic.

Lua Editor Crashing
« on: February 06, 2017, 05:29:22 PM »
Is anyone else having a problem with the lua editor crashing when debugging? I have been trying to write and debug some scripts but it is very slow and frustrating due to the constant crashes.

I have tested on two different pc's and it crashes for me every time even with a simple piece of test code such as:-

if(1 == 1) then
end

One PC is running Windows Vista 32 bit and has the Darwin Printer Port driver installed.
The other PC is running Windows 10 and does not have Darwin installed.
Both have Mach4 version 4.2.0.3233 installed.

From what I can tell it happens when the debugging session is ending as even with something more complicated it will always reach a break point on the last piece of code that gets executed, assuming of course there are no errors! Also if I terminate the debug session using Shift-F5 it does not crash.

Alastair



Re: Lua Editor Crashing
« Reply #1 on: February 07, 2017, 12:36:34 AM »
Hi Alastair,
I've had exactly the same problem. I made some enquires about it and Daz-The-Gaz wrote:
Quote
As you would of gathered by now Mach4 is quite reliant on lua, this is used within the gui and in macros etc.. we all have a tinker and tweek the scripts to our liking but we also dont always see some of the problems with a tiny bit of code thats just not quite right. In light of this it can sometimes crash parts of mach4 that we are not aware of, this can lead to parts not working like they should or an incomplete shutdown cycle.
I know from experience that unless mach4 shuts down gracefully it will not find the ESS until a power cycle is done, this is because the ESS still thinks its connected

When I started coding in LUA the number of mistakes and consequent crashes was very frustrating. It does improve.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Lua Editor Crashing
« Reply #2 on: February 07, 2017, 03:29:43 PM »
Hi Craig

Thanks for the reply. I am glad it is not just me although I would prefer if it was neither of us!!

I wouldn't mind so much if it was a fault in the script that caused the crash, I have had plenty of those as well. Although it does bother me that some crashes take down Mach4, leave a Mach4GUI process running that you cannot kill from the task manager and prevent the computer from shutting down properly requiring the power to be forcefully removed. But that is probably another topic!

Getting back to this issue, a simple script like the one posted doesn't do anything so should not crash the editor. As this happens every time on two different PC's it would suggest that I am doing something with the install or configuration that is causing the problem or there is an issue with the Lua, Mach4 or the implementation of Lua in Mach4. For reference the install on the Windows 10 PC has all the default settings and has not been altered in any way.

I would appreciate if anyone could spare a few minutes to try this simple case and let me know what happens.
Even a one liner like the following crashes the editor for me on both PC's when trying to debug by hitting F5.

local x = 1

Alastair

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Lua Editor Crashing
« Reply #3 on: February 07, 2017, 04:44:59 PM »
Well I have run both bits of code you posted and both ran fine, out of curiosity you might want to check to see if any firewall of any kind is blocking the editor from connecting to the mach4 core.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Lua Editor Crashing
« Reply #4 on: February 07, 2017, 05:17:28 PM »
Thanks DazTheGaz.

I have tried disabling firewall, antivirus, windows defender, etc but it does not help. Now that I have confirmation that it can work ok I will have to dig a bit deeper to see if I can track down a cause.

For anyone else having this issue a possible workaround is to put a breakpoint on the last line executed and end the debugging session using Shift F5 rather than let it end on its own. If I do this it doesn't crash the editor although it is not possible to do this in every case. Perhaps someone knows what happens differently when exiting debug with Shift F5 as opposed to letting it end on its own. Might help narrow it down.

Alastair
Re: Lua Editor Crashing
« Reply #5 on: February 08, 2017, 06:03:52 PM »
Quick update

Adding wx.wxExit to the end of the script prevents the editor from crashing at the end of a debug, for me at least. The wxWidgits manual states that this call should only be used in an emergency. So far I have not seen any issues apart from Mach4 closing if it is called outside of a debug session. Adding it as below will ensure it only gets called when the script is running in the editor.

Code: [Select]
if(mc.mcInEditor() == 1) then
    wx.wxExit()
end

Alastair

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Lua Editor Crashing
« Reply #6 on: February 08, 2017, 07:21:10 PM »
I think instead of finding a work around, the reason why it cant come out of a debug session should be found, I have never know this problem yet and adding wxExit could be problem for you down the line.

DazTheGas

New For 2022 - Instagram: dazthegas
Re: Lua Editor Crashing
« Reply #7 on: February 09, 2017, 03:32:52 PM »
I agree finding the cause of the problem would be better. I spent 4+ hours last night trying eveything could think of, including temproeraly removing firewall / anti-virus, reinstalling Mach4, creating fresh profiles, disabling plugins(removed from the plugins folder completly to make sure). At this point i have to admit defeat!

I will remove wx.wxExit once I have finsihed working on the scirpt just in case.

What is the normal message in the output window when a script ends. If I let it run through just before the editor crashes the output window displays:-
Killed debuggee session (number)
debug session finsihed

If I stop at a breakpoint and end the session with Shift F5 the the message is:-
Debuggie client stopped
debug session finished.

With wx.wxExit the message is just
Debug session finished.

Alastair

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Lua Editor Crashing
« Reply #8 on: February 09, 2017, 04:58:38 PM »
Normal ending for me is

At Breakpoint line: 10 file: C:\Mach4Hobby\Profiles\Mach4Mill\Macros\m6.mcs
Killed debuggee process 3052.
Debug session finished.

DazTheGas

New For 2022 - Instagram: dazthegas
Re: Lua Editor Crashing
« Reply #9 on: February 09, 2017, 05:36:51 PM »
Thanks DazTheGas

I am going to give up on it for now. I have the machine almost set up and working, just a few more input and output signals to map for the pendant.

By the way, thanks for taking the time to post the videos. They are very helpful.

Alastair