Recent

Author Topic: Lazarus 2.1.0 trunk version timestamptomsecs bug  (Read 2463 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Lazarus 2.1.0 trunk version timestamptomsecs bug
« on: February 21, 2019, 05:55:23 pm »
Hi guys, I found a reproducible bug, quite serious. To reproduce it you must have the trunk version (windows 10 64 bit) installed with fpcupdeluxe and the cross compiler for windows 32 bit applications. If you install zeoslib 7.2.4 stable and run the test program that I enclose you will see that at the end of the created form you find the line

app:=Self.ZQuery1.FieldByName('MYDATE').AsDateTime;       

and if you try to run in cross compilation win32 - 32bit you will get the error External: SIGFPE.
« Last Edit: February 24, 2019, 03:09:48 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Lazarus 2.1.0 trunk version datetime bug
« Reply #1 on: February 22, 2019, 03:58:57 pm »
Has anyone managed to replicate the error I mentioned?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Lazarus 2.1.0 trunk version datetime bug
« Reply #2 on: February 23, 2019, 12:24:01 pm »
Haven't tried it because I am using a Mac
But I have a similar problem with DBDateTimePicker.

It won't let me choose a date in runtime

Does anyone else have this problem too?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Lazarus 2.1.0 trunk version datetime bug
« Reply #3 on: February 23, 2019, 12:47:58 pm »
What are your formatsettings and what is the format in the database? I don't think they match which will explain the SIGFPE because the conversion will fail.
The solution is possibly to create a local copy of Tformatsettings and set the datetime formats to what the database expects.
I have encountered such things before, also with previous versions.
I can't test it since I do not write win32 code for some years. But the above is also valid for 64 bit if they indeed do not match the database.

A quick way to test is to use https://www.freepascal.org/docs-html/rtl/sysutils/trystrtodatetime.html TryStrToDateTime instead of AsDateTime. That will not throw a SIGFPE but returns false if the conversion did not succeed.
Are you sure the format is in proper database order? (year month date hour minute seconds msec? not strictly necessary but good practice, depending on formatsettings) and do the Date and time separators match? (that is necessary)
« Last Edit: February 23, 2019, 01:03:08 pm by Thaddy »
Specialize a type, not a var.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Lazarus 2.1.0 trunk version timestamptomsecs bug
« Reply #4 on: February 24, 2019, 03:09:13 pm »
So I narrowed down the field. There must be a bug in the timestamptomsecs function in case of cross compilation. Because if you try to run this simple code you will get the error I mentioned above. This is because the zeoslib library uses this function when using a field.AsDateTime.


Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.    curmilli,latermilli:comp;
  4. begin
  5.   curmilli:=timestamptomsecs(datetimetotimestamp(now));
  6.   showmessage('Waiting');
  7.   latermilli:=timestamptomsecs(datetimetotimestamp(now));
  8.   showmessage(IntToStr(QWord(latermilli)-QWord(curmilli)));
  9. end;                
  10.  

In fact, now I change the name of the 3d.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Lazarus 2.1.0 trunk version timestamptomsecs bug
« Reply #5 on: February 25, 2019, 04:22:32 pm »
I think is a fpc bug. Report to this link: https://bugs.freepascal.org/view.php?id=35147
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018