#5224·diesel

Run (some of) the tests via Miri

Author: weiznichCreated Sep 18, 2026Updated Sep 18, 2026
Labelsenhancementhelp wantedsqlitemysqlpostgresCIMariaDB

Rust Version

stable

Diesel Version

main

Diesel Features

all of them

Database Version

all of them

Operating System Version

Linux

What happened?

We currently run most of our tests not via Miri. We should do change this as some of the code involves quite a lot of unsafe ptr operations.

What did you expect to happen?

Miri provides several options to run FFI code now. This includes:

  • -Zmiri-native-lib to provide a path to a native library to use.
  • -Zmiri-native-lib-enable-tracing to use extended memory tracing for ffi code

I tried these flags a while ago and got at least some SQLite tests running with minimal patching. That mainly required to cfg out callback back to the Rust code starting from the FFI code as they are unsupported. (I still think that miri could in theory support them as well, but I don't have the capacity to fix that on my own).

As a starting point it's likely fine to run only a selected number of tests and heavily cfg out unsupported parts. We can always extend coverage later.

We likely want to integrate this kind of support with our cargo xtask wrapper to automatically set the "right" flags and environment variables. We also want to have a CI job that runs those tests.

Checklist

  • I have already looked over the issue tracker and the discussion forum for similar possible closed issues.

  • This issue can be reproduced on Rust's stable channel. (Please submit the issue in the Rust issue tracker instead if that's not the case)

  • This issue can be reproduced without requiring a third party crate