summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-08-02 06:42:48 +0800
committerErik Kundiman <erik@megapahit.org>2024-08-02 06:42:48 +0800
commit631e50e18719c52970c788dd70c19bd14e0d3a54 (patch)
tree2be0dbc088db0a7959396c2b73d93bbb0073632d
parentf6ceee3a4d789bc1b47a00d5672cefc99bb93c98 (diff)
Fix crash when opening map on higher-end Mx CPUs
There's this comment in indra/llimage/llimagejpeg.cpp: //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 but setjmp longjmp that aren't properly paired should be avoided on Apple Silicon (there are multiple setjmps but only 1 longjmp) so if it still crashes, then that might be because of the try and catch but if it doesn't crash any more, then the cause might just be improperly paired setjmp and longjmp https://megapahit.com/show_bug.cgi?id=34
-rw-r--r--indra/llimage/llimagejpeg.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp
index 93f1d0cdc4..a6da2f66ab 100644
--- a/indra/llimage/llimagejpeg.cpp
+++ b/indra/llimage/llimagejpeg.cpp
@@ -77,11 +77,13 @@ bool LLImageJPEG::updateData()
//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
//
+#if !(LL_DARWIN && defined(__arm64__))
if(setjmp(sSetjmpBuffer))
{
jpeg_destroy_decompress(&cinfo);
return false;
}
+#endif
try
{
// Now we can initialize the JPEG decompression object.
@@ -218,11 +220,13 @@ bool LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time)
//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
//
+#if !(LL_DARWIN && defined(__arm64__))
if(setjmp(sSetjmpBuffer))
{
jpeg_destroy_decompress(&cinfo);
return true; // done
}
+#endif
try
{
// Now we can initialize the JPEG decompression object.
@@ -426,7 +430,9 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )
jpeg_destroy(cinfo);
// Return control to the setjmp point
+#if !(LL_DARWIN && defined(__arm64__))
longjmp(sSetjmpBuffer, 1) ;
+#endif
}
// Decide whether to emit a trace or warning message.
@@ -535,6 +541,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
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//
+#if !(LL_DARWIN && defined(__arm64__))
if( setjmp(sSetjmpBuffer) )
{
// If we get here, the JPEG code has signaled an error.
@@ -545,6 +552,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
mOutputBufferSize = 0;
return false;
}
+#endif
try
{