FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: OrderedDict.get() crashes on wasi · RustPython/RustPython@03d090e · GitHub

Repository navigation

Commit 03d090e

Browse files
committed
fix: OrderedDict.get() crashes on wasi
- Problem: On wasi, OrderedDict.get() crashes with an out of bounds memory access - Cause: OrderedDict uses by_hash: HashMap which requires 8 byte align - Fix: Wrap by_hash in Box<HashMap<...>> to bring align back down to 4 bytes Assisted-by: Claude Code:claude-sonnet-5 Signed-off-by: Jiwoo Ahn <ikwydls1314@gmail.com>
1 parent 04eb0ad commit 03d090e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎crates/vm/src/stdlib/_collections/ordered_dict.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(crate) mod ordered_dict {
4848
last: Option<usize>,
4949
nodes: Vec<Option<ODictNode>>,
5050
free: Vec<usize>,
51-
by_hash: HashMap<PyHash, Vec<usize>>,
51+
by_hash: Box<HashMap<PyHash, Vec<usize>>>,
5252
state: usize,
5353
}
5454

@@ -573,6 +573,7 @@ pub(crate) mod ordered_dict {
573573
fn __sizeof__(&self) -> usize {
574574
self.dict.__sizeof__()
575575
+ core::mem::size_of::<ODictLinks>()
576+
+ core::mem::size_of::<HashMap<PyHash, Vec<usize>>>()
576577
+ self.links.lock().nodes.capacity() * core::mem::size_of::<Option<ODictNode>>()
577578
}
578579

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL