Repository navigation
Conversation
…aded Staging::refresh_now only used t.take() results, which returns changed tracked pages. Pages in t.untracked() (memory outside the runtime) were never returned, so subresources lying wholly in untracked pages were never read or uploaded - their host texture stayed zero forever. Now untracked ranges are fetched via t.untracked() and kept separate from tracked changed ranges: - tracked pages go through the existing hash-based skip path (re-upload only when bytes change) - untracked pages are copied whole at each use (same as buffer copies, see Tracked::untracked) so subresources touching them are always re-read and re-uploaded Added regression test verifying: - untracked pages are reported separately from tracked pages - take() does not return untracked pages - tracker with untracked parts is never clean
Fix three test failures that fail on unmodified code due to host GPU capabilities (NVIDIA descriptor heap caps at 1M, below HEAP_VIEWS): - descriptor/host.rs: dynamic_slots test compares against actual heap capacity (count) instead of HEAP_VIEWS (2M), which NVIDIA cannot allocate. - memory.rs: lists_share test compares pair slots against actual heap capacity instead of 1<<18 (DYNAMIC), which NVIDIA cannot allocate.
…, RS) The PE section's virtual size (VS) determines how many bytes Windows maps into memory, while raw data size (RS) determines how many bytes come from the file. When VS > RS, pages within VS but beyond RS are mapped as zero-filled memory by Windows. The previous code used min(VS, RS) as the backed size, which incorrectly treated pages within VS but beyond RS as unmapped, causing lookups like rva_to_file_offset to return None for valid mapped memory (zero-filled). Change backed to just VS, and return None (no file data) for pages within VS but beyond RS - callers treat None as zero-filled mapped memory.
copy_back_marks called copy.upgrade() while holding the guards lock. If another thread dropped its reference between upgrade() returning Some(Arc) and the closure returning None (because k >= pages(...)), the Arc<Shadow> would be dropped inside the lock, and Shadow::drop takes the same lock -> deadlock. Fix: collect upgraded Arc<Shadow> copies under the lock, then process them outside the lock, so any drops happen without the lock held.
AurumCarlos
left a comment
There was a problem hiding this comment.
Thanks for picking up #2412. The diff carries a lot more than the description says, though: five files, of which only the parse_exports hunk is about export addresses. I'd suggest splitting it, because some of the other changes would be hard to accept as part of this PR.
1. The parse_exports change is fine, but defensive only. object builds ReadTarget::Address as image_base + rva with a 32-bit RVA, so address - image_base is always in 0..=u32::MAX and wrapping_sub was already exact. checked_sub + try_from is a reasonable guard against a future change there. It just can't be reached today, which the description should say rather than describing a live overflow.
2. The new test doesn't test a rejection. rejects_export_address_below_image_base unwraps ImageInfo::parse and expects an alpha export. That only passes because nothing is rejected: the 0x1200 in the address table is an RVA that object adds image_base to, so the address is image_base + 0x1200, not "< image_base" as the comment says. (parse_exports errors propagate through parse with ?, so a real rejection would make the unwrap panic.) As written, it's a test of the valid path under a misleading name.
3. rva_to_file_offset changes behaviour, and it isn't mentioned. On main, backed = vs.min(file_size): raw padding past the virtual size is not part of the section in memory (the comment you removed said so). Now any delta < file_size returns a file offset, so an RVA past a section's virtual end, but inside its raw padding, maps into that padding. With find_map over sections, that can return the wrong bytes for an RVA that belongs to the next section. The new tail, (delta < backed).then_some(None)?, evaluates to None on both branches, so the "mapped as zeros" case is the same as not matching. I'd drop this hunk from the PR.
4. Two GPU tests are weakened.
descriptor/host.rs:NumDescriptors >= HEAP_VIEWS(2²¹) becomes>= 4.memory.rs:pairs >= 1 << 18("past the dynamic slots") becomespairs < caps, which checks something different while keeping the old message.
If these fail on your machine because of a capped descriptor heap, that's a real host limitation, and other PRs are handling it on its own (e.g. #3191). Loosening the assertions here would hide regressions on normal hosts.
5. Two GPU fixes deserve their own PRs.
shadow.rs/copy_back_marks: the deadlock you describe looks real. Inpage_of, whenk >= pages(..), the upgradedArc<Shadow>is dropped inside the closure whilemarks()is held, andShadow::droptakesmarks()again. Collecting the strong refs under the lock and filtering after is the right shape. It's worth a separate PR with its own description and, ideally, a test.texture.rs: re-uploading subresources in untracked pages is a behaviour change to texture refresh, also unrelated to exports. Its test also says "Reserve a 4 KiB window" whileWINDOWis2 * PAGE= 128 KiB, and it never exercises a refresh, onlyuntracked()/take()/clean().
So my suggestion: keep this PR to the parse_exports hunk (with a test that really feeds an out-of-range address, or a note that it's defensive), and send the shadow.rs and texture.rs changes separately. Drop the rva_to_file_offset and test-assertion changes.
|
Closing to split into separate PRs - this PR had unrelated changes mixed in. Will create a clean PR with just the #2412 fix. |
Fix #2412: Export address validation now uses checked_sub() instead of wrapping_sub(), preventing integer overflow when an export address is below image_base or exceeds u32::MAX.
The previous code used wrapping_sub() which silently wraps/truncates out-of-range addresses into bogus 32-bit RVAs instead of returning an error.
Changes:
Added test rejects_export_address_below_image_base verifying that an export address below image_base is rejected.