View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038359 | FPC | Packages | public | 2021-01-15 07:40 | 2021-01-27 23:02 |
Reporter | Zdravko Gabrovski | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | All | OS | All | ||
Product Version | 3.3.1 | ||||
Summary | 0038359: TJPEGImage.SaveToStream (also Save to file) crash and terminate application with exit code (1) w/o any exception | ||||
Description | With a fresh trunk I catch that function that uses TJPEGImage.Save to stream immediately terminates application without any exception. | ||||
Steps To Reproduce | Load standart lazarus JPEG Example from Lazarus/examples folder, load any picture with "load" button, click "Save as jpeg", select file name and... booom!. | ||||
Additional Information | With a trunk version form beginning of november there is no problem, everything is OK. The problem is somewhere inside the jpeg implementation in fcl-image package. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
|
Please create an example that does not use Lazarus to demonstrate the issue. I can perfectly save a JPEG file with the trunk FPC code and 3.2.0. The fcl-image JPEG writing code has not changed since 2016, and the underlying code in pasjpeg has not changed since 2012. Lazarus has several wrappers around the FPC image codebase, maybe the error is there. |
|
I checked the jpegexample project from folder examples/jpeg and loaded the lazaraus.jpg file from that folder. And I did not see any problem when saving it as lazarus1.jpg. So, please be more specific: Which file are you loading? Maybe the file is broken? I am on Win10, 64 bit, Laz-trunk (r64392 of today), FPC-trunk r48157 (of today), both 32 bit. |
|
Strange - I tested with fpc trunc, both in linux and MacOs - the same. Version information: Lazarus 2.1.0 r63994M FPC 3.3.1 x86_64-linux-gtk2 - Works - No problem. Lazarus 2.1.0 r64383 FPC 3.3.1 x86_64-linux-gtk2 - Failed. Lazarus 2.1.0 r64121:64142M FPC 3.3.1 x86_64-win64-win32/win64 - No problem, works. One remark: I load a .png and then try to save as JPG with Lazarus example. @Michael, I will prepare an example but it can not be without LCL. Zdravko. |
|
The only different thing in these version numbers is Lazarus. And if you cannot reproduce it without LCL, that just confirms the error is in Lazarus. I will move the error to lazarus project |
|
Ok, I catch the bug comes in procedure TFPCustomImage.SaveToStream (Str:TStream; Handler:TFPCustomImageWriter); begin Handler.ImageWrite (Str, Self); end; in fpimage.inc in fcl-img may by it is bug in LCL Here is the example. just mark check box and click the button. |
|
The bug happens inside the "Writepixels" method in procedure TFPWriterJPEG.InternalWrite(Str: TStream; Img: TFPCustomImage); in FPWriteJPEG unit, which call methods in JcAPIstd in package pasjpeg in fpsrc so the line LinesWritten := jpeg_write_scanlines(@FInfo, SampArray, 1); in fpwritejpg.pas fails. |
|
Please create an example without LCL. |
|
Ok, I don't know how to do but i will try. |
|
It make me crazy. When I move the source files from /fpcupdeluxe/fpcsrc/packages/pasjpeg/src to my test application folder, everything is OK! Where could the problem be? fpc and lazarus are recompiled with fpcupdeluxe fresh from the trunk yesterday. The same situation on MAC with a trunk from end of december. |
|
I can only repeat: the FPC code for this has not changed in many years... |
|
OK i hope whis is my fault. i just start to checkout and recompile new clean environment from the trunk. |
|
Exactly the same - fresh installation from the trunk, brand new follder, Linux x64. @Michael, please can you give me an idea how to recompile fpc and fpc packages w/o fpcupdeluxe? Guys, may I kindly ask you to download and compile from the trunk and to test the case? |
|
just do a make all PP=ppcx64-3.2.0 (or whatever the 3.2.0 compiler is called) at the top of the FPC source tree. That's all. |
|
Update: Fresh install in Windows 64 - no problem. |
|
I can confirm the bug on Ubuntu 20.04 LTS. Steps to reproduce: Install trunk of fpc and lazarus. Load project /<install_dir>/lazarus/examples/jpeg/jpegexample.lpi Click on "Load Image" and load any .png Click "Save as JPEG to file" and choose any location Click "Save" and the application will crash with "Execution stopped with exit-code 1 ($0001)" p.s. the bug does not occur with a trunk installation from 30.09.2020 |
|
Lazarus 2.1.0 r64392 FPC 3.3.1 x86_64-linux-gtk2 - NOT working Lazarus 2.1.0 r63994M FPC 3.3.1 x86_64-linux-gtk2 - WORKING Lazarus 2.1.0 r64160M FPC 3.3.1 x86_64-darwin-cocoa - NOT Working Lazarus 2.1.0 r64392M FPC 3.3.1 x86_64-win64-win32/win64 - WORKING installation through fpcupdeluxe. |
|
I cannot reproduce with Latest Lazarus trunk. I have Manjaro Linux + KDE. I tested the JpegExample project with GTK2 bindings. Zdravko Gabrovski, you forgot to include any information of your system (OS etc.). Later you mentioned Linux but no distro. Reporter emthreex mentioned Ubuntu. I guess this is yet another bug related to Ubuntu. Zdravko Gabrovski, can you please bisect the exact revision that causes the bug for you. |
|
UBUNTU 18.04 (Mate) Lazarus 2.1.0 r64392 FPC 3.3.1 x86_64-linux-gtk2 - NOT working MAC OS X HighSierra - Lazarus 2.1.0 r64160M FPC 3.3.1 x86_64-darwin-cocoa - NOT Working Both the setup and initial compilation - with fpcupdeluse. UBUNTU 18.04 (Mate) - Lazarus 2.1.0 r63994M FPC 3.3.1 x86_64-linux-gtk2 - WORKING. I will attach video to demonstrate the problem. |
|
PLease find attached video with wrong revision r64392 UBUNU 18.04 Exactly the same behavior under MacOsX High Siera. |
|
And with revision r63994M UBUNTU 18.04 (The same machine) - it working. |
|
r64392 is "StartLazarus: Fix compilation." I don't think it caused the bug. Can you please find which revision did cause it. |
|
Can we please get a Demo of the problem causing in ZIP format not z7 ? I like many do not install all these fancy tools, I like to use what is commonly already established on my OS. |
|
@Jamie, use the standard demo in Lazarus/examples/jpeg. @juha - How can I find this? I am using fpcupdeluxe. The only option I have is to download current trunk. MacOs : Lazarus 2.1.0 r64160M FPC 3.3.1 x86_64-darwin-cocoa - the sam bug. |
|
ok, I have tried that example before and found nothing but I just tried again with a little different variation enabling heap trace and setting the Widget for WIn32 , scaling etc .... What I found is = NOTHING.. it all works here. May I make a suggestion and shoot from the hip here, could it be some other code just out of shear luck could be clobbering the code area in that section sort of hiding an issue elsewhere ? 1. Just for experimentation sake, could you change the order of the UNITS in the main project and source code here so that could possible be compiled in a different order of memory ? 2. Test for the file name string coming out of the Dialog Box before using it for the Jpeg load and see if it is actually valid ? use a break point to view data. 3. Also ensure the opto's are set low since I remember an issue being reported with TRY ,EXcept using the trunk compiler.. 4. Try using the 3.2.x compiler instead, this is what I am using for that test and it works fine.. Its possible some other change of code is actually causing this problem due to use of bad pointers elsewhere etc.. |
|
@Jamie, thanks for suggestions. Under Windows: The same Lazarus release - NO PROBLEM! The problem is only under UBUNTU and MACOS. If you see the videos: Exactly the same code under r63994M - Works fine! |
|
I understand your position but you can't keep throwing stones at a wall that isn't going to move., you need to try things... Please try dropping back to 3.2.x which I believe also gives you set of units version wise.. I believe parts of the code is within FPC and not lazarus LCL.. Also do you have most recent corrected Trunk compiler and have rebuilt the IDE with it ? Also, please try building app with NO DEBUG info in it at all and also the compiler with NO DEBUG in it. Then Run as a normal app and see what happens |
|
> @juha - How can I find this? I am using fpcupdeluxe. The only option I have is to download current trunk. Revision control tools allow you to jump in the history. See: https://wiki.freepascal.org/How_do_I_create_a_bug_report#Regression_caused_by_a_certain_revision Also fpcupdeluxe uses SVN for the sources, although you don't really need fpcupdeluxe to get Lazarus trunk. It is easy. I personally use Git and its great "git bisect" command. |
|
@Please try dropping back to 3.2.x which I believe also gives you set of units version wise.. OK - I will try even with 3.3.1 form r63994M - in that release it working Also do you have most recent corrected Trunk compiler and have rebuilt the IDE with it ? Yes - fpcupdeluxe does Also, please try building app with NO DEBUG info in it at all and also the compiler with NO DEBUG in it. I tried - the same result. Then Run as a normal app and see what happens The same happens. |
|
@Guys can you some body give me a url link to nice description how to build a trunk w/o fpcupdeluxe? I have only this: https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-macos-install-lazarus-svn-under-catalina-32bit-issue/ But I have no success wit this. |
|
Very easy once you have FPC installed and working. $ svn co https://svn.freepascal.org/svn/lazarus/trunk lazarus_trunk $ cd lazarus_trunk $ make $ ./lazarus & In the wiki: https://wiki.freepascal.org/Getting_Lazarus#Development_version_of_Lazarus See, you don't have to install it. Just run it from its location. |
|
@Jamie, I do compile Lazarus trunk with fpc 3.2.0 stable compiler. Now it works with 3.2.0. So, the problem comes from trunk compiler some how. PLease move the issue back to FPC it is not Lazarus issue. |
|
Zdravko, you must create a simple demo using only FPC libraries to prove your point. TJPEGImage and TGraphic are in LCL. It is clearest to create a new report for FPC, after checking for existing reports. |
|
I am no telling you that the problem is in fpc jpeg library. The problem comes when I compile Lazarus with fpc trunk. it is some how related with compiler or linker or package I dont know . if I move sources of fpc jpeg package to jpeg example folder - it compiles and works fine. I discovered that application termination comes from procedure TFPWriterJPEG.InternalWrite(Str: TStream; Img: TFPCustomImage); in FPWriteJPEG unit, which call methods in JcAPIstd in package pasjpeg in fpsrc so the line LinesWritten := jpeg_write_scanlines(@FInfo, SampArray, 1); in fpwritejpg.pas fails - appliction terminated with exit code 1. When I move the jpeg source files to my application folder in order to debug - the problem disappear. |
|
can you do a file compare between what came with fpc deluxe and what you get when you recreate the unit using what should be the same version compilers between the both of them ? If is possible the files are getting corrupted in the fpcupdeluxe ? |
|
i use svn, git in fpcupdeluxe - the same situation under Ubuntu and MacOs. I have no success to install fpc through make from console w/o fpcupdeluce. make install failed with some "crosscompiler missing" |
|
You keep talking about " r63994M". This implies that you have modified your version of Lazarus The error may as weel be in the modification. Please revert that first (in the Lazarus sourcedir do "svn revert * -R") |
|
It is no matter Lazarus, the problem comes from fpc compiler release. SVN revision # 47155 of fpc (no lazarus) breaks functionality. The fpc svn revision # 47154 is the last one that compiles lazarus fine. How to reproduce: With fpcupdeluxe, select Setup+ button, enter in fpc release 47155, leave other fields empty. Compile "trunk" lazarus+fpc. Load jpeg example - it will fails. Then go back to fpc updeluxe, again Setup+ button, select fpc release 47154. Recompile. Load jpeg example, recompile. No it works. Ubuntu 18.04. So somrthing between 47154 and 47155 breaks functionality. |
|
Any ideas? svn diff -r 47154:47155 Index: compiler/ncnv.pas =================================================================== --- compiler/ncnv.pas (revision 47154) +++ compiler/ncnv.pas (revision 47155) @@ -2925,6 +2925,13 @@ docheckremoveinttypeconvs(tbinarynode(n).left) and docheckremoveinttypeconvs(tbinarynode(n).right); end; + unaryminusn: + begin + gotsint:=true; + result:=docheckremoveinttypeconvs(tunarynode(n).left); + end; + notn: + result:=docheckremoveinttypeconvs(tunarynode(n).left); addn,muln,divn,modn,andn: begin if n.nodetype in [divn,modn] then @@ -2980,6 +2987,21 @@ // ((tordconstnode(tbinarynode(n).right).value and $7fffffff)=tordconstnode(tbinarynode(n).right).value) then // inserttypeconv_internal(tbinarynode(n).left,n.resultdef); end; + unaryminusn,notn: + begin + exclude(n.flags,nf_internal); + if not forceunsigned and + is_signed(n.resultdef) then + begin + doremoveinttypeconvs(tunarynode(n).left,signedtype,false,signedtype,unsignedtype); + n.resultdef:=signedtype; + end + else + begin + doremoveinttypeconvs(tunarynode(n).left,unsignedtype,forceunsigned,signedtype,unsignedtype); + n.resultdef:=unsignedtype; + end; + end; typeconvn: begin ttypeconvnode(n).totypedef:=todef; @@ -3271,7 +3293,7 @@ to 64 bit } if (resultdef.size <= 4) and is_64bitint(left.resultdef) and - (left.nodetype in [subn,addn,muln,divn,modn,xorn,andn,orn]) and + (left.nodetype in [subn,addn,muln,divn,modn,xorn,andn,orn,notn,unaryminusn]) and checkremovebiginttypeconvs(left,foundsint,[s8bit,u8bit,s16bit,u16bit,s32bit,u32bit],int64(low(longint)),high(cardinal)) then doremoveinttypeconvs(left,generrordef,not foundsint,s32inttype,u32inttype); {$if defined(cpu16bitalu)} |
|
I have posted a small mail on the core mailing list, maybe the compiler devs can help. |
|
Move this issue back to fpc again? |
|
@Bart, i think the same. |
|
Having an as small as possible example showing the problem would help a lot. I tried to reproduce it with the pasjpeg demo but it worked. |
|
Some clarifications: The problem appears only when try to save as jpeg some other picture type. For example: Load bmp or png - save to jpeg - the problem exists. Load and save jpeg - no problem. Only on Unix-like os - Ubuntu, Macos. @Florian, I don't think that the problem is in pasjpeg. It it some how related with lazarus. If I compilie lazarus and lcl with fpc svn rev 47155 ang higher - problem appears. Buf if compile with 47154 - it disappear. If I take pasjpeg spurces and put it inside my example folder - the problem again disappear. it sounds that precompiled units of pasjpeg is wrong in fcl-image package are wrong? I discovered that application termination comes from procedure TFPWriterJPEG.InternalWrite(Str: TStream; Img: TFPCustomImage); in fpwritejpg.pas unit, which call methods in JcAPIstd in package pasjpeg in fpsrc the line LinesWritten := jpeg_write_scanlines(@FInfo, SampArray, 1); in TFPWriterJPEG.InternalWrite fails - appliction terminated with exit code 1. Souds that parameters between caller and calee are not the same? Some stack issue? |
Date Modified | Username | Field | Change |
---|---|---|---|
2021-01-15 07:40 | Zdravko Gabrovski | New Issue | |
2021-01-15 08:21 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2021-01-15 08:21 | Michael Van Canneyt | Status | new => assigned |
2021-01-15 08:27 | Michael Van Canneyt | Note Added: 0128336 | |
2021-01-15 13:03 | wp | Note Added: 0128342 | |
2021-01-15 15:06 | Zdravko Gabrovski | Note Added: 0128345 | |
2021-01-15 15:30 | Zdravko Gabrovski | Note Edited: 0128345 | View Revisions |
2021-01-15 15:53 | Michael Van Canneyt | Note Added: 0128347 | |
2021-01-15 15:53 | Michael Van Canneyt | Note Edited: 0128347 | View Revisions |
2021-01-15 15:54 | Michael Van Canneyt | Note Edited: 0128347 | View Revisions |
2021-01-15 15:54 | Michael Van Canneyt | Project | FPC => Lazarus |
2021-01-15 16:05 | Zdravko Gabrovski | Note Added: 0128348 | |
2021-01-15 16:05 | Zdravko Gabrovski | File Added: JPegTest.7z | |
2021-01-15 16:21 | Zdravko Gabrovski | Note Added: 0128349 | |
2021-01-15 16:22 | Michael Van Canneyt | Note Added: 0128351 | |
2021-01-15 16:22 | Michael Van Canneyt | Assigned To | Michael Van Canneyt => |
2021-01-15 16:23 | Zdravko Gabrovski | Note Edited: 0128349 | View Revisions |
2021-01-15 16:25 | Zdravko Gabrovski | Note Added: 0128352 | |
2021-01-15 16:31 | Zdravko Gabrovski | Note Added: 0128353 | |
2021-01-15 16:33 | Zdravko Gabrovski | Note Edited: 0128353 | View Revisions |
2021-01-15 16:34 | Michael Van Canneyt | Note Added: 0128354 | |
2021-01-15 16:41 | Zdravko Gabrovski | Note Added: 0128355 | |
2021-01-15 16:48 | Bart Broersma | Status | assigned => new |
2021-01-15 16:48 | Bart Broersma | LazTarget | => - |
2021-01-15 16:54 | Zdravko Gabrovski | Note Added: 0128356 | |
2021-01-15 17:01 | Michael Van Canneyt | Note Added: 0128357 | |
2021-01-15 17:16 | Zdravko Gabrovski | Note Added: 0128358 | |
2021-01-17 14:51 | emthreex | Note Added: 0128389 | |
2021-01-17 14:52 | emthreex | Note Edited: 0128389 | View Revisions |
2021-01-21 23:44 | Zdravko Gabrovski | Note Added: 0128476 | |
2021-01-22 16:19 | Juha Manninen | Note Added: 0128488 | |
2021-01-22 16:25 | Juha Manninen | Note Edited: 0128488 | View Revisions |
2021-01-22 17:53 | Zdravko Gabrovski | Note Added: 0128489 | |
2021-01-22 17:57 | Zdravko Gabrovski | Note Added: 0128490 | |
2021-01-22 17:57 | Zdravko Gabrovski | File Added: R8ubeQBBrh.mp4 | |
2021-01-22 18:03 | Zdravko Gabrovski | Note Added: 0128491 | |
2021-01-22 18:03 | Zdravko Gabrovski | File Added: RfJtNpQv6N.mp4 | |
2021-01-22 18:05 | Zdravko Gabrovski | Note Edited: 0128490 | View Revisions |
2021-01-23 14:43 | Juha Manninen | Note Added: 0128516 | |
2021-01-23 15:40 | jamie philbrook | Note Added: 0128517 | |
2021-01-23 16:08 | Zdravko Gabrovski | Note Added: 0128518 | |
2021-01-23 17:23 | jamie philbrook | Note Added: 0128523 | |
2021-01-23 17:24 | jamie philbrook | Note Edited: 0128523 | View Revisions |
2021-01-23 17:42 | Zdravko Gabrovski | Note Added: 0128526 | |
2021-01-23 17:52 | jamie philbrook | Note Added: 0128527 | |
2021-01-23 18:34 | Juha Manninen | Note Added: 0128530 | |
2021-01-23 19:09 | Zdravko Gabrovski | Note Added: 0128531 | |
2021-01-23 19:23 | Zdravko Gabrovski | Note Added: 0128532 | |
2021-01-23 19:32 | Zdravko Gabrovski | Note Edited: 0128532 | View Revisions |
2021-01-24 00:04 | Juha Manninen | Note Added: 0128535 | |
2021-01-24 09:40 | Zdravko Gabrovski | Note Added: 0128542 | |
2021-01-24 09:41 | Zdravko Gabrovski | Note Edited: 0128542 | View Revisions |
2021-01-24 10:12 | Juha Manninen | Note Added: 0128544 | |
2021-01-24 10:49 | Zdravko Gabrovski | Note Edited: 0128542 | View Revisions |
2021-01-24 11:07 | Zdravko Gabrovski | Note Added: 0128547 | |
2021-01-24 12:42 | jamie philbrook | Note Added: 0128553 | |
2021-01-24 14:23 | Zdravko Gabrovski | Note Added: 0128557 | |
2021-01-24 20:35 | Bart Broersma | Note Added: 0128572 | |
2021-01-25 02:07 | Zdravko Gabrovski | Note Added: 0128578 | |
2021-01-25 02:12 | Zdravko Gabrovski | Note Added: 0128579 | |
2021-01-25 10:09 | Michael Van Canneyt | Note Added: 0128580 | |
2021-01-25 23:12 | Bart Broersma | Note Added: 0128592 | |
2021-01-26 06:17 | Zdravko Gabrovski | Note Added: 0128596 | |
2021-01-26 13:01 | Bart Broersma | Project | Lazarus => FPC |
2021-01-26 22:08 | Florian | Note Added: 0128606 | |
2021-01-27 23:02 | Zdravko Gabrovski | Note Added: 0128629 |