View Issue Details

IDProjectCategoryView StatusLast Update
0006436JEDI VCLJclGraphicspublic2016-08-03 20:23
ReporterCubicDesignAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in VersionDaily / GIT 
Summary0006436: Crash in JvPaintFX.pas
DescriptionThe person that added JanFX library to JEDI removed a {$R-} directive without really understanding what it is doing.
Without this directive the code crashes.
Additional InformationThe problem is

class procedure TJvPaintFX.Stretch(Src, Dst: TBitmap; Filter: TFilterProc; AWidth: Single);
begin
...
    GetMem(Contrib, DstWidth * SizeOf(TCList));
    // Horizontal sub-sampling
    // Scales from bigger to smaller Width
    {$R-} <------------------ THIS WAS REMOVED!!!!!
    if (xscale < 1.0) then
...
end;


This will explain why that range check should be disabled:
http://stackoverflow.com/questions/628965/delphi-accessing-data-from-dynamic-array-that-is-populated-from-an-untyped-poi
Tagsbug, janfx, JvPaintFX, resampler, stretch

Relationships

duplicate of 0006241 resolvedAHUser Range check error in JvPaintFX.pas 

Activities

CubicDesign

2015-09-14 21:21

reporter   ~0021206

To reproduce it, simply call TJvPaintFX.Stretch.
It is amazing that nobody reported this until now.

AHUser

2016-08-02 19:23

developer   ~0021307

All JVCL files are compiled with $R- (first compiler directive in jvcl.inc). So I don't see how that code could be compiled with $R+ unless you copy that part into your own unit.

CubicDesign

2016-08-02 20:00

reporter   ~0021309

> are compiled with $R-
That is BAAAAD! During debugging and testing Range Checking should ALWAYS be on.


> unless you copy that part into your own unit
Yes. This is what I do (and I know for sure at least 3 friends that are doing the same). I don't like having the whole Jedi installed because it is too big, so I only use what I need from it.
Any person that will use ONLY that piece of code will have the same problem.


If in the future Jedi will (hopefully) change the R- to R+ that code will fail also in Jedi. So, why deleting that single line of code if it does NO harm when it is there and LOT of harm when is removed?

AHUser

2016-08-03 17:23

developer   ~0021316

My guess it that the person who integrated TJvPaintFX thought that due to the global $R- that it isn't necessary.


I found some more "array[0..0] of T" type declaration in the JCL/JVCL. The Delphi RTL changed them years ago to "array[0..MaxInt div SizeOf(T) - 1] of T". That's what I'm going to do to fix this.



BTW: Why is TJvPaintFX a component anyway, it should be moved to the JCL and made an abstract class. But I guess it is a bit too late for that, especially with nobody actively working on the JCL/JVCL.

AHUser

2016-08-03 20:23

developer   ~0021317

Fixed in master branch.

I also moved the JvResample.pas to \archive because all its code is a copy of JvPaintFX (with some style guide changes).

Issue History

Date Modified Username Field Change
2015-09-08 09:47 CubicDesign New Issue
2015-09-08 09:47 CubicDesign IDE version => Delphi/C++Builder XE3
2015-09-11 16:28 CubicDesign Tag Attached: janfx
2015-09-11 16:28 CubicDesign Tag Attached: resampler
2015-09-11 16:29 CubicDesign Tag Attached: bug
2015-09-11 16:29 CubicDesign Tag Attached: JvPaintFX
2015-09-11 16:29 CubicDesign Tag Attached: stretch
2015-09-14 21:21 CubicDesign Note Added: 0021206
2016-08-02 19:17 AHUser Project JEDI Code Library => JEDI VCL
2016-08-02 19:23 AHUser Note Added: 0021307
2016-08-02 19:23 AHUser Status new => feedback
2016-08-02 20:00 CubicDesign Note Added: 0021309
2016-08-03 17:23 AHUser Note Added: 0021316
2016-08-03 20:23 AHUser Note Added: 0021317
2016-08-03 20:23 AHUser Status feedback => resolved
2016-08-03 20:23 AHUser Fixed in Version => Daily / GIT
2016-08-03 20:23 AHUser Resolution open => fixed
2016-08-03 20:23 AHUser Assigned To => AHUser
2016-08-04 21:17 AHUser Relationship added duplicate of 0006241