Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regex v1.9.1 / regex-lite v0.1.0: test failures on 32-bit architectures #1041

Closed
decathorpe opened this issue Jul 12, 2023 · 8 comments
Closed

Comments

@decathorpe
Copy link
Contributor

This is a followup from issue #1039 - it appears that similar problems are also present in regex.

Failed doctests are:

    src/builders.rs - builders::bytes::RegexBuilder::size_limit (line 1848)
    src/builders.rs - builders::bytes::RegexSetBuilder::size_limit (line 2420)
    src/builders.rs - builders::string::RegexBuilder::size_limit (line 671)
    src/builders.rs - builders::string::RegexSetBuilder::size_limit (line 1238)
    src/regex/bytes.rs - regex::bytes::CaptureLocations (line 2027)
    src/regex/string.rs - regex::string::CaptureLocations (line 2030)

The first four due to the same size limit being too high for 32-bit architectures, and the last two are again usize literals that are too big for their data type.

Full output for the failures:

failures:
---- src/builders.rs - builders::bytes::RegexBuilder::size_limit (line 1848) stdout ----
Test executable failed (exit status: 101).
stderr:
thread 'main' panicked at 'assertion failed: RegexBuilder::new(r\"\\w\").size_limit(45_000).build().is_err()', src/builders.rs:9:1
stack backtrace:
   0: 0x566abcfe - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e3f417bcf02dcd3
   1: 0x566c7030 - core::fmt::write::hffb0d28c8178d868
   2: 0x566a9d41 - std::io::Write::write_fmt::hd9c1e94d8083a97a
   3: 0x566abacf - std::sys_common::backtrace::print::hb33e9d6b17b3830e
   4: 0x566ad065 - std::panicking::default_hook::{{closure}}::hf736b577d9673442
   5: 0x566ace0e - std::panicking::default_hook::h9d3c62164da10493
   6: 0x566ad63f - std::panicking::rust_panic_with_hook::he6cb4c574f9b74cc
   7: 0x566ad4d2 - std::panicking::begin_panic_handler::{{closure}}::h3fc1035efef798c2
   8: 0x566ac185 - std::sys_common::backtrace::__rust_end_short_backtrace::h581f3c2cbdbe7ea7
   9: 0x566ad242 - rust_begin_unwind
  10: 0x565edb65 - core::panicking::panic_fmt::ha43a609b26c80be9
  11: 0x565edc1c - core::panicking::panic::h70e891db19a9baae
  12: 0x565f4c99 - rust_out::main::_doctest_main_src_builders_rs_1848_0::hf31ead4db7a91307
  13: 0x565f4b35 - rust_out::main::h9d36f4e323f71253
  14: 0x565ee666 - core::ops::function::FnOnce::call_once::hf4cccc4427ce6158
  15: 0x565ee2dc - std::sys_common::backtrace::__rust_begin_short_backtrace::h089b476c5bb5b3a0
  16: 0x565ee372 - std::rt::lang_start::{{closure}}::hb608a0b24121b256
  17: 0x566a7eef - std::rt::lang_start_internal::hba2f6c9bd49860d0
  18: 0x565ee337 - std::rt::lang_start::h7704b4ab844b068a
  19: 0x565f4cd9 - main
  20: 0xf7dcb969 - __libc_start_call_main
  21: 0xf7dcba2c - __libc_start_main@GLIBC_2.0
  22: 0x565ee1bb - _start
  23:        0x0 - <unknown>
---- src/builders.rs - builders::bytes::RegexSetBuilder::size_limit (line 2420) stdout ----
Test executable failed (exit status: 101).
stderr:
thread 'main' panicked at 'assertion failed: RegexSetBuilder::new([r\"\\w\"]).size_limit(45_000).build().is_err()', src/builders.rs:9:1
stack backtrace:
   0: 0x566db69e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e3f417bcf02dcd3
   1: 0x566f69d0 - core::fmt::write::hffb0d28c8178d868
   2: 0x566d96e1 - std::io::Write::write_fmt::hd9c1e94d8083a97a
   3: 0x566db46f - std::sys_common::backtrace::print::hb33e9d6b17b3830e
   4: 0x566dca05 - std::panicking::default_hook::{{closure}}::hf736b577d9673442
   5: 0x566dc7ae - std::panicking::default_hook::h9d3c62164da10493
   6: 0x566dcfdf - std::panicking::rust_panic_with_hook::he6cb4c574f9b74cc
   7: 0x566dce72 - std::panicking::begin_panic_handler::{{closure}}::h3fc1035efef798c2
   8: 0x566dbb25 - std::sys_common::backtrace::__rust_end_short_backtrace::h581f3c2cbdbe7ea7
   9: 0x566dcbe2 - rust_begin_unwind
  10: 0x56619a25 - core::panicking::panic_fmt::ha43a609b26c80be9
  11: 0x56619adc - core::panicking::panic::h70e891db19a9baae
  12: 0x5662340b - rust_out::main::_doctest_main_src_builders_rs_2420_0::hea679552552023ec
  13: 0x56623295 - rust_out::main::h9d36f4e323f71253
  14: 0x5661a7e6 - core::ops::function::FnOnce::call_once::hf4cccc4427ce6158
  15: 0x5661a37c - std::sys_common::backtrace::__rust_begin_short_backtrace::h089b476c5bb5b3a0
  16: 0x5661a412 - std::rt::lang_start::{{closure}}::hb608a0b24121b256
  17: 0x566d788f - std::rt::lang_start_internal::hba2f6c9bd49860d0
  18: 0x5661a3d7 - std::rt::lang_start::h7704b4ab844b068a
  19: 0x56623449 - main
  20: 0xf7ce3969 - __libc_start_call_main
  21: 0xf7ce3a2c - __libc_start_main@GLIBC_2.0
  22: 0x5661a07b - _start
  23:        0x0 - <unknown>
---- src/builders.rs - builders::string::RegexBuilder::size_limit (line 671) stdout ----
Test executable failed (exit status: 101).
stderr:
thread 'main' panicked at 'assertion failed: RegexBuilder::new(r\"\\w\").size_limit(45_000).build().is_err()', src/builders.rs:9:1
stack backtrace:
   0: 0x566e9cfe - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e3f417bcf02dcd3
   1: 0x56705030 - core::fmt::write::hffb0d28c8178d868
   2: 0x566e7d41 - std::io::Write::write_fmt::hd9c1e94d8083a97a
   3: 0x566e9acf - std::sys_common::backtrace::print::hb33e9d6b17b3830e
   4: 0x566eb065 - std::panicking::default_hook::{{closure}}::hf736b577d9673442
   5: 0x566eae0e - std::panicking::default_hook::h9d3c62164da10493
   6: 0x566eb63f - std::panicking::rust_panic_with_hook::he6cb4c574f9b74cc
   7: 0x566eb4d2 - std::panicking::begin_panic_handler::{{closure}}::h3fc1035efef798c2
   8: 0x566ea185 - std::sys_common::backtrace::__rust_end_short_backtrace::h581f3c2cbdbe7ea7
   9: 0x566eb242 - rust_begin_unwind
  10: 0x5662bb65 - core::panicking::panic_fmt::ha43a609b26c80be9
  11: 0x5662bc1c - core::panicking::panic::h70e891db19a9baae
  12: 0x56632c99 - rust_out::main::_doctest_main_src_builders_rs_671_0::h111b55522a3a221f
  13: 0x56632b35 - rust_out::main::h9d36f4e323f71253
  14: 0x5662c666 - core::ops::function::FnOnce::call_once::hf4cccc4427ce6158
  15: 0x5662c2dc - std::sys_common::backtrace::__rust_begin_short_backtrace::h089b476c5bb5b3a0
  16: 0x5662c372 - std::rt::lang_start::{{closure}}::hb608a0b24121b256
  17: 0x566e5eef - std::rt::lang_start_internal::hba2f6c9bd49860d0
  18: 0x5662c337 - std::rt::lang_start::h7704b4ab844b068a
  19: 0x56632cd9 - main
  20: 0xf7cfb969 - __libc_start_call_main
  21: 0xf7cfba2c - __libc_start_main@GLIBC_2.0
  22: 0x5662c1bb - _start
  23:        0x0 - <unknown>
---- src/builders.rs - builders::string::RegexSetBuilder::size_limit (line 1238) stdout ----
Test executable failed (exit status: 101).
stderr:
thread 'main' panicked at 'assertion failed: RegexSetBuilder::new([r\"\\w\"]).size_limit(45_000).build().is_err()', src/builders.rs:9:1
stack backtrace:
   0: 0x5667769e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e3f417bcf02dcd3
   1: 0x566929d0 - core::fmt::write::hffb0d28c8178d868
   2: 0x566756e1 - std::io::Write::write_fmt::hd9c1e94d8083a97a
   3: 0x5667746f - std::sys_common::backtrace::print::hb33e9d6b17b3830e
   4: 0x56678a05 - std::panicking::default_hook::{{closure}}::hf736b577d9673442
   5: 0x566787ae - std::panicking::default_hook::h9d3c62164da10493
   6: 0x56678fdf - std::panicking::rust_panic_with_hook::he6cb4c574f9b74cc
   7: 0x56678e72 - std::panicking::begin_panic_handler::{{closure}}::h3fc1035efef798c2
   8: 0x56677b25 - std::sys_common::backtrace::__rust_end_short_backtrace::h581f3c2cbdbe7ea7
   9: 0x56678be2 - rust_begin_unwind
  10: 0x565b5a25 - core::panicking::panic_fmt::ha43a609b26c80be9
  11: 0x565b5adc - core::panicking::panic::h70e891db19a9baae
  12: 0x565bf40b - rust_out::main::_doctest_main_src_builders_rs_1238_0::h4fd3d4ec58f2cebb
  13: 0x565bf295 - rust_out::main::h9d36f4e323f71253
  14: 0x565b67e6 - core::ops::function::FnOnce::call_once::hf4cccc4427ce6158
  15: 0x565b637c - std::sys_common::backtrace::__rust_begin_short_backtrace::h089b476c5bb5b3a0
  16: 0x565b6412 - std::rt::lang_start::{{closure}}::hb608a0b24121b256
  17: 0x5667388f - std::rt::lang_start_internal::hba2f6c9bd49860d0
  18: 0x565b63d7 - std::rt::lang_start::h7704b4ab844b068a
  19: 0x565bf449 - main
  20: 0xf7d72969 - __libc_start_call_main
  21: 0xf7d72a2c - __libc_start_main@GLIBC_2.0
  22: 0x565b607b - _start
  23:        0x0 - <unknown>
---- src/regex/bytes.rs - regex::bytes::CaptureLocations (line 2027) stdout ----
error: literal out of range for `usize`
  --> src/regex/bytes.rs:2040:27
   |
16 | assert_eq!(None, locs.get(34973498648));
   |                           ^^^^^^^^^^^
   |
   = note: the literal `34973498648` does not fit into the type `usize` whose range is `0..=4294967295`
   = note: `#[deny(overflowing_literals)]` on by default
error: literal out of range for `usize`
  --> src/regex/bytes.rs:2041:27
   |
17 | assert_eq!(None, locs.get(9944060567225171988));
   |                           ^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `9944060567225171988` does not fit into the type `usize` whose range is `0..=4294967295`
error: aborting due to 2 previous errors
Couldn't compile the test.
---- src/regex/string.rs - regex::string::CaptureLocations (line 2030) stdout ----
error: literal out of range for `usize`
  --> src/regex/string.rs:2043:27
   |
16 | assert_eq!(None, locs.get(34973498648));
   |                           ^^^^^^^^^^^
   |
   = note: the literal `34973498648` does not fit into the type `usize` whose range is `0..=4294967295`
   = note: `#[deny(overflowing_literals)]` on by default
error: literal out of range for `usize`
  --> src/regex/string.rs:2044:27
   |
17 | assert_eq!(None, locs.get(9944060567225171988));
   |                           ^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `9944060567225171988` does not fit into the type `usize` whose range is `0..=4294967295`
error: aborting due to 2 previous errors
Couldn't compile the test.
failures:
    src/builders.rs - builders::bytes::RegexBuilder::size_limit (line 1848)
    src/builders.rs - builders::bytes::RegexSetBuilder::size_limit (line 2420)
    src/builders.rs - builders::string::RegexBuilder::size_limit (line 671)
    src/builders.rs - builders::string::RegexSetBuilder::size_limit (line 1238)
    src/regex/bytes.rs - regex::bytes::CaptureLocations (line 2027)
    src/regex/string.rs - regex::string::CaptureLocations (line 2030)
test result: FAILED. 231 passed; 6 failed; 1 ignored; 0 measured; 0 filtered out; finished in 33.09s
error: doctest failed, to rerun pass `--doc`
error: 1 target failed:
    `--doc`
@BurntSushi
Copy link
Member

Is it possible for you to do a complete check to make sure there aren't any more? I don't really want to play whack-a-mole here. Ideally we could get this tested in CI somehow, but I'm not sure what the best path to that is.

@BurntSushi BurntSushi added the bug label Jul 12, 2023
@decathorpe
Copy link
Contributor Author

decathorpe commented Jul 12, 2023

As far as I can tell, these were the last ones. I have looked and verified this for the latest versions of regex-test, regex-syntax, regex-automata, and regex, and regex-lite also looks good.

As far as testing doctests goes, I have no experience with cross, we run all our tests on actual hardware.
Though for i686 I don't think you even need special tools? Running tests on x86_64-unknown-linux-gnu with "--target i686-unknown-linux-gnu" should just work (or at least, it used to work when I last needed to do that) - assuming that the toolchain for it was installed with rustup.

EDIT: Pressed the button too fast, regex-lite also has failures on i686, will paste them below.

@decathorpe
Copy link
Contributor Author

Failures from regex-lite v0.1.0:

failures:
---- src/string.rs - string::CaptureLocations (line 2065) stdout ----
error: literal out of range for `usize`
  --> src/string.rs:2078:27
   |
16 | assert_eq!(None, locs.get(34973498648));
   |                           ^^^^^^^^^^^
   |
   = note: the literal `34973498648` does not fit into the type `usize` whose range is `0..=4294967295`
   = note: `#[deny(overflowing_literals)]` on by default
error: literal out of range for `usize`
  --> src/string.rs:2079:27
   |
17 | assert_eq!(None, locs.get(9944060567225171988));
   |                           ^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `9944060567225171988` does not fit into the type `usize` whose range is `0..=4294967295`
error: aborting due to 2 previous errors
Couldn't compile the test.
failures:
    src/string.rs - string::CaptureLocations (line 2065)
test result: FAILED. 82 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.06s
error: doctest failed, to rerun pass `--doc`
error: 1 target failed:
    `--doc`

@decathorpe decathorpe changed the title regex v1.9.1: test failures on 32-bit architectures regex v1.9.1 / regex-lite v0.1.0: test failures on 32-bit architectures Jul 12, 2023
@BurntSushi
Copy link
Member

No dice on just running cargo directly:

$ cargo test --manifest-path regex-automata/Cargo.toml --target i686-unknown-linux-gnu --doc
    Finished test [optimized + debuginfo] target(s) in 0.01s

So maybe it isn't cross that doesn't support doctests for non-host targets, but that it's rustdoc (or whatever) itself.

@BurntSushi
Copy link
Member

So it looks like either some new test runner needs to be devised for the doctests to run on non-host targets, or we need actual i686 hardware in CI to run these tests. I doubt either one of those is happening unfortunately. So it looks like we're just going to have to play whack-a-mole as they come up.

@BurntSushi
Copy link
Member

OK, I have a fix incoming that should squash these tests.

In the future, I'd rather not open issues for this. Just file PRs that disable tests that don't work on 32-bit. I have literally no easy way of running these tests myself in a 32-bit environment.

@decathorpe
Copy link
Contributor Author

decathorpe commented Oct 8, 2023

Yeah, that works for me. I'll file PRs instead of tickets in the future. Thanks!

@BurntSushi
Copy link
Member

Perfect, thank you!!!

BurntSushi added a commit that referenced this issue Oct 8, 2023
Some doc tests make 64-bit assumptions and fail on 32-bit. I'd be open
to perhaps refactoring the tests somehow to make them work on both, but
I literally have no easy way to run doc tests in a 32-bit environment.
Without being able to actually run them myself, I don't feel comfortable
doing anything other than squashing the tests in that case.

Closes #1041
BurntSushi added a commit that referenced this issue Oct 8, 2023
Some doc tests make 64-bit assumptions and fail on 32-bit. I'd be open
to perhaps refactoring the tests somehow to make them work on both, but
I literally have no easy way to run doc tests in a 32-bit environment.
Without being able to actually run them myself, I don't feel comfortable
doing anything other than squashing the tests in that case.

Closes #1041
BurntSushi added a commit that referenced this issue Oct 9, 2023
Some doc tests make 64-bit assumptions and fail on 32-bit. I'd be open
to perhaps refactoring the tests somehow to make them work on both, but
I literally have no easy way to run doc tests in a 32-bit environment.
Without being able to actually run them myself, I don't feel comfortable
doing anything other than squashing the tests in that case.

Closes #1041
BurntSushi added a commit that referenced this issue Oct 9, 2023
Some doc tests make 64-bit assumptions and fail on 32-bit. I'd be open
to perhaps refactoring the tests somehow to make them work on both, but
I literally have no easy way to run doc tests in a 32-bit environment.
Without being able to actually run them myself, I don't feel comfortable
doing anything other than squashing the tests in that case.

Closes #1041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants