Mercurial > public > mercurial-scm > hg-stable
diff tests/test-persistent-nodemap.t @ 46353:7d0405e458a0 stable
persistent-nodemap: Fix Rust declarations for Revlog_CAPI signatures
Use Rust?s `libc::ssize_t` as the closest match to C?s `Py_ssize_t`.
See details in test comment.
Going forward we should find a way to have such Rust declarations
auto-generated from C headers at build time,
or auto-checked against them in a test.
Differential Revision: https://phab.mercurial-scm.org/D9901
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 28 Jan 2021 13:15:34 +0100 |
parents | 3df00f905458 |
children | bfaacfa8ebfc |
line wrap: on
line diff
--- a/tests/test-persistent-nodemap.t Thu Jan 28 13:25:37 2021 +0100 +++ b/tests/test-persistent-nodemap.t Thu Jan 28 13:15:34 2021 +0100 @@ -33,10 +33,18 @@ #if rust -Reported bug: some Rust code panics when handling the null revision +Regression test for a previous bug in Rust/C FFI for the `Revlog_CAPI` capsule: +in places where `mercurial/cext/revlog.c` function signatures use `Py_ssize_t` +(64 bits on Linux x86_64), corresponding declarations in `rust/hg-cpython/src/cindex.rs` +incorrectly used `libc::c_int` (32 bits). +As a result, -1 passed from Rust for the null revision became 4294967295 in C. - $ hg log -r 00000000 2>&1 | grep panicked - thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', hg-cpython/src/revlog.rs:* (glob) + $ hg log -r 00000000 + changeset: -1:000000000000 + tag: tip + user: + date: Thu Jan 01 00:00:00 1970 +0000 + #endif