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

"Object reference not set to an instance of an object" Error in FixedCache.TryLookup #129

Open
abstratovcm opened this issue Oct 4, 2024 · 0 comments · May be fixed by #130
Open

"Object reference not set to an instance of an object" Error in FixedCache.TryLookup #129

abstratovcm opened this issue Oct 4, 2024 · 0 comments · May be fixed by #130

Comments

@abstratovcm
Copy link

When using Mzinga.LinuxX64 on Ubuntu 22.04 with the engine option "Ponder During Idle" set to "Multi Threaded", an intermittent error occurs in the FixedCache.TryLookup method. The error message states, "Object reference not set to an instance of an object", suggesting that a null reference is being accessed. This happens sporadically, likely due to concurrent access by multiple threads.

Error message (using Debug mode):

err Object reference not set to an instance of an object.
   at Mzinga.Core.FixedCache2.TryLookup(TKey key, TEntry& entry) in /home/abstrato/work/git/Mzinga/src/Mzinga/Core/FixedCache.cs:line 119
   at Mzinga.Core.AI.GameAI.CalculateBoardScore(Board board) in /home/abstrato/work/git/Mzinga/src/Mzinga/Core/AI/GameAI.cs:line 686
   at Mzinga.Core.AI.GameAI.QuiescenceSearchAsync(Board board, Int32 depth, Double alpha, Double beta, Int32 color, CancellationToken token) in /home/abstrato/work/git/Mzinga/src/Mzinga/Core/AI/GameAI.cs:line 622

I used a lock (_storeLock) around the TryLookup method to ensure thread safety, similar to other methods in the same class. After applying this fix, the error stopped occurring during my testing, even after several games.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant