Skip to content

Commit 638ecbe

Browse files
author
Rye
committed
Disable setjmp based error handling in llimagejpeg to work around crash on ARM
1 parent 5cd941b commit 638ecbe

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

indra/llimage/llimagejpeg.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "llerror.h"
3232
#include "llexception.h"
3333

34+
#if !LL_ARM64
3435
jmp_buf LLImageJPEG::sSetjmpBuffer ;
36+
#endif
3537
LLImageJPEG::LLImageJPEG(S32 quality)
3638
: LLImageFormatted(IMG_CODEC_JPEG),
3739
mOutputBuffer( NULL ),
@@ -78,12 +80,15 @@ bool LLImageJPEG::updateData()
7880
//
7981
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
8082
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
83+
//except in the case of AARCH64/ARM64 where setjmp will crash
8184
//
85+
#if !LL_ARM64
8286
if(setjmp(sSetjmpBuffer))
8387
{
8488
jpeg_destroy_decompress(&cinfo);
8589
return false;
8690
}
91+
#endif
8792
try
8893
{
8994
// Now we can initialize the JPEG decompression object.
@@ -223,11 +228,13 @@ bool LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time)
223228
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
224229
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
225230
//
231+
#if !LL_ARM64
226232
if(setjmp(sSetjmpBuffer))
227233
{
228234
jpeg_destroy_decompress(&cinfo);
229235
return true; // done
230236
}
237+
#endif
231238
try
232239
{
233240
// Now we can initialize the JPEG decompression object.
@@ -431,9 +438,10 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )
431438

432439
// Let the memory manager delete any temp files
433440
jpeg_destroy(cinfo);
434-
441+
#if !LL_ARM64
435442
// Return control to the setjmp point
436443
longjmp(sSetjmpBuffer, 1) ;
444+
#endif
437445
}
438446

439447
// Decide whether to emit a trace or warning message.
@@ -545,6 +553,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
545553
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
546554
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
547555
//
556+
#if !LL_ARM64
548557
if( setjmp(sSetjmpBuffer) )
549558
{
550559
// 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 )
555564
mOutputBufferSize = 0;
556565
return false;
557566
}
558-
567+
#endif
559568
try
560569
{
561570

indra/llimage/llimagejpeg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ class LLImageJPEG : public LLImageFormatted
7878

7979
S32 mEncodeQuality; // on a scale from 1 to 100
8080
private:
81+
#if !LL_ARM64
8182
static jmp_buf sSetjmpBuffer; // To allow the library to abort.
83+
#endif
8284
};
8385

8486
#endif // LL_LLIMAGEJPEG_H

0 commit comments

Comments
 (0)