ollama - 💡(How to fix) Fix Crash on Windows: Exception 0xc0000005 in MLX during startup [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15059Fetched 2026-04-08 01:31:32
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1labeled ×1

Error Message

Ollama crashes immediately on startup (or when running any command like ollama --version) with an access violation error (0xc0000005). The crash appears to originate from the MLX image generation module. Immediate crash with the following error: `Exception 0xc0000005 0x8 0x7fff05cecb12 0x7fff05cecb12

RAW_BUFFERClick to expand / collapse

What is the issue?

Description

Ollama crashes immediately on startup (or when running any command like ollama --version) with an access violation error (0xc0000005). The crash appears to originate from the MLX image generation module.

This prevents the application from starting at all.

Steps to Reproduce

  • Install Ollama on Windows

  • Run: ollama or ollama --version

  • Observe crash

Actual Behavior

Immediate crash with the following error: `Exception 0xc0000005 0x8 0x7fff05cecb12 0x7fff05cecb12 PC=0x7fff05cecb12 signal arrived during external code execution

runtime.cgocall(...) github.com/ollama/ollama/x/imagegen/mlx._Cfunc_mlx_random_key(...) github.com/ollama/ollama/x/imagegen/mlx.RandomKey(...) ...`

Environment OS: Windows 10 (22H2) CPU: I7-14700KF GPU: AMD RX 9070 XT

Relevant log output

OS

Windows

GPU

AMD

CPU

Intel

Ollama version

No response

extent analysis

Fix Plan

The fix involves updating the MLX image generation module to handle compatibility issues with Windows.

  • Update the go.mod file to use the latest version of the MLX library.
  • Modify the mlx.go file to include error checking for the mlx_random_key function.
  • Use the following example code to handle the error:
// mlx.go
package mlx

/*
#include <mlx.h>
*/
import "C"
import "unsafe"

func RandomKey() (key []byte, err error) {
    // Check if the MLX library is initialized
    if C.mlx_init() != 0 {
        return nil, fmt.Errorf("failed to initialize MLX library")
    }
    // Call the mlx_random_key function
    cKey := C.mlx_random_key()
    if cKey == nil {
        return nil, fmt.Errorf("failed to generate random key")
    }
    // Convert the C string to a Go byte slice
    key = C.GoBytes(unsafe.Pointer(cKey), C.mlx_key_len())
    return key, nil
}
  • Rebuild the Ollama application with the updated MLX library.

Verification

To verify the fix, run the Ollama application with the --version flag. If the application starts without crashing, the fix is successful.

Extra Tips

  • Ensure that the MLX library is compatible with the Windows operating system.
  • Check for any other dependencies that may be causing compatibility issues.
  • Test the application on different environments to ensure that the fix is not specific to one setup.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING