This is the tale of a long weekend spent uncovering a mysterious iOS 18 Neural Engine bug—a journey of problem-solving in a system where full visibility is elusive, especially in the locked-down world of Apple’s platforms. But the process I followed is a general approach you can use for any opaque system. It all began last week when I stumbled upon a strange behavior in my iOS app. The output generated from a CoreML model was completely broken—something I had never seen before. And after some digging, I realized this only happened when the model was running on the Neural Engine of iOS 18. The first step was triage. I implemented a quick workaround in the app: if the device is running iOS 18, switch from the Neural Engine to the GPU. This temporarily solved the issue, but I had no idea why it worked or whether other CoreML models in the app’s pipeline might also be affected. Without a deeper understanding of the root cause, I knew I cou
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile this with -rdynamic and your emulator .so with -fPIC -fpie -shared | |
#include <dlfcn.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include "dcheck.h" | |
static char logfile_name[] = "/tmp/gbtracer.log.XXXXXX"; | |
static int logfile_fd = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/runtime.h> | |
#import <mach/mach.h> | |
#import <malloc/malloc.h> | |
#import <dlfcn.h> | |
typedef struct { | |
Class targetClass; | |
void (^block)(id object, BOOL isSubclass, BOOL *stop); | |
dispatch_semaphore_t semaphore; | |
BOOL shouldStop; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# coding=utf-8 | |
""" | |
Apple eficheck EALF parser | |
Copyright (C) 2024 Plato Mavropoulos | |
""" | |
import ctypes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'pathname' | |
def update_name(name, options) | |
pattern = /#{options[:rpath]}/ | |
if name =~ pattern | |
suffix = $' | |
if options[:path].join(suffix).exist? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>ShutdownReportTimeout</key> | |
<integer>2</integer> | |
<key>SIGTERMTimeout</key> | |
<integer>5</integer> | |
<key>CrashOnSIGTERMTimeout</key> | |
<true/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CoreGraphics/CoreGraphics.h> | |
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
#import <objc/message.h> | |
#import <dlfcn.h> | |
__attribute__((constructor)) static void init(void) { | |
Method bundleIdentifierMethod = class_getInstanceMethod(objc_getClass("NSBundle"), sel_registerName("bundleIdentifier")); | |
IMP newImp = imp_implementationWithBlock(^(id self) { |
resources to find what Apple/Asahi acronyms mean:
- check out this table
- search with
site:asahilinux.org
(maybe they talked about it in the blog) - grep the linux and m1n1 repos
some other random acronyms, mostly peripherals of the SoC:
- AIC → Apple Interrupt Controller
- AP → Application Processor (where the OS runs)
- DART → Device Address Resolution Table (IOMMU)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Decompresses a pbzx stream. | |
Simplified/corrected version of <https://gist.github.com/Lekensteyn/6e0840e77bc9bd013f57> | |
Example usage (from Python): | |
decompress_pbzx(open('PayloadJava', 'rb'), open('PayloadJava.cpio', wb')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************** | |
add a grid to a graph in .dot format | |
**************************************************************************/ | |
BEGIN{ | |
int i, Indx, bcnt, LR; | |
string Type, Val, Gcolor[], Gstyle[], Gsize[], tmpstr; | |
string Hcolor, Vcolor, Hstyle, Vstyle, gridType, gridAlign; | |
float Hsize, Vsize, deltaX, deltaY, minX, minY, maxX, maxY; |