-
Notifications
You must be signed in to change notification settings - Fork 519
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
ConcurrentDictionary.TryGetValue crashes with System.IndexOutOfRangeException: Arg_IndexOutOfRangeException #8866
Comments
@igor-sidorovich even though you cannot reproduce it, can you attach a snippet of code which shows more-or-less what you're doing when the crash happens? Also, please gather and post info about the crash environment(s) - Android version, locale, device(s). Lastly, could you attach full crash stack trace, with as much context as possible, that you get in the Google console? Thanks! |
@vitek-karas would you mind looking into this issue? |
@igor-sidorovich do you use custom If the problem is not with the equality comparer, the problem might be in |
, and looks like we are using default string comparer
Do we have option do not use FastMod?
|
@igor-sidorovich thanks for the additional information. I tried reproducing the exception today and I wasn't successful. I tried the running the following code on my Samsung S23, and there wasn't any exception thrown by private readonly ConcurrentDictionary<string, string> _dictionary = new();
private Thread[] _threads = new Thread[11];
private void OnCounterClicked(object sender, EventArgs e)
{
bool gotException = false;
for (int i = 1; i < _threads.Length; i++)
{
_threads[i] = new Thread(() =>
{
while (!gotException)
{
try
{
var key = GenerateRandomString(30, 80);
var value = "abc";
_dictionary.TryAdd(key, value);
_dictionary.TryGetValue(key, out _);
Interlocked.Increment(ref count);
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
gotException = true;
}
}
});
}
_threads[0] = new Thread(() =>
{
while (!gotException)
{
Device.BeginInvokeOnMainThread(() => CounterBtn.Text = $"i: {count}, dc: {_dictionary.Count}");
Thread.Sleep(100);
}
});
foreach (var thread in _threads)
{
thread.Start();
}
}
static string GenerateRandomString(int min, int max)
{
int length = Random.Shared.Next(min, max);
var sb = new System.Text.StringBuilder(length );
for (int i = 0; i < length; i++)
{
sb.Append((char)Random.Shared.Next('A', 'Z' + 1));
}
return sb.ToString();
} The OS eventually kills the app, but nothing suggests it is because of
It means that maybe this could some glitch in arm chips? But since it crashes on all those devices in the screenshot running different chips, it's probably not the problem. I think we need a repro if we want to fix this. |
I understand, but i also tried repro on different ARM phones and no any success. Do we have option do not use FastMod? |
I don't think so. But honestly, I think the chance that this is the problem is quite slim, since it happens on so many different devices and not just on some specific model. |
@igor-sidorovich have you had any success reproducing this issue? or do you have some data about the frequency of the crashes and the affected OS versions or phone models you could share with us? |
i do not have repo, i tried but didn't success. I will send affected OS versions and phone models later, thx. |
|
@igor-sidorovich thanks for the additional info. I was also interested in the frequency - are these rare cases or is this affecting a large number of customers? |
We opened it only on 0.5% percent of customers. It's - India, Colombia, Thailand, Pakistan. And off course it's rare cases. |
For 50000 users - we have only 10 crashes. |
@jpobst So far, this issue doesn't seem to be Android-specific. I think we should transfer it into dotnet/runtime. Is there some easy way to do it or is it easiest to close this one and open a new one? |
Unfortunately there isn't an easy way to transfer issues to a different organization. We will probably need to open a new one in |
Should i open new one? |
If you don't mind, please do. Having the issue in Please include a link to this issue in the description so they can reference the context here. Thanks! |
@simonrozsival, @jpobst Done - dotnet/runtime#102545. |
Thanks! Tracking this here: dotnet/runtime#102545. |
Android application type
.NET Android (net7.0-android, net8.0-android, etc.)
Affected platform version
.NET 8.0.200, workload 34.0.52/8.0.100
Description
Since updating from Xamarin to .NET 8 we are getting next crashes in ConcurrentDictionary.
For me it looks like strange to have such crashes for ConcurrentDictionary.
Steps to Reproduce
Unfortuantle, i do not have repro(I tried but didn't succeed), but on Production we see such crashes.
Did you find any workaround?
No
Relevant log output
The text was updated successfully, but these errors were encountered: