Program will not quit completely. Stays in task manager with services

I have a Windows compiled app running on Windows Server 2012. When quiting the app on that Server, it almost always closes all open windows, but continues to run, visible in Task Manager down where services are.

I usually get an error saying the app has stopped working, giving the option to force close it.

image

We have been through all of the compatibility modes with no success, but here is the Details when this pops up:

Problem signature:
Problem Event Name: BEX
Application Name: publish To DM.exe
Application Version: 1.0.0.99
Application Timestamp: 5b636dee
Fault Module Name: ntdll.dll
Fault Module Version: 6.3.9600.20718
Fault Module Timestamp: 636f3368
Exception Offset: 000f56c4
Exception Code: c000000d
Exception Data: 00000000
OS Version: 6.3.9600.2.0.0.16.7
Locale ID: 1033
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: ff84
Additional Information 4: ff847098ee7efa49c70e06e469a2896b

Can anyone help with this?

Thanks,
Rocky Scofield

Does the application open multiple windows? Also what is the value of App.AllowAutoQuit ?

If you have a main window and you want the application to quit when that closes you could add Quit to App.closing .

1 Like

I have the same issue sometimes also on Windows and Mac with some Shell tasks in background (which are finished before I close the app (multi-window)).
I found out that there are no tasks left in the Task Manager if you close the app over File > Exit but tasks may remain if you use the close button (“x”) of the app window.I don’t know where/why Xojo behaves different in those two closing ways.

Thank you both for your replies. I am still working on a solution for this.

It closes gracefully as expected on Win10, just not on Server 2012.

Rocky

Quiting how?

Hi, Ivan. Thanks for the question.

This app does not have any separate processes (timers or threads) to close. So, when the user selects a close option, it runs through routines to make sure there is no unsaved work in any modules (windows), etc.

The last thing it does in the app.close event is to loop through any open windows (that could have been missed in the other closing ruotines) and closes them just to be sure.

Since the app closes as it should in Win10, I am fairly certain it has something to do with compatibility between Xojo and the 2012 server (basically Win8, I think).

I never mentioned that I am working in Xojo 2018r2. I don’t intend to upgrade until there is an official release Android.

Is App.Close actually firing?

Hi, Tim.

Yes, the program always successfully reaches app.close.

This program has been in service for a number of years on around 30 laptops running Win10, with no problems closing.

It has to be some sort of conflict with Win Server 2012. I have another Xojo program that is only for this same server. It does the same thing. The IT guy at my clients company will even consider using MS support for a server that old. So, I am looking elsewhere for solutions.

Rocky

This could be the cause of the problem. I can’t explain how without examining the project, but I have seen problems caused by over-zealous Close events.

For what it’s worth, if the Close event is firing the app intends to close. CancelClose has come and gone, the app is exiting now. When the app intends to close, all the windows will close with it. You do not need to do so.

Hi, Tim. Thanks for your response.

I added the loop to close the windows AFTER I was having problems on the 2012 server, just to make sure there was no issue. So, I have the same problem with and without that window.close loop

There are two other things in the app.Close event:

  1. mutexOneAppAtATime.Leave
  2. Valentina.ShutDownReports

I suppose both of those could be moved to the bottom of CancelClose.

Rocky

  1. Does it happen if you start and stop the app on W2012 before it does anything else or does it happen after it’s been running for a while ? Are you able to quickly replicate it on a regular and repeatable basis?

  2. Have you tried it on a fresh W2012 install in a VM? Does it also happen there?

  3. Is there only one user on the W2012 machine or is it a host for a multiuser remote desktop?

  4. Is this app the only instance of it running on the machine? (see 3)

  5. Have you installing the xojo remote debugger (in extras) or the xojo ide on the W2012 machine to see if its stuck in an infinite loop during shutdown causing the process to hang?

Those are some great in-depth questions, Julian. I will respond below each one.

  1. Does it happen if you start and stop the app on W2012 before it does anything else or does it happen after it’s been running for a while ?

Great observation. It almost always closes correctly if I immediately close it after opening it. If I do anything in the open app, it has issues when closing.

Are you able to quickly replicate it on a regular and repeatable basis?

The closing issue is consistent. Nothing I have tried has made any difference.

  1. Have you tried it on a fresh W2012 install in a VM? Does it also happen there?

This is the next step. The IT Guy at my clients company is preparing that for next week. We did already try to disable the AV with no change to the closing issue.

  1. Is there only one user on the W2012 machine or is it a host for a multiuser remote desktop?

This machine is a multiuser remote desktop.

  1. Is this app the only instance of it running on the machine? (see 3)

It is the only instance of it running on Server itself. Once we get this closing issue taken care of , the idea is to have access to this program for multiple, but a limited, number of users. This is not the case yet since we are in the testing stage now.

  1. Have you installing the xojo remote debugger (in extras) or the xojo ide on the W2012 machine to see if its stuck in an infinite loop during shutdown causing the process to hang?

I have not tried to use the Run mode yet. I have an instance of Xojo installed on the server, but I develop this particular program on my local desktop. I have a few iftems that I would need to move to the server from my local machine to get it to compile. I do know that it is getting to app.close though.

Again, great questions. Any suggestions about my responses would be helpful.

Thanks,
Rocky

  1. So not easily repeatable without leaving the software to run for a while? Or are you able to reproduce it every time using similar steps?

  2. You can download W2012 eval here if you want to test it on your computer in a VM (like virtualbox)

  3. Is it being run on the console session (session 0) or as a user?

  4. Left blank

  5. You can put the remote debugger on the server, (its located in C:\Program Files\Xojo\Xojo 2023r1\Extras\Remote Debugger Desktop\Remote Debugger Desktop 64-Bit or similar, depending on version etc.) and you don’t need to install anything on the server as long as you have access to the required port you can do full debugs from your desktop at home.

  6. If you liberally sprinkle your app with system.debuglog(“message”) they will appear when running DebugView which you can use to track things like app state or if its stuck in a loop without having to remote debug or write to a file (that might hang during the crash). These messages will always be displayed and might not be effected like writing to a file for debugging until you are able to run debugging remotely or via xojo installed on the target machine. The IT staff can then filter the output by your app and send you the output after a crash so you can see what state your app was in. The best place to start using this is to place System.DebugLog(CurrentMethodName) at the top of every event, method, etc. that you use so you can see the flow of your app, this will at least display the last block of code it entered before the hang (apologies if you know all this).

  7. Do you use DoEvents anywhere in your app?

  8. Are your windows set to Implicit Instance?

  9. What version of Xojo are you using?

  10. Do you use XojoScript anywhere in your app?

If this was the only problem, the “exe has stopped working” dialog wouldn’t appear, correct?
That’s a crash, not just a hang or an “idle after all windows have closed”, IMO.

Just working through a process of elimination.

This sounds reasonable, but the app makes it to the very bottom of app.close. Could it still be stuck in a loop somewhere at that point? I think this “exe has stopped working” might also come up when a program does not respond to Windows like it should for a certain amount of time.

This would still not explain why it has a clean exit in Win10, but not in Server 2012. There has to be some kind of compatibility issue between Xojo and Server 2012, but not Win10?

Rocky

It seems a bug in the framework adds up to the problem, since after app.close, you don’t have control anymore, from code.
Have you managed to read the Windows logs? (I’ve quickly re-read this thread but didn’t see it mentioned).

Replace the ntdll.dll from a server you trust may resolve it for some users, for others resetting local user profiles in the registry seemed to resolve also.

Or perhaps your application is trying to write a value at windows while it is closing causing an error as the memory it is using is no longer available due to closing.

Thanks for all of your replies. I am still working on this. If I figure it out, I will post the solution here.
Rocky