We’re getting a crash in Utilities.urlEncoded(_ in the SnowplowTracker iOS library. Using 6.0.8, but I don’t see anything related in fixes for 6.0.9 or 6.1.0.
Has this happened to anyone else? It specifically happens when addingPercentEncoding(withAllowedCharacters:). I’ve tried to break that Core Foundation method will all kinds of characters or a empty string, but I can’t make it happen, yet the crash is real.
Hi Mike. Can’t seem to attach the crash log here. And it’s reading the copy paste as containing more than 2 links, even though there are none, and not allowing it as I’m a new user.
This from the NSStringAPI file in Swift Foundation, which is called 2 steps before the crash in the crash report:
/// Returns a new string created by replacing all characters in the string
/// not in the specified set with percent encoded characters.
public func addingPercentEncoding(
withAllowedCharacters allowedCharacters: CharacterSet
) → String? {
// FIXME: the documentation states that this method can return nil if the
// transformation is not possible, without going into further details. The
// implementation can only return nil if malloc() returns nil, so in
// practice this is not possible. Still, to be consistent with
// documentation, we declare the method as returning an optional String.
//
// rdar://problem/17901698 Docs for -[NSString
// stringByAddingPercentEncodingWithAllowedCharacters] don’t precisely
// describe when return value is nil
return _ns.addingPercentEncoding(withAllowedCharacters:
allowedCharacters
)
}
Thanks. Attaching the crash report below. All crashes come from users running iOS 18.1.1, but that needn’t be relevant. There are only 21 reports across 6 users. Seems perhaps they have a memory issue on their device, malloc() returns NULL, but that fails to become a nil return from the method.
Date/Time: 2025-01-16 02:24:48.8735 +0100
Launch Time: 2025-01-16 01:37:36.6761 +0100
OS Version: iPhone OS 18.1.1 (22B91)
Release Type: User
Baseband Version: 2.20.03
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4345217024
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
—>
__TEXT 102fec000-102ff0000 [ 16K] r-x/r-x SM=COW /var/containers/Bundle/Application/17C03FC7-A322-4858-BE96-74E37D52D66C/Casino.app/Casino
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [3287]
Thank you for the report, I just looked into this, but it seems a bit challenging to resolve as it is an exception produced in Foundation APIs and not something under our control.
We can’t really catch the exception as it is a low level memory access signal. As you suggested, it could relate to a memory issue, perhaps low memory on device.
We could consider using a different method for URL encoding in the tracker, perhaps one that is implemented in Swift rather than ObjC and more memory safe.