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

tests/test_hash_trie_map.py::test_hashing - pyo3_runtime.PanicException: attempt to multiply with overflow and more #86

Closed
mgorny opened this issue Aug 7, 2024 · 5 comments

Comments

@mgorny
Copy link

mgorny commented Aug 7, 2024

The test suite of 0.20.0 release fails with PyO3 panics when built with --profile=dev.

To reproduce:

pip install -e . -Cbuild-args=--profile=dev
pip install pytest
pytest

Output:

========================================================= test session starts =========================================================
platform linux -- Python 3.12.4, pytest-8.3.2, pluggy-1.5.0
rootdir: /tmp/rpds
configfile: pyproject.toml
collected 116 items                                                                                                                   

tests/test_hash_trie_map.py ............F.F............................................                                         [ 50%]
tests/test_hash_trie_set.py ..F..................                                                                               [ 68%]
tests/test_list.py ...................                                                                                          [ 85%]
tests/test_queue.py .................                                                                                           [100%]

============================================================== FAILURES ===============================================================
____________________________________________________________ test_hashing _____________________________________________________________

    def test_hashing():
        o = object()
    
>       assert hash(HashTrieMap([(o, o), (1, o)])) == hash(
            HashTrieMap([(o, o), (1, o)]),
        )
E       pyo3_runtime.PanicException: attempt to multiply with overflow

tests/test_hash_trie_map.py:157: PanicException
-------------------------------------------------------- Captured stderr call ---------------------------------------------------------
thread '<unnamed>' panicked at src/lib.rs:13:5:
attempt to multiply with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
_______________________________________ test_map_does_not_hash_values_on_second_hash_invocation _______________________________________

    def test_map_does_not_hash_values_on_second_hash_invocation():
        hashable = HashabilityControlled()
        x = HashTrieMap(dict(el=hashable))
>       hash(x)
E       pyo3_runtime.PanicException: attempt to multiply with overflow

tests/test_hash_trie_map.py:196: PanicException
-------------------------------------------------------- Captured stderr call ---------------------------------------------------------
thread '<unnamed>' panicked at src/lib.rs:13:5:
attempt to multiply with overflow
____________________________________________________________ test_hashing _____________________________________________________________

    def test_hashing():
        o = object()
    
>       assert hash(HashTrieSet([o])) == hash(HashTrieSet([o]))
E       pyo3_runtime.PanicException: attempt to multiply with overflow

tests/test_hash_trie_set.py:51: PanicException
-------------------------------------------------------- Captured stderr call ---------------------------------------------------------
thread '<unnamed>' panicked at src/lib.rs:13:5:
attempt to multiply with overflow
======================================================= short test summary info =======================================================
FAILED tests/test_hash_trie_map.py::test_hashing - pyo3_runtime.PanicException: attempt to multiply with overflow
FAILED tests/test_hash_trie_map.py::test_map_does_not_hash_values_on_second_hash_invocation - pyo3_runtime.PanicException: attempt to multiply with overflow
FAILED tests/test_hash_trie_set.py::test_hashing - pyo3_runtime.PanicException: attempt to multiply with overflow
==================================================== 3 failed, 113 passed in 0.32s ====================================================
@FlickerSoul
Copy link
Contributor

Thanks for catching that! I was not aware of overflowing in Rust when implementing it. I'll submit a PR to fix it soon!

@mgorny
Copy link
Author

mgorny commented Aug 8, 2024

Thanks! Feel free to CC me and I'll test it.

@mgorny
Copy link
Author

mgorny commented Aug 8, 2024

By the way, it's probably useful to consider running CI using dev profile, as that catches more potential issues.

Julian added a commit to FlickerSoul/rpds that referenced this issue Oct 31, 2024
Julian added a commit that referenced this issue Oct 31, 2024
Fix hashing overflow issues (#86)
@Julian
Copy link
Member

Julian commented Oct 31, 2024

Fixed in #87.

@Julian Julian closed this as completed Oct 31, 2024
@mgorny
Copy link
Author

mgorny commented Oct 31, 2024

Thanks!

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

No branches or pull requests

3 participants