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

Index was outside the bounds of the array. at NCalc.Expression.Evaluate() #39

Open
enshivam opened this issue Feb 7, 2020 · 5 comments

Comments

@enshivam
Copy link

enshivam commented Feb 7, 2020

In any random and rare scenario, Getting Index was outside the bounds of the array. at NCalc.Expression.Evaluate() while only evaluating very simple expression, or boolean conversions. Using .net core 3.0.

Issue doesn't seem to appear while using EvaluationOptions.NoCache.

Any pointers on if I may be doing something wrong? Any way to identify the detailed trace atleast?

@GDeGruyter
Copy link

Same issue here. We ran on .net core 2.2 and saw no issues. Since we upgraded to .net core 3.0 we are experiencing the issues as described. I also saw 'Object reference not set to an instance object' on Expression.CleanCache(), which confirms the issue could be related to the cache. I will test with 'EvalualationOptions.NoCache' as suggested by @enshivam. I can also confirm the issue is random so hard to ack the relationship with the cache.

@Bykiev
Copy link
Contributor

Bykiev commented Mar 19, 2024

I've tried to reproduce the issue with no luck

@eugenca
Copy link
Contributor

eugenca commented Mar 21, 2024

@Bykiev I got some occasional test run error on that test recently when running it first time, then it disappeared

@Bykiev
Copy link
Contributor

Bykiev commented Mar 22, 2024

@Bykiev I got some occasional test run error on that test recently when running it first time, then it disappeared

What is a target framework? I've tried to reproduce the issue with no luck. The cache will be slightly changed if #98 will be merged.

@Bykiev
Copy link
Contributor

Bykiev commented Mar 22, 2024

From the docs:

For modifications and write operations to the dictionary, ConcurrentDictionary<TKey,TValue> uses fine-grained locking to ensure thread safety (read operations on the dictionary are performed in a lock-free manner). The addValueFactory and updateValueFactory delegates may be executed multiple times to verify the value was added or updated as expected. However, they are called outside the locks to avoid the problems that can arise from executing unknown code under a lock. Therefore, AddOrUpdate is not atomic with regards to all other operations on the ConcurrentDictionary<TKey,TValue> class.

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

No branches or pull requests

4 participants