BGRABitmap NoGUI lazarus / 46-BGRABitmap and LazPaint ---------------------------------------------------------------------- raulik · 2016-10-13 13:30 Hello, i have installed BGRABitmap NoGUI on Win64 and try to crosscompile for Linux/64 NoGui Console app. Have somethink bad, compilation's dona ok, but run ends with An unhandled exception occurred at $00000000004E8997: EInvalidOp: Invalid floating point operation   $00000000004E8997   $0000000000515957 line 373 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc   $000000000051BE09 line 1531 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc   $0000000000468CD9 When i use BGRABitmap or some other units. When i dont use it, aplication runs ok. Linux is Ubuntu server. Any idea ?? ---------------------------------------------------------------------- raulik · 2016-10-13 13:41 Don't know why, but the error line is : power(255, GammaExpFactor); Tried :   try     Writeln('power : ' + FloatToStr(power(255, GammaExpFactor)));   except     on E:Exception do Writeln('ERROR : ' + E.Message);   end; it writes : ERROR : Invalid floating point operation ---------------------------------------------------------------------- circular · 2016-10-13 17:45 Maybe it is a bug of the cross-compiler. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i power(255, GammaExpFactor)can be replaced by Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i exp(ln(255)*GammaExpFactor) Does that also produce a runtime error? ---------------------------------------------------------------------- raulik · 2016-10-13 18:26 Still the same error An unhandled exception occurred at $00000000005145AB: EInvalidOp: Invalid floating point operation   $00000000005145AB line 373 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc   $000000000051AA69 line 1531 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc I dont have posibility of compile on destination system directly, because of this, i'm using crosscompile. ---------------------------------------------------------------------- lainz · 2016-10-13 18:53 Lazarus 1.6 fpc 3.0 or trunk? Works as 32 bit cross compiling? You can install Ubuntu Server in a virtual machine and compile directly in the target os if you want. ---------------------------------------------------------------------- raulik · 2016-10-13 19:08 I think, that lazarus 1.6 with fpc 3.0 - i use fpcup, so i dont know this exactly. Lazarus is 64bit, fpc too. Crosscompile to Linux/64. Lazarus about say : Lazarus 1.6 r51630 FPC 3.0.0 x86_64-win64-win32/win64 - from which i'm not very wise. I tried to compile to Linux/32 (not very happy, because of memory need of this script (large image manipulation), that's the reason for what i need to run this on the server, not my computer), but i dont have Crosscompile to Linux/32 installed and absolutely dont know how to install Sorry, i'm very new in Lazarus, i was delphi programer, but... This summer i moved to Lazarus, so i'm very happy to have something done with crosscompile. There is not problem to install fpc on this server - that my own, but i',m not friendly with fpc this time, for compilation this app from commandline - lot of packages, lot of units - aprox 300 000 lines of code. I can aprove, that on win64, there is not this bug. ---------------------------------------------------------------------- lainz · 2016-10-13 21:11 I'm running ubuntu 32 and nothing happens. What if you comment the line 1531? ---------------------------------------------------------------------- raulik · 2016-10-14 09:31 Then the skript runs (commented out whole his work, so only loading of BGRABitmap unit is tested). But what about this gamma disconfiguration ? ---------------------------------------------------------------------- circular · 2016-10-14 10:13 Gamma correction is to improve the color and brightness computation, but it is not necessary. However there need to be some initialization. @raulik: I invite you to try the following. Add the following procedure next to procedure BGRASetGamma: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure BGRANoGamma;var i: integer;begin  GammaExpFactor := 1;  for i := 0 to 255 do    GammaExpansionTab[i] := (i shl 8) + i;  for i := 0 to 65535 do    GammaCompressionTab[i] := i shr 8;end; And at the end of bgrapixel.inc, in the INCLUDE_INIT part, replace the call to BGRASetGamma by BGRANoGamma: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$IFDEF INCLUDE_INIT}{$UNDEF INCLUDE_INIT}  BGRANoGamma();{$ENDIF} ---------------------------------------------------------------------- raulik · 2016-10-14 10:41 Many thanks, will try it. This time i'm searching for some else  "Invalid floating point operation" which is not shows on windows. So, the problem is more deeply, because next IFOP is from : round(filter.i['Treshold'] * 655.35) so somethink bad is about FP operation. Somethink what i should check ? EDIT 2: I dont understand this totally. When i try to do somethink like :   function test(const x : byte; const y : real) : word;   begin     result := Round((x*y));   end;    Write('Test(82,655.35) = ');    Writeln(IntToStr(test(82,655.35))); On beginning of my code, that;s runs ok. but i deep of my code :    tresh := filter.i['Treshold'];    Log('tresh = ' + IntToStr(tresh));    Log('tresh * 655.35 = ');    Log(FloatToStr(tresh*655.35));    Log('round(tresh * 655.35) = ');    Log(IntToStr(round(tresh*655.35))); results in : 2016.10.14 13:36:36.151 - filter.i[Treshold] = 82 2016.10.14 13:36:36.151 - tresh = 82 2016.10.14 13:36:36.151 - tresh * 655.35 = 2016.10.14 13:36:36.151 - Exception on deploying image Invalid floating point operation EDIT3: function test(const x : byte; const y : real) : word; begin   result := Round((x*y)); end; var tresh : byte;    tresh := filter.i['Treshold'];    Log('1)tresh = ' + IntToStr(tresh));    Log('2)Test(82,655.35) = ');    Log('2)'+IntToStr(test(82,655.35)));    Log('3)82 * 655.35 = ');    Log('3)'+FloatToStr(82*655.35));    Log('4)test(trash, 655.35) = ');    Log('4)'+IntToStr(test(tresh,655.35)));    Log('5)tresh * 655.35 = ');    Log('5)'+FloatToStr(tresh*655.35));    Log('6)round(tresh * 655.35) = ');    Log('6)'+IntToStr(round(tresh*655.35))); results : 2016.10.14 13:58:23.914 - 1)tresh = 82 2016.10.14 13:58:23.914 - 2)Test(82,655.35) = 2016.10.14 13:58:23.914 - 2)53739 2016.10.14 13:58:23.914 - 3)82 * 655.35 = 2016.10.14 13:58:23.914 - 3)Nan 2016.10.14 13:58:23.914 - 4)test(trash, 655.35) = 2016.10.14 13:58:23.914 - 4)53739 2016.10.14 13:58:23.914 - 5)tresh * 655.35 = 2016.10.14 13:58:23.915 - Exception on deploying image Invalid floating point operation So there is difference between direct math and math in function test. And other bug is, that the same error i have foud on line like :                 fn += ifthen(filterNeedFilename<>'',filterNeedFilename,FormatFloat('0000', i)+'.jpeg'); I is word. ---------------------------------------------------------------------- raulik · 2016-10-14 13:43 Lazarus 64bit, FPC 32bit with Crosscompile to Linux64bit is good - so the bugs are only in fpc64. ---------------------------------------------------------------------- circular · 2016-10-14 14:59 I would suggest to report on the bugtracker with a test program and detailled explanation on the compilation method. ---------------------------------------------------------------------- raulik · 2016-10-14 16:03 Will try to reproduct this errors with test app next week. This time i changed fpc from 64bit to 32bit - don't know exactly how to change it back and i'm now happy, that the ppu cheksum changed errors leave. So for best, i need some virtual win with fpc install.