Bug in fuzz function() | Use-After-Free Bug. [libEXR & libAppleEXR]
Discussion & Analysis
libc++abi: terminating due to uncaught exception of type booboo
Summary: The fuzz() function in Jackalope when using example/imageio.variants contain some over-release and/or ARC Issues. Is easier to show the File Information, Channels and Sub Sampling Crash with the PoC Flowers.exr using Python, then show the same issue in Sub Sampling that the Fuzz() function it encountering.
Reproduction of Sub Sampling Issue causing Abort() in libAppleEXR and all those Apple Apps on XNU.
In this contrived example to Reproduce the Bug in these Frameworks, the best guess is that the Image File has been Closed yet the Code continues and is a Use-After-Free Bug. [libEXR & libAppleEXR]
Apple Bug - Potential Use-After-Free
(lldb) target create "/System/Applications/Preview.app/Contents/MacOS/Preview"
Current executable set to '/System/Applications/Preview.app/Contents/MacOS/Preview' (x86_64).
(lldb) settings set -- target.run-args "other_0xxxxxxxxxx7ce_0x0_1.exr"
(lldb) r
Process 61419 launched: '/System/Applications/Preview.app/Contents/MacOS/Preview' (x86_64)
,,,
2023-11-18 13:00:52.496289-0500 Preview[61419:3692146] [UI] No ORIGINAL document attributes found (error: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument")
2023-11-18 13:00:52.652203-0500 Preview[61419:3692146] [UI] Fetching document attributes for URL file:///other_0xxxxxxxxxx7ce_0x0_1.exr
2023-11-18 13:00:52.652311-0500 Preview[61419:3692146] [UI] No LAST MODIFIED document attributes found (error: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument")
2023-11-18 13:00:52.652442-0500 Preview[61419:3692146] [UI] No ORIGINAL document attributes found (error: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument")
libc++abi: terminating due to uncaught exception of type int
Process 61419 stopped
Bug in fuzz function() | Use-After-Free Bug. [libEXR & libAppleEXR]
Discussion & Analysis
Summary: The fuzz() function in Jackalope when using example/imageio.variants contain some over-release and/or ARC Issues. Is easier to show the File Information, Channels and Sub Sampling Crash with the PoC Flowers.exr using Python, then show the same issue in Sub Sampling that the Fuzz() function it encountering.
Reproduction of Sub Sampling Issue causing Abort() in libAppleEXR and all those Apple Apps on XNU.
Apple Bug - Potential Use-After-Free
__pthread_kill + 10 libsystem_kernel.dylib
: -> 0x7ff8072a37ce <+10>: jae 0x7ff8072a37d8 ; <+20> 0x7ff8072a37d0 <+12>: movq %rax, %rdi 0x7ff8072a37d3 <+15>: jmp 0x7ff80729d1c4 ; cerror_nocancel 0x7ff8072a37d8 <+20>: retq Target 0: (Preview) stopped. (lldb) bt__pthread_kill + 10 frame #1: 0x00007ff8072dbf30 libsystem_pthread.dylib
pthread_kill + 262 frame #2: 0x00007ff8071faa49 libsystem_c.dylibabort + 126 frame #3: 0x00007ff807294c72 libc++abi.dylib
abort_message + 241 frame #4: 0x00007ff807286e1a libc++abi.dylibdemangling_terminate_handler() + 266 frame #5: 0x00007ff806f27376 libobjc.A.dylib
_objc_terminate() + 104 frame #6: 0x00007ff8072940cb libc++abi.dylibstd::__terminate(void (*)()) + 6 frame #7: 0x00007ff807294086 libc++abi.dylib
std::terminate() + 54 frame #8: 0x00007ff806f385f1 libobjc.A.dylibobjc_terminate + 9 frame #9: 0x00007ff8071345e1 libdispatch.dylib
_dispatch_client_callout2 + 28 frame #10: 0x00007ff807144e3e libdispatch.dylib_dispatch_apply_invoke + 214 frame #11: 0x00007ff80713459a libdispatch.dylib
_dispatch_client_callout + 8 frame #12: 0x00007ff80714399d libdispatch.dylib_dispatch_root_queue_drain + 879 frame #13: 0x00007ff807143f22 libdispatch.dylib
_dispatch_worker_thread2 + 152 frame #14: 0x00007ff8072d8c06 libsystem_pthread.dylib_pthread_wqthread + 262 frame #15: 0x00007ff8072d7b97 libsystem_pthread.dylib
start_wqthread + 15Instrumented module CoreSVG, code size: 233472 2023-12-05 15:17:26.322141-0500 test_imageio[29656:288121] Terminating app due to uncaught exception 'NSBadBitmapParametersException', reason: 'Overflow allocating bitmap backing store. Cannot back bitmap with 1152921504606846976 bytes per row, 100 height, and 1 planes.' First throw call stack: ( 0 CoreFoundation 0x00007ff8198e6fa6 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8193dc231 objc_exception_throw + 48 2 CoreFoundation 0x00007ff8198e6e46 +[NSException raise:format:] + 214 3 AppKit 0x00007ff81cfc4473 NSNewBitmapBackingStore + 141 4 AppKit 0x00007ff81cfc3fed +[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:] + 609 5 AppKit 0x00007ff81cfcbb0d -[NSImageRep CGImageForProposedRect:context:hints:] + 591 6 AppKit 0x00007ff81cfa866f 48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke + 87 7 AppKit Terminating app due to uncaught exception 'NSBadBitmapParametersException', reason: 'Overflow allocating bitmap backing store. Cannot back bitmap with 1152921504606846976 bytes per row, 100 height, and 1 planes.' First throw call stack: ( 0 CoreFoundation 0x00007ff8198e6fa6 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8193dc231 objc_exception_throw + 48 2 CoreFoundation 0x00007ff8198e6e46 +[NSException raise:format:] + 214 3 AppKit 0x00007ff81cfc4473 NSNewBitmapBackingStore + 141 4 AppKit 0x00007ff81cfc3fed +[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:] + 609 5 AppKit 0x00007ff81cfcbb0d -[NSImageRep CGImageForProposedRect:context:hints:] + 591 6 AppKit 0x00007ff81cfa866f 48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke + 87 7 AppKit 0x00007ff81cfa82cc -[NSImage _usingBestRepresentationForRect:context:hints:body:] + 123 8 AppKit 0x00007ff81cfa791a -[NSImage CGImageForProposedRect:context:hints:] + 589 9 test_imageio 0x00000001000037e2 fuzz + 418 10 ??? 0x0000000000000f22 0x0 + 3874 11 dyld 0x00007ff8194103a6 start + 1942 ) libc++abi: terminating due to uncaught exception of type NSException Exception at address 0x7ff8197607ce
Instrumented module CoreSVG, code size: 233472 2023-12-05 15:17:37.448778-0500 test_imageio[29744:288395] Terminating app due to uncaught exception 'NSBadBitmapParametersException', reason: 'Overflow allocating bitmap backing store. Cannot back bitmap with 448 bytes per row, -9223372036854775808 height, and 1 planes.' First throw call stack: ( 0 CoreFoundation 0x00007ff8198e6fa6 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8193dc231 objc_exception_throw + 48 2 CoreFoundation 0x00007ff8198e6e46 +[NSException raise:format:] + 214 3 AppKit 0x00007ff81cfc4473 NSNewBitmapBackingStore + 141 4 AppKit 0x00007ff81cfc3fed +[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:] + 609 5 AppKit 0x00007ff81cfcbb0d -[NSImageRep CGImageForProposedRect:context:hints:] + 591 6 AppKit 0x00007ff81cfa866f 48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke + 87 7 AppKit Terminating app due to uncaught exception 'NSBadBitmapParametersException', reason: 'Overflow allocating bitmap backing store. Cannot back bitmap with 448 bytes per row, -9223372036854775808 height, and 1 planes.' First throw call stack: ( 0 CoreFoundation 0x00007ff8198e6fa6 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8193dc231 objc_exception_throw + 48 2 CoreFoundation 0x00007ff8198e6e46 +[NSException raise:format:] + 214 3 AppKit 0x00007ff81cfc4473 NSNewBitmapBackingStore + 141 4 AppKit 0x00007ff81cfc3fed +[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:] + 609 5 AppKit 0x00007ff81cfcbb0d -[NSImageRep CGImageForProposedRect:context:hints:] + 591 6 AppKit 0x00007ff81cfa866f 48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke + 87 7 AppKit 0x00007ff81cfa82cc -[NSImage _usingBestRepresentationForRect:context:hints:body:] + 123 8 AppKit 0x00007ff81cfa791a -[NSImage CGImageForProposedRect:context:hints:] + 589 9 test_imageio 0x00000001000037e2 fuzz + 418 10 ??? 0x0000000000000f22 0x0 + 3874 11 dyld 0x00007ff8194103a6 start + 1942 ) libc++abi: terminating due to uncaught exception of type NSException Exception at address 0x7ff8197607ce
Instrumented module CoreSVG, code size: 233472 2023-12-05 15:17:37.448778-0500 test_imageio[29744:288395] Terminating app due to uncaught exception 'NSBadBitmapParametersException', reason: 'Overflow allocating bitmap backing store. Cannot back bitmap with 448 bytes per row, -9223372036854775808 height, and 1 planes.' First throw call stack: ( 0 CoreFoundation 0x00007ff8198e6fa6 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8193dc231 objc_exception_throw + 48 2 CoreFoundation 0x00007ff8198e6e46 +[NSException raise:format:] + 214 3 AppKit 0x00007ff81cfc4473 NSNewBitmapBackingStore + 141 4 AppKit 0x00007ff81cfc3fed +[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:] + 609 5 AppKit 0x00007ff81cfcbb0d -[NSImageRep CGImageForProposedRect:context:hints:] + 591 6 AppKit 0x00007ff81cfa866f 48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke + 87 7 AppKit Terminating app due to uncaught exception 'NSBadBitmapParametersException', reason: 'Overflow allocating bitmap backing store. Cannot back bitmap with 448 bytes per row, -9223372036854775808 height, and 1 planes.' First throw call stack: ( 0 CoreFoundation 0x00007ff8198e6fa6 exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff8193dc231 objc_exception_throw + 48 2 CoreFoundation 0x00007ff8198e6e46 +[NSException raise:format:] + 214 3 AppKit 0x00007ff81cfc4473 NSNewBitmapBackingStore + 141 4 AppKit 0x00007ff81cfc3fed +[NSCGImageSnapshotRep _lockFocusForCreatingSnapshot:withRect:context:hints:flipped:] + 609 5 AppKit 0x00007ff81cfcbb0d -[NSImageRep CGImageForProposedRect:context:hints:] + 591 6 AppKit 0x00007ff81cfa866f 48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke + 87 7 AppKit 0x00007ff81cfa82cc -[NSImage _usingBestRepresentationForRect:context:hints:body:] + 123 8 AppKit 0x00007ff81cfa791a -[NSImage CGImageForProposedRect:context:hints:] + 589 9 test_imageio 0x00000001000037e2 fuzz + 418 10 ??? 0x0000000000000f22 0x0 + 3874 11 dyld 0x00007ff8194103a6 start + 1942 ) libc++abi: terminating due to uncaught exception of type NSException Exception at address 0x7ff8197607ce