Results 1 to 10 of 10

Thread: A problem caused the program to stop working correctly

  1. #1

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    A problem caused the program to stop working correctly

    OS: Windows 10 Pro
    Application: VB6 exe (please don't ask why - proprietory code)

    We have sporadic instances of Windows 10 shutting down the app stating it has stopped working. The same function / feature works on the same machine many times. But sometimes it just gives up.

    So far we haven't been able to identify any pattern as to why these errors are occurring. We have tried most of the tricks in the book, but no luck.

    The function in question takes a string input by the user in a textbox, sends it to a webservice through an XMLHttpRequest, and receives XMLHttpResponse in return from the webservice. We have been able to confirm that the webservice returns a response. Thereafter the application is supposed to parse the response and load some data in a list. This part never executes when the app crashes.

    The same machine with the same OS and the same app and the same input string and the same webservice runs fine for hours, even days. And then once in a while, it crashes.

    Since it's the OS shutting down the app, I don't think we can handle it with the On Error construct. Any other ideas to handle such errors would of course be great. Will the QueryUnload event of the main form help here?
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: A problem caused the program to stop working correctly

    Are there any clues in the crash report in the Event Log? I haven't seen any crashes of this description myself.

    I'm not sure why you'd hope the QueryUnload event would be of any service here. It is probably never raised.

  3. #3
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: A problem caused the program to stop working correctly

    Does the Win 10 machine go to sleep? Even though applications are restored when woken up, some of the basic system functions are not (for example network connections). When the problem occurs, run a "netstat -an" from the command prompt to see if there are any stranded connections (TIME_WAIT/FIN_WAIT). A VB program that stops responding is usually caught in an endless loop and stops responding to system messages.

    The other thing you can do is log "Debug.Print" commands to file when the .exe is running. I use this routine for that purpose:
    Code:
    Public Sub PrintDebug(Msg As String)
        Debug.Print Msg
        If DbgFlg Then Call LogError(Msg)
    End Sub
    By setting the DbgFlg, it prints the regular debug messages in the IDE, but logs them to file in the .exe.

    J.A. Coutts

  4. #4

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: A problem caused the program to stop working correctly

    Quote Originally Posted by dilettante View Post
    Are there any clues in the crash report in the Event Log? I haven't seen any crashes of this description myself.

    I'm not sure why you'd hope the QueryUnload event would be of any service here. It is probably never raised.
    I have asked for the event logs, will post here if I find something amiss. About QueryUnload, I am not sure if it gets fired, I had a hunch it would probably be called even if the OS tried to shut down the program, but my knowledge of VB6 is kinda rusted now. It's been years since I worked on it.

    Quote Originally Posted by couttsj View Post
    Does the Win 10 machine go to sleep? Even though applications are restored when woken up, some of the basic system functions are not (for example network connections). When the problem occurs, run a "netstat -an" from the command prompt to see if there are any stranded connections (TIME_WAIT/FIN_WAIT). A VB program that stops responding is usually caught in an endless loop and stops responding to system messages.

    The other thing you can do is log "Debug.Print" commands to file when the .exe is running. I use this routine for that purpose:
    Code:
    Public Sub PrintDebug(Msg As String)
        Debug.Print Msg
        If DbgFlg Then Call LogError(Msg)
    End Sub
    By setting the DbgFlg, it prints the regular debug messages in the IDE, but logs them to file in the .exe.

    J.A. Coutts
    The machine doesn't go to sleep. It's a pos kind of an app, so constantly in use. Also we have already added code to write to a log table, but we can only find trace till the moment of crash. Which we already know was working fine. After the webservice call returns, if the app crashes, obviously there are no log entries. We know generally the point where the app crashes.

    The code at the time of the crash does not have any infinite loops. It basically just loops through a recordset and populates items in a list. Checked and there's no logical error or any other condition that could lead to an infinite loop.

    I read up on this type of error online, and there are some suggestions which say Windows 10 might (wrongly) think the application has become unresponsive. If that's the case, is there any way the application can "tell" the OS that it's alive and kicking?

    The way I see it, the OS is trying to force the user to shut down the app, and not sure why that would be happening.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  5. #5
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: A problem caused the program to stop working correctly

    There is a program that keeps windows awake, and perhaps you can mimic the idea within your application -
    http://www.zhornsoftware.co.uk/caffeine/
    "It works by simulating a keypress once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver
    Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.
    Note: PowerPoint uses the F15 keypress to pause video in a slide, if you think this may cause you a problem, use the -useshift command line parameter.
    Note: if you use Google Docs, or a terminal emulation app like Putty, you might find that F15 does interfere with what you're doing. In that case, I'd suggest using the -useshift command line option. "

    Rob
    PS This may be more professional -
    "The program uses a Windows function called SetThreadExecutionState which software applications use to tell the operating system they are in use and prevents the computer sleeping"
    That idea, plus some more programs are listed here -
    https://www.raymond.cc/blog/dont-sle...e-and-restart/
    Last edited by Bobbles; Dec 27th, 2017 at 09:52 PM.

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: A problem caused the program to stop working correctly

    Quote Originally Posted by honeybee View Post
    The function in question takes a string input by the user in a textbox, sends it to a webservice through an XMLHttpRequest, and receives XMLHttpResponse in return from the webservice. We have been able to confirm that the webservice returns a response.
    I would investigate exactly that (in more depth).
    The XMLHttpRequest-Object (due to being socket-bound) always performs its actions asynchronously -
    (even when you specify "synchronous behaviour" - in that case only an internal MessageChecking-WaitLoop is performed).

    And the MS-XML-Parser which is used under the covers of that Object, is "known to behave funny" in async-mode (with "not yet fully returned results").

    We had something similar running in a Service-App - and encountered similar unstable behaviour...
    The solution was, to:
    - switch over to the MS-WinHttp 5.1 Object
    - correctly specify its TimeOuts
    - checking (on return) for TimeOut-Reached or not (if yes, returning with an appropriate Err-Message)
    - if not TimeOut-reached, check for a valid http-Reponse-Status
    - if the http-ResponseStatus is Ok, check for valid (XML) Response-Content (because some (rare) sites sometimes return Errors as HTML, if the XML-Service is not reachable)

    Only after all these checks were performed, we feed the returned (and validated) XML-content into a *dedicated* (entirely separated from http-requests) XML-Parser-Object-Instance.

    These changes have proven worthwhile in our sevice-app.

    HTH

    Olaf

  7. #7

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: A problem caused the program to stop working correctly

    Quote Originally Posted by Schmidt View Post
    I would investigate exactly that (in more depth).
    The XMLHttpRequest-Object (due to being socket-bound) always performs its actions asynchronously -
    (even when you specify "synchronous behaviour" - in that case only an internal MessageChecking-WaitLoop is performed).

    And the MS-XML-Parser which is used under the covers of that Object, is "known to behave funny" in async-mode (with "not yet fully returned results").

    We had something similar running in a Service-App - and encountered similar unstable behaviour...
    The solution was, to:
    - switch over to the MS-WinHttp 5.1 Object
    - correctly specify its TimeOuts
    - checking (on return) for TimeOut-Reached or not (if yes, returning with an appropriate Err-Message)
    - if not TimeOut-reached, check for a valid http-Reponse-Status
    - if the http-ResponseStatus is Ok, check for valid (XML) Response-Content (because some (rare) sites sometimes return Errors as HTML, if the XML-Service is not reachable)

    Only after all these checks were performed, we feed the returned (and validated) XML-content into a *dedicated* (entirely separated from http-requests) XML-Parser-Object-Instance.

    These changes have proven worthwhile in our sevice-app.

    HTH

    Olaf
    Thanks, that does make some sense, in that it could be happening in our case.

    If we move the webservice calling part to a DotNet component and consume it via Interop in the VB6 app, do you think the problem would be taken care? I need to do a quick proof of concept to check if this is indeed the case for us, and moving the webservice interfacing code to a DotNet component seems like a future proof idea - hopefully the DotNet framework should take care of the async nature?
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  8. #8

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: A problem caused the program to stop working correctly

    Quote Originally Posted by dilettante View Post
    Are there any clues in the crash report in the Event Log? I haven't seen any crashes of this description myself.

    I'm not sure why you'd hope the QueryUnload event would be of any service here. It is probably never raised.
    Have received screenshots of the event log with two instances referring to our application.

    It's "Event 1002, Application Hang", with details as "The program xyz version xxxxx stopped interacting with Windows and was closed. ....."
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: A problem caused the program to stop working correctly

    Quote Originally Posted by honeybee View Post
    Thanks, that does make some sense, in that it could be happening in our case.

    If we move the webservice calling part to a DotNet component and consume it via Interop in the VB6 app, do you think the problem would be taken care? I need to do a quick proof of concept to check if this is indeed the case for us, and moving the webservice interfacing code to a DotNet component seems like a future proof idea - hopefully the DotNet framework should take care of the async nature?
    IMO there is no need to resort to .NET-interop.
    The WinHttp 5.1-Object is available over the Project-References-Dialogue -
    and when you declare it WithEvents, you can fully manage a truly asynchronous WebRequest entirely COM-based.

    It requires only a handful of Extra-lines of code, to switch from an XMLHttp-Request to WinHttp-5.1 mode.

    Olaf

  10. #10

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: A problem caused the program to stop working correctly

    Quote Originally Posted by Schmidt View Post
    IMO there is no need to resort to .NET-interop.
    The WinHttp 5.1-Object is available over the Project-References-Dialogue -
    and when you declare it WithEvents, you can fully manage a truly asynchronous WebRequest entirely COM-based.

    It requires only a handful of Extra-lines of code, to switch from an XMLHttp-Request to WinHttp-5.1 mode.

    Olaf
    Alright, will give it a shot. Thanks!
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width