Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger: Lock memory during stack walk #16988

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
samplerjit: Prevent thread local stale cache read.
If the generation count happens to match, would still get a stale pointer
and crash.  Let's just make the generation count static so it always
increases.
  • Loading branch information
unknownbrackets committed Feb 23, 2023
commit cd3fc26190c4ef0897884449094a724022b4d2ae
2 changes: 2 additions & 0 deletions GPU/Software/DrawPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,12 @@ SingleFunc PixelJitCache::GenericSingle(const PixelFuncID &id) {
}

thread_local PixelJitCache::LastCache PixelJitCache::lastSingle_;
int PixelJitCache::clearGen_ = 0;

// 256k should be plenty of space for plenty of variations.
PixelJitCache::PixelJitCache() : CodeBlock(1024 * 64 * 4), cache_(64) {
lastSingle_.gen = -1;
clearGen_++;
}

void PixelJitCache::Clear() {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Software/DrawPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class PixelJitCache : public Rasterizer::CodeBlock {
DenseHashMap<size_t, SingleFunc, nullptr> cache_;
std::unordered_map<PixelFuncID, const u8 *> addresses_;
std::unordered_set<PixelFuncID> compileQueue_;
int clearGen_ = 0;
static int clearGen_;
static thread_local LastCache lastSingle_;

const u8 *constBlendHalf_11_4s_ = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions GPU/Software/Sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ FetchFunc GetFetchFunc(SamplerID id, BinManager *binner) {
thread_local SamplerJitCache::LastCache SamplerJitCache::lastFetch_;
thread_local SamplerJitCache::LastCache SamplerJitCache::lastNearest_;
thread_local SamplerJitCache::LastCache SamplerJitCache::lastLinear_;
int SamplerJitCache::clearGen_ = 0;

// 256k should be enough.
SamplerJitCache::SamplerJitCache() : Rasterizer::CodeBlock(1024 * 64 * 4), cache_(64) {
lastFetch_.gen = -1;
lastNearest_.gen = -1;
lastLinear_.gen = -1;
clearGen_++;
}

void SamplerJitCache::Clear() {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Software/Sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class SamplerJitCache : public Rasterizer::CodeBlock {
DenseHashMap<size_t, NearestFunc, nullptr> cache_;
std::unordered_map<SamplerID, const u8 *> addresses_;
std::unordered_set<SamplerID> compileQueue_;
int clearGen_ = 0;
static int clearGen_;
static thread_local LastCache lastFetch_;
static thread_local LastCache lastNearest_;
static thread_local LastCache lastLinear_;
Expand Down