0xC0000054 / PSFilterPdn

A Paint.NET effect plugin that enables the use of 3rd party 8bf filters.
https://forums.getpaint.net/index.php?/topic/20622-psfilterpdn/
MIT License
37 stars 3 forks source link

Crash when calling RegionPtr<T>.Slice() #10

Open rickbrew opened 1 month ago

rickbrew commented 1 month ago

This was sent to me, I checked and they do have the latest version of the plugin installed (2.0.8.0):

This text file was created because [paint.net](http://paint.net/) crashed. Please e-mail this to [crashlog5@getpaint.net](mailto:crashlog5@getpaint.net) so we can diagnose and fix the problem.

Application version: [paint.net](http://paint.net/) 5.0.13 (Stable 5.13.8830.42291)
Time of crash: 11/05/2024 22:44:14
Application uptime: 00:00:17.9771986
Application state: Running
Working set: 383,920 KiB
Handles and threads: 1561 handles, 97 threads, 1003 gdi, 329 user
Install type: Classic
Application directory: C:\Program Files\[paint.net](http://paint.net/)
Current directory: C:\Program Files\[paint.net](http://paint.net/)
Install directory: C:\Program Files\[paint.net](http://paint.net/)
OS Version: Windows 10 Home 10.0.19045.0 x64
.NET version: .NET 7.0.16 x64
Processor: "Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz" @ ~3600MHz (4C/8T, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2)
Memory: 16,335 MB physical (10,355 MB free), 133,947,977 MB virtual free, 18,767 MB pagefile (10,603 MB free)
Video card: NVIDIA GeForce GTX 1660 (fl:12.1, v:10DE, d:2184, r:A1), Microsoft Basic Render Driver (fl:12.1, v:1414, d:8C, r:0)
Hardware acceleration: True (default: True) (rendering: 🚀 Performance (NVIDIA GeForce GTX 1660))
Remote session: no
Pointers: none
UI animations: True
UI DPI: 96 dpi (1.00x scale)
UI theme: VisualStyleCategory=Aero, EffectiveTheme=Aero, DWM=yes, AeroColorScheme=Light, ThemeFileName=Aero.msstyles
Updates: True, 11/05/2024
Locale: pdnr.c: en-GB, hklm: en-GB, hkcu: en-GB, cc: en-GB, cuic: en-GB
Flags:

Exception details:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'bounds (768,0,27,256) is not valid (0,0,794,644)')
   at PaintDotNet.RegionPtr`1.SliceError(RectInt32 bounds) in D:\src\pdn\src_5_0_x\Primitives\RegionPtr`1.cs:line 470
   at PaintDotNet.Imaging.BitmapBase`1.LockImpl(RectInt32 rect, BitmapLockOptions lockOptions) in D:\src\pdn\src_5_0_x\Windows.Core\Imaging\BitmapBase`1.cs:line 123
   at PaintDotNet.Imaging.BitmapBase`1.Lock(RectInt32 rect, BitmapLockOptions lockOptions) in D:\src\pdn\src_5_0_x\Windows.Core\Imaging\BitmapBase`1.cs:line 92
   at PSFilterLoad.PSApi.Imaging.Internal.WICBitmapSurface`1.Lock(Rectangle bounds, SurfaceLockMode mode) in D:\Dev_projects\PSFilterPdn\src\PSApi\Imaging\Internal\WICBitmapSurface.cs:line 134
   at PSFilterLoad.PSApi.LoadPsFilter.FillInputBuffer(FilterRecord* filterRecord) in D:\Dev_projects\PSFilterPdn\src\PSApi\LoadPsFilter.cs:line 1788
   at PSFilterLoad.PSApi.LoadPsFilter.AdvanceStateProc() in D:\Dev_projects\PSFilterPdn\src\PSApi\LoadPsFilter.cs:line 1355
0xC0000054 commented 1 month ago

I am not able to reproduce that crash with any of the filters I tried.

rickbrew commented 1 month ago

I'm guessing you're either being given an out-of-bounds rectangle, or the rectangle becomes out-of-bounds when applying the padding values. This is in AdvanceStateProc -- I looked at the other methods in this call stack and none of them are doing any clipping or bounds checking, they just forward it along to the next method.

I'm not sure what you should do here in this case, whether you should clip or throw.

0xC0000054 commented 1 month ago

Yeah, I was thinking that the filter was passing me bad data. But without having a copy of the filter in question, there is no way for me to debug the issue.