gh-108253: Fix bug in func version cache by gvanrossum · Pull Request #108296 · python/cpython · GitHub
Skip to content

gh-108253: Fix bug in func version cache - #108296

Merged
gvanrossum merged 1 commit into
python:mainfrom
gvanrossum:fix-func-cache
Aug 22, 2023
Merged

gvanrossum merged 1 commit into
python:mainfrom
gvanrossum:fix-func-cache

Conversation

@gvanrossum

Copy link
Copy Markdown
Member

When a function object changed its version, a stale pointer might remain in the cache.

Now, test_opcache just fails when run with -Xuops instead of accessing freed memory. This fixes gh-108253.

When a function object changed its version, a stale pointer
might remain in the cache.
@alex

alex commented Aug 23, 2023

Copy link
Copy Markdown
Member

@gvanrossum

Copy link
Copy Markdown
Member Author

This PR introduces a use of uninitialized memory.

Interesting, since it also definitely fixed a case of free-after-use. I will try to understand the report.

@gvanrossum

Copy link
Copy Markdown
Member Author

Ah, I was over-zealous. That is the one place where ...->func_version = 0 is correct instead of going through the call. :-( PR coming up.

@alex

alex commented Aug 23, 2023

Copy link
Copy Markdown
Member

Thanks!

@gvanrossum

Copy link
Copy Markdown
Member Author

This is a great service! Surprised though that address-sanitizer didn't catch this.

@alex

alex commented Aug 23, 2023

Copy link
Copy Markdown
Member

ASAN doesn't catch unitialized memory, only MSAN does. (And MSAN is kind of a pain in the neck to setup.)

@llooFlashooll

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

heap-use-after-free in _PyFunction_LookupByVersion

4 participants