Re: [Lazarus] Is it possible to find the location of an EAccessViolation, with Lazarus?

2018-05-13 Thread Carlos E. R. via Lazarus
On 2018-05-13 06:06, Cyrax via Lazarus wrote:
> On 12/05/18 21:04, Carlos E. R. via Lazarus wrote:


>> Although the child is not using pipes :-?
>>
>>
>>
> 
> If the child process outputs something (text or something else), then it
> is using stdout pipe. And if you want access to this output, then you
> need to set poUsePipes enum in the TProcess.Options so TProcess can set
> up IO redirection correctly.

Ah. Then it is the parent who is setting an implicit pipe. That is an
important "detail" that I didn't notice/read about.


> Also do not forget read TProcess.StdErr pipe, otherwise there is change
> for strange behaviour. Or add poStderrToOutPut to TProcess.Options.

Well, of course I did not set it up, because I did not see it in the
example I was following or in the documentation. Thanks for telling me!






-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Is it possible to find the location of an EAccessViolation, with Lazarus?

2018-05-12 Thread Cyrax via Lazarus

On 12/05/18 21:04, Carlos E. R. via Lazarus wrote:

On 2018-05-12 18:35, Orbán Árpád via Lazarus wrote:

Hi Carlos,

Try add poUsePipes to TProcess.Options:


  AProcess := TProcess.Create(nil);
     try
    AProcess.Executable := '/usr/local/bin/egctl';
    AProcess.Parameters.Add('Regleta');
    AProcess.Parameters.Add('off');
    AProcess.Parameters.Add('off');
    AProcess.Parameters.Add('off');
    AProcess.Parameters.Add('off');


     AProcess.Options := AProcess.Options + [poUsePipes];



    AProcess.Execute;


Ah. Thanks. I had commented that out by mistake. Actual code was:

   {$ifDEF Dummy}
   AProcess.Parameters.Add('Regleta');
   AProcess.Options := [poWaitOnExit, poUsePipes];
   {$else}
   AProcess.Parameters.Add('Regleta');
   AProcess.Parameters.Add('off');
   AProcess.Parameters.Add('off');
   AProcess.Parameters.Add('off');
   AProcess.Parameters.Add('off');
   {$endIf}

And "Dummy" was not defined.

Although the child is not using pipes :-?





If the child process outputs something (text or something else), then it 
is using stdout pipe. And if you want access to this output, then you 
need to set poUsePipes enum in the TProcess.Options so TProcess can set 
up IO redirection correctly.


Also do not forget read TProcess.StdErr pipe, otherwise there is change 
for strange behaviour. Or add poStderrToOutPut to TProcess.Options.


--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Is it possible to find the location of an EAccessViolation, with Lazarus?

2018-05-12 Thread Carlos E. R. via Lazarus
On 2018-05-12 18:35, Orbán Árpád via Lazarus wrote:
> Hi Carlos,
> 
> Try add poUsePipes to TProcess.Options:
> 
>>  AProcess := TProcess.Create(nil);
>>     try
>>    AProcess.Executable := '/usr/local/bin/egctl';
>>    AProcess.Parameters.Add('Regleta');
>>    AProcess.Parameters.Add('off');
>>    AProcess.Parameters.Add('off');
>>    AProcess.Parameters.Add('off');
>>    AProcess.Parameters.Add('off');
> 
>     AProcess.Options := AProcess.Options + [poUsePipes];
> 
>>
>>    AProcess.Execute;

Ah. Thanks. I had commented that out by mistake. Actual code was:

  {$ifDEF Dummy}
  AProcess.Parameters.Add('Regleta');
  AProcess.Options := [poWaitOnExit, poUsePipes];
  {$else}
  AProcess.Parameters.Add('Regleta');
  AProcess.Parameters.Add('off');
  AProcess.Parameters.Add('off');
  AProcess.Parameters.Add('off');
  AProcess.Parameters.Add('off');
  {$endIf}

And "Dummy" was not defined.

Although the child is not using pipes :-?

-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Is it possible to find the location of an EAccessViolation, with Lazarus?

2018-05-12 Thread Orbán Árpád via Lazarus

Hi Carlos,

Try add poUsePipes to TProcess.Options:


 AProcess := TProcess.Create(nil);
try
   AProcess.Executable := '/usr/local/bin/egctl';
   AProcess.Parameters.Add('Regleta');
   AProcess.Parameters.Add('off');
   AProcess.Parameters.Add('off');
   AProcess.Parameters.Add('off');
   AProcess.Parameters.Add('off');


AProcess.Options := AProcess.Options + [poUsePipes];



   AProcess.Execute;


Regards,
  Arpad
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Is it possible to find the location of an EAccessViolation, with Lazarus?

2018-05-12 Thread Carlos E. R. via Lazarus
Hi,

a program of mine crashed with:

Exception at 00401B4A: EAccessViolation:
Access violation.


Is it possible to find the location line of that address?


Very long ago, with turbopascal, it was possible to type the address of the 
fault in a box in the compiler, which would build again the source and stop at 
the exact location. I do not see similar thing in Lazarus. Did I miss it?



I know where it happened, more or less, from the messages on screen and syslog.
Maybe someone here can see the problem in the code.


procedure TMyApplication.DoRebootRouter;
 {See  
  for the doc on calling a program and getting its output.}
   const
 BUF_SIZE = 2048; // Buffer size for reading the output in chunks
   var
 AProcess : TProcess;
 OutputStream : TStream;
 BytesRead: longint;
 Buffer   : array[1..BUF_SIZE] of byte;
 ExitCode,
 ExitStatus   : Integer;
begin
   LastRouterRebootTimestamp:= Now;
   inc(RebootTimes);
   ExitCode := -1;
   AProcess := TProcess.Create(nil);
   try
  AProcess.Executable := '/usr/local/bin/egctl';
  AProcess.Parameters.Add('Regleta');
  AProcess.Parameters.Add('off');
  AProcess.Parameters.Add('off');
  AProcess.Parameters.Add('off');
  AProcess.Parameters.Add('off');

  AProcess.Execute;  < this does execute.
  OutputStream := TMemoryStream.Create;
  repeat
 BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);
 OutputStream.Write(Buffer, BytesRead)
  until BytesRead = 0;
  ExitCode:= AProcess.ExitStatus;
  ExitStatus:= AProcess.ExitStatus
   finally
  AProcess.Free;
   end;

   syslog(log_info, 'Called %s, got EC: %d ED: %d'#10, ['egctl', ExitCode, 
ExitStatus]);   <  this part doesn't execute.
   Writeln('Got exitcode ', AProcess.ExitCode, ' ExitStatus: ', 
AProcess.ExitStatus);



The external program runs fine.

The screen output was:

Last sucessfull ping was more than 60 seconds ago, rebooting the router.
Exception at 00401B4A: EAccessViolation:
Access violation.
socket 1 - off  <=== child program
socket 2 - off
socket 3 - off
socket 4 - off


Syslog entries are these:

<16.6> 2018-05-12T07:25:18.455969+02:00 Isengard WatchDog - - -  WatchDog MARK! 
Status: Router 1 (F/T 0/48) Google 1 (F/T 0/8) Rebooting 0  Reboots 0
<16.6> 2018-05-12T07:47:20.514116+02:00 Isengard WatchDog - - -  Last 
sucessfull ping was more than 60 seconds ago, rebooting the router.
<16.6> 2018-05-12T07:47:20.515184+02:00 Isengard WatchDog - - -  Ending

The second line indicates that the procedure shown above is called.

The third line comes from here:


destructor TMyApplication.Destroy;
begin
   ping.Free;
   syslog(log_info,'Ending',[1234]);
   closelog;
   inherited Destroy;
end;   



Ideas?


-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus