René's URL Explorer Experiment


Title: Panic in hash wrapping when user hash returns oversized int · Issue #6550 · RustPython/RustPython · GitHub

Open Graph Title: Panic in hash wrapping when user hash returns oversized int · Issue #6550 · RustPython/RustPython

X Title: Panic in hash wrapping when user hash returns oversized int · Issue #6550 · RustPython/RustPython

Description: What happened? Calling hash() on an object whose __hash__ returns an oversized integer (e.g., 1 << 63) causes a panic in hash_wrapper. The wrapper attempts to convert the BigInt to i64, then falls back to % u64::MAX, but that remainder c...

Open Graph Description: What happened? Calling hash() on an object whose __hash__ returns an oversized integer (e.g., 1 << 63) causes a panic in hash_wrapper. The wrapper attempts to convert the BigInt to i64, then falls ...

X Description: What happened? Calling hash() on an object whose __hash__ returns an oversized integer (e.g., 1 << 63) causes a panic in hash_wrapper. The wrapper attempts to convert the BigInt to i64, then ...

Opengraph URL: https://github.com/RustPython/RustPython/issues/6550

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Panic in hash wrapping when user hash returns oversized int","articleBody":"### What happened?\n\nCalling `hash()` on an object whose `__hash__` returns an oversized integer (e.g., `1 \u003c\u003c 63`) causes a panic in hash_wrapper. The wrapper attempts to convert the BigInt to i64, then falls back to `% u64::MAX`, but that remainder can still be outside i64 and leads to `unwrap()` on None instead of raising a Python exception or normalizing safely.\n\n**Proof of Concept:**\n```python\nclass Evil:\n    def __hash__(self):\n        return 1 \u003c\u003c 63\n\nhash(Evil())\n```\n\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAffected Versions\u003c/strong\u003e\u003c/summary\u003e\n\n| RustPython Version | Status | Exit Code |\n|---|---|---|\n| `Python 3.13.0alpha (heads/main-dirty:21300f689, Dec 13 2025, 22:16:49) [RustPython 0.4.0 with rustc 1.90.0-nightly (11ad40bb8 2025-06-28)]` | Panic | 1 |\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eVulnerable Code\u003c/strong\u003e\u003c/summary\u003e\n\n```c\nfn hash_wrapper(zelf: \u0026PyObject, vm: \u0026VirtualMachine) -\u003e PyResult\u003cPyHash\u003e {\n    let hash_obj = vm.call_special_method(zelf, identifier!(vm, __hash__), ())?;\n    let py_int = hash_obj\n        .downcast_ref::\u003cPyInt\u003e()\n        .ok_or_else(|| vm.new_type_error(\"__hash__ method should return an integer\"))?;\n    let big_int = py_int.as_bigint();\n    let hash: PyHash = big_int\n        .to_i64()\n        .unwrap_or_else(|| (big_int % BigInt::from(u64::MAX)).to_i64().unwrap()); // Bug: u64::MAX should be i64::Max\n    Ok(hash)\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRust Output\u003c/strong\u003e\u003c/summary\u003e\n\n```\nthread 'main' panicked at crates/vm/src/types/slot.rs:369:72:\ncalled `Option::unwrap()` on a `None` value\nstack backtrace:\n   0: __rustc::rust_begin_unwind\n             at /rustc/11ad40bb839ca16f74784b4ab72596ad85587298/library/std/src/panicking.rs:697:5\n   1: core::panicking::panic_fmt\n             at /rustc/11ad40bb839ca16f74784b4ab72596ad85587298/library/core/src/panicking.rs:75:14\n   2: core::panicking::panic\n             at /rustc/11ad40bb839ca16f74784b4ab72596ad85587298/library/core/src/panicking.rs:145:5\n   3: core::option::unwrap_failed\n             at /rustc/11ad40bb839ca16f74784b4ab72596ad85587298/library/core/src/option.rs:2072:5\n   4: core::option::Option\u003cT\u003e::unwrap\n             at /home/jackfromeast/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1005:21\n   5: rustpython_vm::types::slot::hash_wrapper::{{closure}}\n             at ./crates/vm/src/types/slot.rs:369:72\n   6: core::option::Option\u003cT\u003e::unwrap_or_else\n             at /home/jackfromeast/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1050:21\n   7: rustpython_vm::types::slot::hash_wrapper\n             at ./crates/vm/src/types/slot.rs:369:10\n   8: rustpython_vm::protocol::object::\u003cimpl rustpython_vm::object::core::PyObject\u003e::hash\n             at ./crates/vm/src/protocol/object.rs:663:20\n   9: rustpython_vm::stdlib::builtins::builtins::hash\n             at ./crates/vm/src/stdlib/builtins.rs:440:13\n  10: core::ops::function::Fn::call\n             at /home/jackfromeast/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:79:5\n  11: rustpython_vm::function::builtin::\u003cimpl rustpython_vm::function::builtin::sealed::PyNativeFnInternal\u003c(rustpython_vm::function::builtin::OwnedParam\u003cT1\u003e,),R,rustpython_vm::vm::VirtualMachine\u003e for F\u003e::call_\n             at ./crates/vm/src/function/builtin.rs:126:17\n  12: \u003cF as rustpython_vm::function::builtin::IntoPyNativeFn\u003c(T,R,VM)\u003e\u003e::call\n             at ./crates/vm/src/function/builtin.rs:92:14\n  13: rustpython_vm::function::builtin::into_func::{{closure}}\n             at ./crates/vm/src/function/builtin.rs:50:40\n  14: \u003crustpython_vm::builtins::builtin_func::PyNativeFunction as rustpython_vm::types::slot::Callable\u003e::call\n             at ./crates/vm/src/builtins/builtin_func.rs:73:9\n  15: rustpython_vm::types::slot::Callable::slot_call\n             at ./crates/vm/src/types/slot.rs:1028:9\n  16: rustpython_vm::protocol::callable::PyCallable::invoke\n             at ./crates/vm/src/protocol/callable.rs:52:22\n  17: rustpython_vm::protocol::callable::\u003cimpl rustpython_vm::object::core::PyObject\u003e::call_with_args\n             at ./crates/vm/src/protocol/callable.rs:33:18\n  18: rustpython_vm::protocol::callable::\u003cimpl rustpython_vm::object::core::PyObject\u003e::call\n             at ./crates/vm/src/protocol/callable.rs:22:14\n  19: rustpython_vm::frame::ExecutingFrame::execute_call\n             at ./crates/vm/src/frame.rs:1880:30\n  20: rustpython_vm::frame::ExecutingFrame::execute_instruction\n             at ./crates/vm/src/frame.rs:667:22\n  21: rustpython_vm::frame::ExecutingFrame::run\n             at ./crates/vm/src/frame.rs:372:31\n  22: rustpython_vm::frame::\u003cimpl rustpython_vm::object::core::Py\u003crustpython_vm::frame::Frame\u003e\u003e::run::{{closure}}\n             at ./crates/vm/src/frame.rs:247:40\n  23: rustpython_vm::frame::\u003cimpl rustpython_vm::object::core::Py\u003crustpython_vm::frame::Frame\u003e\u003e::with_exec\n             at ./crates/vm/src/frame.rs:242:9\n  24: rustpython_vm::frame::\u003cimpl rustpython_vm::object::core::Py\u003crustpython_vm::frame::Frame\u003e\u003e::run\n             at ./crates/vm/src/frame.rs:247:14\n  25: rustpython_vm::vm::VirtualMachine::run_frame::{{closure}}\n             at ./crates/vm/src/vm/mod.rs:467:44\n  26: rustpython_vm::vm::VirtualMachine::with_frame::{{closure}}\n             at ./crates/vm/src/vm/mod.rs:495:26\n  27: rustpython_vm::vm::VirtualMachine::with_recursion\n             at ./crates/vm/src/vm/mod.rs:483:22\n  28: rustpython_vm::vm::VirtualMachine::with_frame\n             at ./crates/vm/src/vm/mod.rs:493:14\n  29: rustpython_vm::vm::VirtualMachine::run_frame\n             at ./crates/vm/src/vm/mod.rs:467:20\n  30: rustpython_vm::vm::VirtualMachine::run_code_obj\n             at ./crates/vm/src/vm/mod.rs:442:14\n  31: rustpython_vm::vm::compile::\u003cimpl rustpython_vm::vm::VirtualMachine\u003e::run_simple_file\n             at ./crates/vm/src/vm/compile.rs:93:26\n  32: rustpython_vm::vm::compile::\u003cimpl rustpython_vm::vm::VirtualMachine\u003e::run_any_file\n             at ./crates/vm/src/vm/compile.rs:57:14\n  33: rustpython_vm::vm::compile::\u003cimpl rustpython_vm::vm::VirtualMachine\u003e::run_script\n             at ./crates/vm/src/vm/compile.rs:50:14\n  34: rustpython::run_rustpython\n             at ./src/lib.rs:231:16\n  35: rustpython::run::{{closure}}\n             at ./src/lib.rs:112:41\n  36: rustpython_vm::vm::interpreter::Interpreter::run::{{closure}}\n             at ./crates/vm/src/vm/interpreter.rs:103:35\n  37: rustpython_vm::vm::interpreter::Interpreter::enter::{{closure}}\n             at ./crates/vm/src/vm/interpreter.rs:72:39\n  38: scoped_tls::ScopedKey\u003cT\u003e::set\n             at /home/jackfromeast/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/scoped-tls-1.0.1/src/lib.rs:137:9\n  39: rustpython_vm::vm::thread::enter_vm::{{closure}}\n             at ./crates/vm/src/vm/thread.rs:30:20\n  40: std::thread::local::LocalKey\u003cT\u003e::try_with\n             at /home/jackfromeast/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:315:12\n  41: std::thread::local::LocalKey\u003cT\u003e::with\n             at /home/jackfromeast/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:279:20\n  42: rustpython_vm::vm::thread::enter_vm\n             at ./crates/vm/src/vm/thread.rs:27:14\n  43: rustpython_vm::vm::interpreter::Interpreter::enter\n             at ./crates/vm/src/vm/interpreter.rs:72:9\n  44: rustpython_vm::vm::interpreter::Interpreter::run\n             at ./crates/vm/src/vm/interpreter.rs:103:24\n  45: rustpython::run\n             at ./src/lib.rs:112:27\n  46: rustpython::main\n             at ./src/main.rs:2:5\n  47: core::ops::function::FnOnce::call_once\n             at /home/jackfromeast/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5\nnote: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eCPython Output\u003c/strong\u003e\u003c/summary\u003e\n\n```\n(No output)\n```\n\u003c/details\u003e\n\n","author":{"url":"https://github.com/jackfromeast","@type":"Person","name":"jackfromeast"},"datePublished":"2025-12-27T04:53:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/6550/RustPython/issues/6550"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2f71b252-47a0-89db-2625-211efa13524a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE288:1B7E6F:17E4342:20EF6C9:696A9F7F
html-safe-nonceb8a7a74445356b3a9e43e67cab6f104c2915c7f34f0c43ce33869baf80f26cbd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjg4OjFCN0U2RjoxN0U0MzQyOjIwRUY2Qzk6Njk2QTlGN0YiLCJ2aXNpdG9yX2lkIjoiNTEyNzY1NjgyNjc2NDY5NzQ3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac39b2ffaaca0f7bd390c99ae867128db0fb7f4787100e40d3b52ffe8ba81e3a74
hovercard-subject-tagissue:3764355058
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/6550/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6a320d8b7fe49248b622e3bc5f50fb39bd2665e495e209344faa81d67b78e295/RustPython/RustPython/issues/6550
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6a320d8b7fe49248b622e3bc5f50fb39bd2665e495e209344faa81d67b78e295/RustPython/RustPython/issues/6550
og:image:altWhat happened? Calling hash() on an object whose __hash__ returns an oversized integer (e.g., 1 << 63) causes a panic in hash_wrapper. The wrapper attempts to convert the BigInt to i64, then falls ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejackfromeast
hostnamegithub.com
expected-hostnamegithub.com
Nonea51f97dbb9326f71c08ecb61577457d543c602124d1a2672871258ef37ac5261
turbo-cache-controlno-preview
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4bd0eac606c70914085176ef312ebdcd97a8cdf1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/issues/6550#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fissues%2F6550
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fissues%2F6550
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/issues/6550
Reloadhttps://github.com/RustPython/RustPython/issues/6550
Reloadhttps://github.com/RustPython/RustPython/issues/6550
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.4k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 21.7k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 278 https://github.com/RustPython/RustPython/issues
Pull requests 92 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects 0 https://github.com/RustPython/RustPython/projects
Wiki https://github.com/RustPython/RustPython/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/RustPython/RustPython/security
Please reload this pagehttps://github.com/RustPython/RustPython/issues/6550
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Wiki https://github.com/RustPython/RustPython/wiki
Security https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
New issuehttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/6550
New issuehttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/6550
Panic in hash wrapping when user hash returns oversized inthttps://github.com/RustPython/RustPython/issues/6550#top
https://github.com/youknowone
https://github.com/copilot-swe-agent
https://github.com/jackfromeast
https://github.com/jackfromeast
jackfromeasthttps://github.com/jackfromeast
on Dec 27, 2025https://github.com/RustPython/RustPython/issues/6550#issue-3764355058
Copilothttps://github.com/apps/copilot-swe-agent
youknowonehttps://github.com/youknowone
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.