antirez / antirez/voxtral.c

Crash on macOS 14.x due to unguarded mathMode API usage

Offen
#17 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C
Sterne
1.7k
Forks
123
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Bug: Crash on macOS 14.x due to unguarded mathMode API usage

### Description
The application crashes on macOS versions prior to 15.0 with the following error:

-[MTLCompileOptionsInternal setMathMode:]: unrecognized selector sent to instance ...

This occurs in voxtral_metal.m when attempting to set the mathMode property, which is only available on macOS 15.0+.

### Location
The problematic code is located at:

```objc
voxtral_metal.m:438:17:
438 | options.mathMode = MTLMathModeFast;
| ^~~~~~~~
```

### Environment
- OS: macOS 14.8.5
- Library: voxtral (latest)
- Metal API: MTLCompileOptions

### Root Cause
The code unconditionally accesses options.mathMode. Since this property was introduced in macOS 15.0 (Sequoia), calling it on macOS 14.x triggers an NSInvalidArgumentException because the selector does not exist on the runtime object.

### Proposed Fix
Guard the mathMode assignment with an availability check and fall back to fastMathEnabled for older systems:

```objc
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000
if (@available(macOS 15.0, *)) {
options.mathMode = MTLMathModeFast;
} else {
options.fastMathEnabled = YES;
}
#else
options.fastMathEnabled = YES;
#endif
```

### Testing
- macOS 14.8.5: Crash resolved, application runs correctly with fallback.
- Behavior: fastMathEnabled provides equivalent performance characteristics for this use case.

### Impact
- Fixes critical crash for macOS 14.x users.
- No functional regression on macOS 15.0+.
- Minimal code change (~10 lines).

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.