[Lazarus] Console application does not close cleanly!

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Console application does not close cleanly!

Bo Berglund
I was using Lazarus to create a console application for parsing out
data from a network speed test program.

In this case I used the Lazarus new project dialogue and specified a
console application with all the defaults.

This creates an application framework including command line parameter
parsing, which is good. I use the cl to pass file names (input and
output).

My problem is this:
I went to the section in DoRun where it states:
  { add your program here }

This is exatly what I did. The code parses out a report file and
extracts the valid data, then writes it out to a file (append at end
of that file) using TStringList.SaveToFile.
This all works fine so far, but when this is done the code gets to the
predefined statement:

  // stop program loop
  Terminate;

And here I am getting an exception:
External: SIGSEGV

If I comment out Terminate then the program never ends....

Is this specific to Ubuntu Linux or is it some error in my coding that
causes this?

I am using two objects in the DoRun, one TStringList and one object i
created for parsing the data. Both are created and then freed in a
try-finally construct before the Terminate call.

All is fine up until this spot, the file is parsed and the result is
written, yet I get the exception.

Can someone please explain this?


--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
ik
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Console application does not close cleanly!

ik





On Sun, Apr 10, 2011 at 22:20, Bo Berglund <[hidden email]> wrote:
I was using Lazarus to create a console application for parsing out
data from a network speed test program.

In this case I used the Lazarus new project dialogue and specified a
console application with all the defaults.

This creates an application framework including command line parameter
parsing, which is good. I use the cl to pass file names (input and
output).

My problem is this:
I went to the section in DoRun where it states:
 { add your program here }

This is exatly what I did. The code parses out a report file and
extracts the valid data, then writes it out to a file (append at end
of that file) using TStringList.SaveToFile.
This all works fine so far, but when this is done the code gets to the
predefined statement:

 // stop program loop
 Terminate;

And here I am getting an exception:
External: SIGSEGV

If I comment out Terminate then the program never ends....

It's a feature (the Terminate), not a bug.
The program is executed in a loop that parses data such as events and more (regardless of it being terminal app).
Terminate "break" the loop and allow you to finish the execution.
 

Is this specific to Ubuntu Linux or is it some error in my coding that
causes this?

I am using two objects in the DoRun, one TStringList and one object i
created for parsing the data. Both are created and then freed in a
try-finally construct before the Terminate call.

All is fine up until this spot, the file is parsed and the result is
written, yet I get the exception.

Can someone please explain this?

Can you execute it with debug code and see where the crash happens ?
 


--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Ido
LINESIP - Opening the source for communication
http://www.linesip.com
http://www.linesip.co.il

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Console application does not close cleanly!

Bo Berglund
On Sun, 10 Apr 2011 23:32:57 +0300, ik <[hidden email]> wrote:

>> Is this specific to Ubuntu Linux or is it some error in my coding that
>> causes this?
>>

[blush]...
I made a silly mistake of creating and freeing the same object twice
(in constructor/destructor plus in a method)!
Of course freeing twice is not such a good idea....


--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus