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

IndexOutOfRangeException when using IContextStore.Set #1908

Closed
arkadiuszwojcik opened this issue Jan 22, 2023 · 0 comments · Fixed by #1909
Closed

IndexOutOfRangeException when using IContextStore.Set #1908

arkadiuszwojcik opened this issue Jan 22, 2023 · 0 comments · Fixed by #1909

Comments

@arkadiuszwojcik
Copy link
Contributor

I get IndexOutOfRangeException while using IContextStore.Set. Looks like a bug in TypedDictionary

bacause:
private static int typeIndex = -1;

when we use Add:

public void Add<TKey>(TValue value)
    {
        lock (_lockObject)
        {
            var id = TypeKey<TKey>.Id;

            if (id >= _values.Length)
            {
                Array.Resize(ref _values, (int)(id * _growthFactor));
            }

            _values[id] = value;
        }
    }

With very first use id becomes 0 and 0 * _growthFactor = 0 so _values[id] = value; fails.

arkadiuszwojcik added a commit to arkadiuszwojcik/protoactor-dotnet that referenced this issue Jan 22, 2023
rogeralsing pushed a commit that referenced this issue Jan 23, 2023
* Fix array resize bug (#1908)

* add store test 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

Successfully merging a pull request may close this issue.

1 participant