Closed Bug 1856630 Opened 2 years ago Closed 1 year ago

Update libjpeg-turbo to version 3.0.3

Categories

(Core :: Graphics: ImageLib, task)

task

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- wontfix
firefox129 --- fixed

People

(Reporter: RyanVM, Assigned: RyanVM)

References

Details

Attachments

(1 file)

https://github.com/libjpeg-turbo/libjpeg-turbo/releases/tag/3.0.1

Significant changes relative to 3.0.0:

  • The x86-64 SIMD functions now use a standard stack frame, prologue, and epilogue so that debuggers and profilers can reliably capture backtraces from within the functions.
  • Fixed two minor issues in the interblock smoothing algorithm that caused mathematical (but not necessarily perceptible) edge block errors when decompressing progressive JPEG images exactly two MCU blocks in width or that use vertical chrominance subsampling.
  • Fixed a regression introduced by 3.0 beta2[6] that, in rare cases, caused the C Huffman encoder (which is not used by default on x86 and Arm CPUs) to generate incorrect results if the Neon SIMD extensions were explicitly disabled at build time (by setting the WITH_SIMD CMake variable to 0) in an AArch64 build of libjpeg-turbo.
Summary: Update libjpeg-turbo to version 3.0.0 → Update libjpeg-turbo to version 3.0.1

https://github.com/libjpeg-turbo/libjpeg-turbo/releases/tag/3.0.2

Significant changes relative to 3.0.1:

  • Fixed a signed integer overflow in the tj3CompressFromYUV8(), tj3DecodeYUV8(), tj3DecompressToYUV8(), and tj3EncodeYUV8() functions, detected by the Clang and GCC undefined behavior sanitizers, that could be triggered by setting the align parameter to an unreasonably large value. This issue did not pose a security threat, but removing the warning made it easier to detect actual security issues, should they arise in the future.
  • Introduced a new parameter (TJPARAM_MAXMEMORY in the TurboJPEG C API and TJ.PARAM_MAXMEMORY in the TurboJPEG Java API) and a corresponding TJBench option (-maxmemory) for specifying the maximum amount of memory (in megabytes) that will be allocated for intermediate buffers, which are used with progressive JPEG compression and decompression, optimized baseline entropy coding, lossless JPEG compression, and lossless transformation. The new parameter and option serve the same purpose as the max_memory_to_use field in the jpeg_memory_mgr struct in the libjpeg API, the JPEGMEM environment variable, and the cjpeg/djpeg/jpegtran -maxmemory option.
  • Introduced a new parameter (TJPARAM_MAXPIXELS in the TurboJPEG C API and TJ.PARAM_MAXPIXELS in the TurboJPEG Java API) and a corresponding TJBench option (-maxpixels) for specifying the maximum number of pixels that the decompression, lossless transformation, and packed-pixel image loading functions/methods will process.
  • Fixed an error ("Unsupported color conversion request") that occurred when attempting to decompress a 3-component lossless JPEG image without an Adobe APP14 marker. The decompressor now assumes that a 3-component lossless JPEG image without an Adobe APP14 marker uses the RGB colorspace if its component IDs are 1, 2, and 3.
Summary: Update libjpeg-turbo to version 3.0.1 → Update libjpeg-turbo to version 3.0.2

I have a patch for this which appears to compile but then die during linking with a whole lot of undefined hidden symbol errors along the lines of:

ld.lld: error: undefined hidden symbol: j12init_d_main_controller
>>> referenced by jdmaster.c:719 (/media/libjpeg/jdmaster.c:719)
>>>               /obj-x86_64-pc-linux-gnu/toolkit/library/build/../../../media/libjpeg/jdmaster.o:(jinit_master_decompress)

https://hg.mozilla.org/try/rev/fd38802aa4658b96e23a6ea382f0c06a89de1717

RyanVM asked me to look into this. Recording what I found.

The files seem to need to be compiled multiple times with BITS_IN_JSAMPLE set to different values each time

https://github.com/libjpeg-turbo/libjpeg-turbo/blob/2dfe6c0fe9e18671105e94f7cbf044d4a1d157e6/sharedlib/CMakeLists.txt#L86

https://github.com/libjpeg-turbo/libjpeg-turbo/releases/tag/3.0.3

Significant changes relative to 3.0.2:

  • Fixed an issue in the build system, introduced in 3.0.2, that caused all libjpeg-turbo components to depend on the Visual C++ run-time DLL when built with Visual C++ and CMake 3.15 or later, regardless of value of the WITH_CRT_DLL CMake variable.
  • The x86-64 SIMD extensions now include support for Intel Control-flow Enforcement Technology (CET), which is enabled automatically if CET is enabled in the C compiler.
  • Fixed a regression introduced by 3.0 beta2[6] that made it impossible for calling applications to supply custom Huffman tables when generating 12-bit-per-component lossy JPEG images using the libjpeg API.
  • Fixed a segfault that occurred when attempting to use the jpegtran -drop option with a specially-crafted malformed input image or drop image (specifically an image in which all of the scans contain fewer components than the number of components specified in the Start Of Frame segment.)
Summary: Update libjpeg-turbo to version 3.0.2 → Update libjpeg-turbo to version 3.0.3

(In reply to Timothy Nikkel (:tnikkel) from comment #4)

RyanVM asked me to look into this. Recording what I found.

The files seem to need to be compiled multiple times with BITS_IN_JSAMPLE set to different values each time

https://github.com/libjpeg-turbo/libjpeg-turbo/blob/2dfe6c0fe9e18671105e94f7cbf044d4a1d157e6/sharedlib/CMakeLists.txt#L86

Documenting some discussion with glandium, our build system doesn't allow the same file to be compiled multiple times from the same moz.build file, so the only real option would be to create a different moz.build for each configuration in a different directory where the different BITS_IN_JSAMPLE value can be passed in. That sounds...fun.

What about creating a file like

#define BITS_IN_JSAMPLE 8

#include filetocompile.cpp

#define BITS_IN_JSAMPLE 10

#include filetocompile.cpp

And just compiling that, would that work?

I guess if we wanted to try going that route, this looks like the relevant set of source files we'd need to handle:

set(JPEG16_SOURCES jcapistd.c jccolor.c jcdiffct.c jclossls.c jcmainct.c
  jcprepct.c jcsample.c jdapistd.c jdcolor.c jddiffct.c jdlossls.c jdmainct.c
  jdpostct.c jdsample.c jutils.c)
set(JPEG12_SOURCES ${JPEG16_SOURCES} jccoefct.c jcdctmgr.c jdcoefct.c
  jddctmgr.c jdmerge.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c
  jidctred.c jquant1.c jquant2.c)
set(JPEG_SOURCES ${JPEG12_SOURCES} jcapimin.c jchuff.c jcicc.c jcinit.c
  jclhuff.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c jctrans.c
  jdapimin.c jdatadst.c jdatasrc.c jdhuff.c jdicc.c jdinput.c jdlhuff.c
  jdmarker.c jdmaster.c jdphuff.c jdtrans.c jerror.c jfdctflt.c jmemmgr.c
  jmemnobs.c jpeg_nbits.c)

Using separate moz.build files actually turned out to be pretty straightforward. I think that'll be a pretty workable solution here.

Assignee: nobody → ryanvm
Depends on: 1815737
Pushed by rvandermeulen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2ed1cc5bdd50 Update libjpeg-turbo to version 3.0.3. r=tnikkel
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
Regressions: 1896573
Regressions: 1898479
Regressions: 1898606
Regressions: 1901193
Regressions: 1902304

Per discussion with tnikkel, we're going to revert this for now until it's had more bake time.

Blocks: 1918889
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: