Bug 453746 - Crash when exporting lossy JPEG XL
Summary: Crash when exporting lossy JPEG XL
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (other bugs)
Version First Reported In: git master (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL: https://github.com/libjxl/libjxl/pull...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-13 15:22 UTC by Alvin Wong
Modified: 2022-06-09 13:46 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.1.0
Sentry Crash Report:


Attachments
Backtrace with line numbers (7.80 KB, text/plain)
2022-05-13 15:40 UTC, Alvin Wong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin Wong 2022-05-13 15:22:01 UTC
Probably upstream but here it is:

krita.exe caused an Illegal Instruction at location 00007FFB48EC3EF0 in module libjxl.dll.

AddrPC           Params
00007FFB48EC3EF0 0000000000000000 00007FFB490B74F7 000000000000038B  libjxl.dll!jxl::Abort+0x0
00007FFB48CFAD07 000000000000000C 0000000000000E60 F8AF000000000101  libjxl.dll!jxl::FindBestQuantizer+0x2597
00007FFB48DF7DD6 0000000000000136 00007FFB4904597B 000000E2096FC9E0  libjxl.dll!jxl::DefaultEncoderHeuristics::LossyFrameHeuristics+0x2d06
00007FFB48DADFFB 0000000000000000 00007FFBA05F5BA1 0000000000000BE4  libjxl.dll!jxl::LossyFrameEncoder::ComputeEncodingData+0xdb
00007FFB48DA6D38 0000024BD017E9F0 0000024BD017E9F0 0000024BD017EA0A  libjxl.dll!jxl::EncodeFrame+0x1368
00007FFB48D27305 0000024B92C65D50 00007FFB490454C7 000000E2096FD8F0  libjxl.dll!jxl::InitializePassesEncoder+0xb85
00007FFB48DAE055 0000000000000000 00007FFBA05F5BA1 0000000000000B64  libjxl.dll!jxl::LossyFrameEncoder::ComputeEncodingData+0x135
00007FFB48DA6D38 0000000077747074 00007FFB606C6D35 0000024BC892CAF0  libjxl.dll!jxl::EncodeFrame+0x1368
00007FFB48E75388 0000000000000000 0000000000004000 0000000000004000  libjxl.dll!JxlEncoderStruct::RefillOutputByteQueue+0x698
00007FFB48E7A5EE 0000024B98F20E60 00007FFB00000000 0000024B8A6736F0  libjxl.dll!JxlEncoderProcessOutput+0xde
00007FFB7F8E6279 00007FFB5C59BE20 0000024B00000000 0000000000000000  kritajxlexport.dll!JPEGXLExport::convert+0x26d9
00007FFB60C25C19 0000000000000000 0000000000000000 0000000000000000  libkritaui.dll!KisImportExportManager::doExportImpl+0x129
00007FFB60C2515C 0000000200000000 0000000000000000 0000000000000000  libkritaui.dll!KisImportExportManager::doExport+0x7c
00007FFB60C27DF5 0000024BC879AE90 0000000000000100 0000000000000000  libkritaui.dll!std::__1::__invoke<KisImportExportErrorCode (KisImportExportManager::*&)(QString const&, QSharedPointer<KisImportExportFilter>, KisPinnedSharedPtr<KisPropertiesConfiguration>, bool), KisImportExportManager*&, QString&, QSharedPointer<KisImportExportFilter>&, KisPinnedSharedPtr<KisPropertiesConfiguration>&, bool&, void>+0x95
00007FFB60C279CC 0000024BC892CD10 00007FFB5C7A3F5F 0000000000000000  libkritaui.dll!QtConcurrent::StoredFunctorCall0<KisImportExportErrorCode, std::__1::__bind<KisImportExportErrorCode (KisImportExportManager::*)(QString const&, QSharedPointer<KisImportExportFilter>, KisPinnedSharedPtr<KisPropertiesConfiguration>, bool), KisImportExportManager*, QString const&, QSharedPointer<KisImportExportFilter>&, KisPinnedSharedPtr<KisPropertiesConfiguration>&, bool&> >::runFunctor+0x3c
00007FFB60C278EC 0000024BCADD7360 0000024B922E00E0 0000000000000000  libkritaui.dll!QtConcurrent::RunFunctionTask<KisImportExportErrorCode>::run+0x2c
00007FFB5C5A006E 0000000000000000 0000000000000000 0000000000000000  Qt5Core.dll!QThreadPoolThread::run+0xae
00007FFB5C59BF2C 0000000000000000 0000000000000000 0000000000000000  Qt5Core.dll!QThreadPrivate::start+0x10c
00007FFBA02E7034 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk+0x14
00007FFBA0622651 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart+0x21
Comment 1 Alvin Wong 2022-05-13 15:40:11 UTC
Created attachment 148800 [details]
Backtrace with line numbers
Comment 2 Alvin Wong 2022-05-13 15:41:27 UTC
Abort called from:

./lib/jxl/enc_adaptive_quantization.cc:907: JXL_CHECK: enc_state->shared.frame_header.color_transform == ColorTransform::kXYB
Comment 3 amyspark 2022-05-13 16:29:03 UTC
I need the KRA you were trying to export, also (if you can) tell me what instruction sets your computer support. You can try the xsimd branch if you want, that one has this information embedded in the bug reporter.
Comment 4 Alvin Wong 2022-05-13 17:17:09 UTC
It crashes on a blank new 8-bit A4 300dpi document. Note that this crash is an abort from JXL_CHECK, not actually from an illegal instruction within actual code. If you want to know it's a Kaby Lake i5-7300U (Surface Pro 5).
Comment 5 Alvin Wong 2022-05-13 17:52:03 UTC
Ah, I found the trigger: "Low resolution DC" was set to "512x512 + 64x64" (must've changed that some time when scrolling). Other options are default.
Comment 6 amyspark 2022-05-16 20:58:03 UTC
Sent the report upstream.
Comment 7 Alvin Wong 2022-05-18 09:32:51 UTC
I find it a bit concerning that libjxl will assert and abort like this when used as a library. Normally I would expect the library return a failure or throw an exception, rather than bringing down the whole process. Is there anything we can do to make libjxl stop gracefully?
Comment 8 amyspark 2022-05-18 12:27:17 UTC
> I find it a bit concerning that libjxl will assert and abort like this when used as a library. Normally I would expect the library return a failure or throw an exception, rather than bringing down the whole process. Is there anything we can do to make libjxl stop gracefully?

I had thought you were referring to my changes to error logging (see https://invent.kde.org/graphics/krita/-/blob/master/3rdparty/ext_jpegxl/CMakeLists.txt#L47) but JXL_ASSERT is definitely *not* enabled by my changes, it gets defined automatically in all cases. I'll disable it in our 3rdparty builds now.
Comment 9 amyspark 2022-06-07 18:57:55 UTC
Fixed in https://github.com/libjxl/libjxl/pull/1481. Reopening for scheduling a library update.
Comment 10 Bug Janitor Service 2022-06-08 20:30:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1469
Comment 11 Dmitry Kazakov 2022-06-09 07:25:11 UTC
Git commit a728092447bb6fe5923a028b82bcd56ab58ffcce by Dmitry Kazakov, on behalf of L. E. Segovia.
Committed on 09/06/2022 at 07:23.
Pushed by dkazakov into branch 'master'.

libjxl: update to latest 0.7.0 master

D  +0    -32   3rdparty/ext_jpegxl/0001-Make-gflags-an-IMPORTED-GLOBAL-library.patch
M  +2    -3    3rdparty/ext_jpegxl/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/a728092447bb6fe5923a028b82bcd56ab58ffcce
Comment 12 amyspark 2022-06-09 13:46:32 UTC
Git commit 2832ac86bd5a44ce2ba27918cf893b14e3195c02 by L. E. Segovia.
Committed on 09/06/2022 at 13:46.
Pushed by lsegovia into branch 'krita/5.1'.

libjxl: update to latest 0.7.0 master
(cherry picked from commit a728092447bb6fe5923a028b82bcd56ab58ffcce)

D  +0    -32   3rdparty/ext_jpegxl/0001-Make-gflags-an-IMPORTED-GLOBAL-library.patch
M  +2    -3    3rdparty/ext_jpegxl/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/2832ac86bd5a44ce2ba27918cf893b14e3195c02