Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-04

Console application does not close cleanly!

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

ik
to Bo Berglund
Bo Berglund wrote 28 lines
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.

Show quoted text 13 lines
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 ?

Show quoted text 13 lines
-- Bo Berglund Developer in Sweden -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Ido
LINESIP - Opening the source for communication
http://www.linesip.com
http://www.linesip.co.il
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110410/94d80f55/attachment-0001.html>

Reply by email

Bo Berglund
to ik
ik 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

Reply by email