Friday, October 3, 2025

SpamSieve 3.2.1

SpamSieve 3.2.1 is a maintenance release of my Mac e-mail spam filter.

Previously:

5 Comments RSS · Twitter · Mastodon


The issue with callStackSymbols is Swift, as it converts to strings at the ObjC->Swift berrier. Instead, take the addresses (the other Array API), and translate on demand. I have a better replacement, that demangles C++ and Swift symbols:
https://github.com/LeoNatan/LNObjectiveCHelpers/blob/master/LNAddressInfo.mm

There is also a private API to initialize the special NSArray subclass with the addresses when you really need them.


@Léo I’m aware of the eager bridging, but that has previously not been a problem for me, and it seems like it could be defeated by preventing/delaying the conversion to Array (e.g. casting to NSArray), without having to demangle them yourself. Thanks for you solution, though. I think the main issue is that in rare cases the demangling is super slow. I’m not sure what causes that, though.


Yes, if you manager to preserve the NSArray and travel with that, it should not fire the symbolication. I'm not familiar with bugs in that flow, as theoretically, the data exists in the Mach-O and the cost should be the string allocations.


@Léo I tested this, and it works to just cast to NSArray when receiving the value in Swift. Here’s the bottom part of the slow sample:

1722 backtrace_symbols  (in libsystem_c.dylib) + 108  [0x7ff80fbdacaa]
  1722 dyld4::APIs::dladdr(void const*, dl_info*)  (in dyld) + 206  [0x7ff80f9f6a78]
    1722 dyld3::MachOLoaded::findClosestSymbol(unsigned long long, char const**, unsigned long long*) const  (in dyld) + 320  [0x7ff80fa14888]

Looking at source ( https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/common/MachOLoaded.cpp#L606 ), it is traveling the MachO headers. I wonder what is causing it to slow down.

Leave a Comment