Disable LLImageJPEG setjmp hack when building on ARM to avoid crash

master
Rye 2025-02-10 14:13:21 -05:00
parent fd94dc0cd0
commit 4a56738e4f
2 changed files with 13 additions and 2 deletions

View File

@ -31,7 +31,9 @@
#include "llerror.h" #include "llerror.h"
#include "llexception.h" #include "llexception.h"
#if !LL_ARM64
jmp_buf LLImageJPEG::sSetjmpBuffer ; jmp_buf LLImageJPEG::sSetjmpBuffer ;
#endif
LLImageJPEG::LLImageJPEG(S32 quality) LLImageJPEG::LLImageJPEG(S32 quality)
: LLImageFormatted(IMG_CODEC_JPEG), : LLImageFormatted(IMG_CODEC_JPEG),
mOutputBuffer( NULL ), mOutputBuffer( NULL ),
@ -78,12 +80,15 @@ bool LLImageJPEG::updateData()
// //
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//except in the case of AARCH64/ARM64 where setjmp will crash
// //
#if !LL_ARM64
if(setjmp(sSetjmpBuffer)) if(setjmp(sSetjmpBuffer))
{ {
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
return false; return false;
} }
#endif
try try
{ {
// Now we can initialize the JPEG decompression object. // Now we can initialize the JPEG decompression object.
@ -223,11 +228,13 @@ bool LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time)
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
// //
#if !LL_ARM64
if(setjmp(sSetjmpBuffer)) if(setjmp(sSetjmpBuffer))
{ {
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
return true; // done return true; // done
} }
#endif
try try
{ {
// Now we can initialize the JPEG decompression object. // Now we can initialize the JPEG decompression object.
@ -431,9 +438,10 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )
// Let the memory manager delete any temp files // Let the memory manager delete any temp files
jpeg_destroy(cinfo); jpeg_destroy(cinfo);
#if !LL_ARM64
// Return control to the setjmp point // Return control to the setjmp point
longjmp(sSetjmpBuffer, 1) ; longjmp(sSetjmpBuffer, 1) ;
#endif
} }
// Decide whether to emit a trace or warning message. // Decide whether to emit a trace or warning message.
@ -545,6 +553,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
// //
#if !LL_ARM64
if( setjmp(sSetjmpBuffer) ) if( setjmp(sSetjmpBuffer) )
{ {
// If we get here, the JPEG code has signaled an error. // If we get here, the JPEG code has signaled an error.
@ -555,7 +564,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
mOutputBufferSize = 0; mOutputBufferSize = 0;
return false; return false;
} }
#endif
try try
{ {

View File

@ -78,7 +78,9 @@ protected:
S32 mEncodeQuality; // on a scale from 1 to 100 S32 mEncodeQuality; // on a scale from 1 to 100
private: private:
#if !LL_ARM64
static jmp_buf sSetjmpBuffer; // To allow the library to abort. static jmp_buf sSetjmpBuffer; // To allow the library to abort.
#endif
}; };
#endif // LL_LLIMAGEJPEG_H #endif // LL_LLIMAGEJPEG_H