8000 ios: pass log messages to NSLog as an argument, not as the format by benface · Pull Request #684 · not-fl3/miniquad · GitHub
[go: up one dir, main page]

Skip to content

ios: pass log messages to NSLog as an argument, not as the format - #684

Open
benface wants to merge 1 commit into
not-fl3:masterfrom
benface:ios-log-format-string
Open

benface wants to merge 1 commit into
not-fl3:masterfrom
benface:ios-log-format-string

Conversation

@benface
@benface benface commented Oct 10, 2026
Copy link
Copy Markdown
Contributor

Why

NSLog reads its first argument as a format string. native::ios::log, which warn!, error! and the other log-impl macros call on iOS, passed the message there, and so did load_file's "loading:" line and the panic hook. When a message holds a format specifier, NSLog reads arguments that were never passed. So an app that logs text it doesn't control, such as a parse error quoting a corrupt file, crashes inside NSLog:

EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS at 0x000000000000001c
objc_opt_respondsToSelector
_NSDescriptionWithStringProxyFunc
__CFStringAppendFormatCore
…
_NSLogv
NSLog

Change

log passes the message as the argument to a fixed %@ format, so it prints as it is. load_file and the panic hook now log through log.

Verification

  • On the iOS Simulator (iOS 27.0), a macroquad game (CHOMP) whose save file read music = %@ %s %n crashed at launch when it logged the parse error with warn!. With this change, the warning prints that line as written and the game carries on.
  • cargo check passes for aarch64-apple-ios, aarch64-apple-tvos and aarch64-apple-darwin.

🤖 Generated with Claude Code

`NSLog` reads its first argument as a format string, and `log`,
`load_file`'s "loading:" line and the panic hook all passed their
message there. A message holding a format specifier made `NSLog`
read arguments that were never passed: a `warn!` whose text included
`%@` crashed the app with SIGSEGV, and any other `%` came out mangled.

Each message now goes in as the argument to a fixed `%@` format,
through `log`, so it prints as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0