Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 21:20:12 UTC, Martin Krejcirik 
wrote:

On Friday, 9 December 2016 at 16:50:05 UTC, unDEFER wrote:

And in mini program it works and shows diagnostic message.
Where my diagnostic message in more complicate program???


Try redirecting stdout and stderr to a file(s). There are cases 
when the console itself can crash.


OK, thank you. Next time with other crashes I will try.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 20:35:07 UTC, Ali Çehreli wrote:

Assuming boundschecking is turned off, I think you get unlucky 
in the mini program and happen to hit a '\0' byte.


No, no.. the program built in debug mode with dub.


Re: The program exits unexpectedly

2016-12-09 Thread Martin Krejcirik via Digitalmars-d-learn

On Friday, 9 December 2016 at 16:50:05 UTC, unDEFER wrote:

And in mini program it works and shows diagnostic message.
Where my diagnostic message in more complicate program???


Try redirecting stdout and stderr to a file(s). There are cases 
when the console itself can crash.


Re: The program exits unexpectedly

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn

On 12/09/2016 08:50 AM, unDEFER wrote:
> On Friday, 9 December 2016 at 14:29:38 UTC, unDEFER wrote:
>> I'm afraid that the problem that my program wants to say something,
>> but there is no "flush" so message leaves in the buffer.
>
> I have found, it was code like:
>
> string path = "C:";
> string parent = path[0..path.lastIndexOf("\\")];

That's a bug because you're not checking the return value of 
lastIndexOf. According to its documentation, lastIndexOf returns -1 if 
it fails to find the needle:


  http://dlang.org/phobos/std_string.html#.lastIndexOf

ptrdiff_t found = path.lastIndexOf("\\");
if (found == -1) {
// Not found
}
else {
// Now we can use it:
string parent = path[0..path.lastIndexOf("\\")];
// ...
 }

The added complication is the fact that ptrdiff_t can be converted to 
size_t and you get a huge string when doing path[0..path.lastIndexOf("\\")]


Do you have boundschecking turned off? It should catch such an error.

> And in mini program it works and shows diagnostic message.
> Where my diagnostic message in more complicate program???

Assuming boundschecking is turned off, I think you get unlucky in the 
mini program and happen to hit a '\0' byte.


Ali



Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 14:29:38 UTC, unDEFER wrote:
I'm afraid that the problem that my program wants to say 
something, but there is no "flush" so message leaves in the 
buffer.


I have found, it was code like:

string path = "C:";
string parent = path[0..path.lastIndexOf("\\")];

And in mini program it works and shows diagnostic message.
Where my diagnostic message in more complicate program???


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
I'm afraid that the problem that my program wants to say 
something, but there is no "flush" so message leaves in the 
buffer.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 10:08:24 UTC, unDEFER wrote:

On Friday, 9 December 2016 at 09:42:52 UTC, unDEFER wrote:
Exceptions works good, and prints debug message always. It is 
not exception..
I have tried to add try/catch around full loop of the program. 
It doesn't work. And program has infinite loop.

But maybe it is unhandled signal?


I have found. It exits on "stdout.flush()"


Without flush falls in different places.. And in the console 
leaves not fully printed lines.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 09:42:52 UTC, unDEFER wrote:
Exceptions works good, and prints debug message always. It is 
not exception..
I have tried to add try/catch around full loop of the program. 
It doesn't work. And program has infinite loop.

But maybe it is unhandled signal?


I have found. It exits on "stdout.flush()"


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 09:29:36 UTC, rikki cattermole 
wrote:

On 09/12/2016 10:26 PM, unDEFER wrote:
An exception/error might be thrown, try catching Error's in the 
threads function.

Also try adding an infinite loop to it.


Exceptions works good, and prints debug message always. It is not 
exception..
I have tried to add try/catch around full loop of the program. It 
doesn't work. And program has infinite loop.

But maybe it is unhandled signal?


Re: The program exits unexpectedly

2016-12-09 Thread rikki cattermole via Digitalmars-d-learn

On 09/12/2016 10:26 PM, unDEFER wrote:

Hello!
I'm starting port my program to Windows _without_ Cygwin and found big
trouble.
My main thread exits unexpectedly without any diagnostic messages. The
second thread still lives when it happens.
The visual studio debugger say that thread exits with code 2.
What it maybe?


An exception/error might be thrown, try catching Error's in the threads 
function.

Also try adding an infinite loop to it.


The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

Hello!
I'm starting port my program to Windows _without_ Cygwin and 
found big trouble.
My main thread exits unexpectedly without any diagnostic 
messages. The second thread still lives when it happens.

The visual studio debugger say that thread exits with code 2.
What it maybe?