Your message dated Sat, 08 Jun 2024 22:38:26 +0000
with message-id <[email protected]>
and subject line Bug#1069047: fixed in rust-bindgen-cli 0.66.1-6
has caused the Debian Bug report #1069047,
regarding librust-bindgen-dev: Thread 'main' panicked at 'called 
Result::unwrap() on an Err value
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1069047: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069047
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: librust-bindgen-dev
Version: 0.66.1-4
Severity: normal
Tags: patch upstream
X-Debbugs-Cc: [email protected]

Dear Maintainer,

While building the linux kernel with additional patches to enable support for 
Apple Silicon, I came across a Rust panic due to the way bindgen v0.66 
generates bindings. The error message I got was

> Thread 'main' panicked at 'called Result::unwrap() on an Err value: 
> FromBytesWithNulError { kind: InteriorNul(x) }

(where x is an integer I did not take note of). After a bit of digging I found 
out this is a known regression introduced in v0.66 and fixed in v0.68, having 
to do with how bindgen deals with strings that have null bytes inside them. 
More detail can be found at 
https://github.com/rust-lang/rust-bindgen/issues/2566 (issue) and 
https://github.com/rust-lang/rust-bindgen/pull/2567 (resolution). Would it be 
possible to upload a version of bindgen v0.66 with the patch backported from 
v0.68, or, as an alternative, to upgrade to the latter? I checked that the 
original patch applies cleanly to v0.66 as present in the Debian archive, e.g. 
by streamlining it and modifying the path of the patched file like in 
attachment.

Thank you,

NoisyCoil


*** /home/noisycoil/bindgen.patch
--- a/codegen/mod.rs
+++ b/codegen/mod.rs
@@ -714,18 +714,18 @@ impl CodeGenerator for Var {
                     let len = proc_macro2::Literal::usize_unsuffixed(
                         cstr_bytes.len(),
                     );
-                    let cstr = CStr::from_bytes_with_nul(&cstr_bytes).unwrap();
 
                     // TODO: Here we ignore the type we just made up, probably
                     // we should refactor how the variable type and ty ID work.
                     let array_ty = quote! { [u8; #len] };
                     let cstr_ty = quote! { ::#prefix::ffi::CStr };
 
-                    let bytes = proc_macro2::Literal::byte_string(
-                        cstr.to_bytes_with_nul(),
-                    );
+                    let bytes = proc_macro2::Literal::byte_string(&cstr_bytes);
 
-                    if rust_features.const_cstr && options.generate_cstr {
+                    if options.generate_cstr &&
+                        rust_features.const_cstr &&
+                        CStr::from_bytes_with_nul(&cstr_bytes).is_ok()
+                    {
                         result.push(quote! {
                             #(#attrs)*
                             #[allow(unsafe_code)]

--- End Message ---
--- Begin Message ---
Source: rust-bindgen-cli
Source-Version: 0.66.1-6
Done: NoisyCoil <[email protected]>

We believe that the bug you reported is fixed in the latest version of
rust-bindgen-cli, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
NoisyCoil <[email protected]> (supplier of updated rust-bindgen-cli 
package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Sun, 09 Jun 2024 00:12:28 +0200
Source: rust-bindgen-cli
Architecture: source
Version: 0.66.1-6
Distribution: unstable
Urgency: medium
Maintainer: Debian Rust Maintainers 
<[email protected]>
Changed-By: NoisyCoil <[email protected]>
Closes: 1069047
Changes:
 rust-bindgen-cli (0.66.1-6) unstable; urgency=medium
 .
   * Rebuild using rust-bindgen v0.66.1-6 (Closes: #1069047)
Checksums-Sha1:
 0cc392bdfd05709f8837bca0f4e118619fced363 1913 rust-bindgen-cli_0.66.1-6.dsc
 c1a46d79729f125cfcfbf581db9146d6678d495d 3012 
rust-bindgen-cli_0.66.1-6.debian.tar.xz
 4ad66aa086ffcc64273fff9075b90cea40b4faa7 6385 
rust-bindgen-cli_0.66.1-6_source.buildinfo
Checksums-Sha256:
 fbc814d800aad6e6b43a228a8dcb2b0209e2dd41cc24cfebce336266b80319cb 1913 
rust-bindgen-cli_0.66.1-6.dsc
 665d53ca48c87bbe7c5ca6d8154c979414ef0290a8e0a2432e34ca3ee228c0f3 3012 
rust-bindgen-cli_0.66.1-6.debian.tar.xz
 1a7b136980434ba958ef4a13c69769ae784848943dac1798b1453b940b03ef6d 6385 
rust-bindgen-cli_0.66.1-6_source.buildinfo
Files:
 e78c7dd4649bfb90513245108ba3eb66 1913 rust optional 
rust-bindgen-cli_0.66.1-6.dsc
 c43d19b89aa978d491da1d32f09fc15b 3012 rust optional 
rust-bindgen-cli_0.66.1-6.debian.tar.xz
 f21ddc8fea960e54d8e0c329a0b58e9a 6385 rust optional 
rust-bindgen-cli_0.66.1-6_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iHUEARYIAB0WIQQUWTv/Sl6/b+DpcW7svtu2B7myvgUCZmTXdQAKCRDsvtu2B7my
vozaAP9p0Tzns+V+FYBPzy3idQ3HyUqpiHhPGrmk98RG+byNmQD/fUBlHqi+Njy9
sXhaoIA8lEzlmNaTQJ/A6PJ4kOTytQ4=
=eTWR
-----END PGP SIGNATURE-----

Attachment: pgp2QfGUzkLyl.pgp
Description: PGP signature


--- End Message ---

Reply via email to