Skip to content

fix: Dereferencing freed memos when verifying provisional memos#788

Merged
MichaReiser merged 2 commits intosalsa-rs:masterfrom
MichaReiser:fix-dereference-freed-memos
Apr 9, 2025
Merged

fix: Dereferencing freed memos when verifying provisional memos#788
MichaReiser merged 2 commits intosalsa-rs:masterfrom
MichaReiser:fix-dereference-freed-memos

Conversation

@MichaReiser
Copy link
Copy Markdown
Contributor

@MichaReiser MichaReiser commented Apr 9, 2025

Fixes #785

The root cause of #785 is that Salsa tries to load the memo of a cycle head that is stored on a tracked struct that has been freed.

The main problem is that we tried to verify validate_provisional even in cases where the query is from a past revision, in which case we can't trust any inputs to still exist (and be valid).

The fix in this PR is to change the order in which shallow_verify and validate_provisional are called. This requires extracting the mutating bits out of shallow_verify because we only want to call those if the struct isn't provisional (at least, that's what we did before and I tried to preserve this behavior).

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 9, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit d33d824
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/67f6a077a9449d0008cbac8f

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 9, 2025

CodSpeed Performance Report

Merging #788 will not alter performance

Comparing MichaReiser:fix-dereference-freed-memos (d33d824) with master (c999c71)

Summary

✅ 12 untouched benchmarks

@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch 5 times, most recently from 5536c7c to 8b820db Compare April 9, 2025 15:57
Comment thread src/function/maybe_changed_after.rs Outdated
@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch 2 times, most recently from 560b74f to 149f615 Compare April 9, 2025 16:04
Copy link
Copy Markdown
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

Comment thread src/function/maybe_changed_after.rs Outdated
Comment thread src/function/maybe_changed_after.rs
@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch from 149f615 to 7e8c8e0 Compare April 9, 2025 16:26
@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch from 7e8c8e0 to d33d824 Compare April 9, 2025 16:29
@MichaReiser MichaReiser marked this pull request as ready for review April 9, 2025 16:31
@MichaReiser MichaReiser enabled auto-merge April 9, 2025 16:34
@MichaReiser MichaReiser added the bug Something isn't working label Apr 9, 2025
@MichaReiser MichaReiser added this pull request to the merge queue Apr 9, 2025
Merged via the queue into salsa-rs:master with commit 69272a8 Apr 9, 2025
11 checks passed
@MichaReiser MichaReiser deleted the fix-dereference-freed-memos branch April 9, 2025 16:50
@github-actions github-actions Bot mentioned this pull request Apr 9, 2025
carljm pushed a commit to astral-sh/ruff that referenced this pull request Apr 9, 2025
## Summary

Update Salsa to pull in salsa-rs/salsa#788 which
fixes the, by now, famous *access to field whilst the value is being
initialized*.

This PR also re-enables all tests that previously triggered the panic.

## Test Plan

`cargo test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tracked-structs: access to field whilst the value is being initialized

2 participants