On Friday, 5 February 2016 at 03:47:40 UTC, tcak wrote:
On Thursday, 4 February 2016 at 22:27:31 UTC, Ali Çehreli wrote:
On 02/04/2016 12:25 PM, tcak wrote:

> [...]

That would happen when there is an exception.

> [...]

If a thread is terminated with an exception, its stack is unwound and unlike the main thread, the program will not terminate. I think this is due to an exception.

> [...]

I think putting a break point at exception construction would be helpful but it will be simpler to put a try-catch block that covers the entire body of threadFunc().

> [...]
this?

I am still betting on an exception. :)

Ali

Yup, it is exception it seems like, but with a weird result. Check the new codes:

void threadFunc(){
        scope(exit){
                writeln("Leaving 2: ", stopRequested);
        }

        scope(failure){
                writeln("Failure");
        }

        try{
                while( !stopRequested ){

                }

                writeln("Leaving 1: ", stopRequested);
        }
        catch( Exception ex ){
                writeln("Caught the exception");
        }
}

Now, the thread stops with:

Failure
Leaving 2: false


There is no "Caught the exception". And believe me other then the codes inside while loop, main structure as seen in the above code.

By testing many times, I understood that the problem occurs when too many requests are received suddenly (by pressing F5 many times again and again produces the exception).

But the question is why try-catch is not able to catch it, and just scope(failure) can?

Okay. The cause of problem has been solved with good-old writeln("DEBUG"); method :)

Cause is trying to access outside of array (e.g. array[$]). But I didn't like that fact that scope(failure) is called for that properly, but no other error was seen.

Environment: MonoDevelop, Linux x64, DMD 2.070, MonoD, running in Debug mode.

Reply via email to