Непонятная ошибка
От: Barbar1an Украина  
Дата: 09.08.17 22:58
Оценка:
на сервере что происходит начинает выдавать постоянно такую ошибку

Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Collections.Generic.List`1.Add(T item) +37
Site.Core.OnSessionStart(HttpSessionState s, HttpRequest r) +67
Site.Application.Session_Start() +53

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +87
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +21
System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +56
System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e) +9976119
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +160
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1095
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +254
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


код тривиальный

    

    public class Core
    {
        List<SessionEnvironment>            _Environments;
    
        private Core(HttpApplication a, RouteCollection routes)
        {
            _Environments            = new List<SessionEnvironment>();
        }

        public void OnSessionStart(HttpSessionState s, HttpRequest r)
        {

            SessionEnvironment env = new SessionEnvironment(_Site, _GeoIPService, s, r);
            s["environment"] = env;
            _Environments.Add(env);
        }


какой нафиг индекс?
Я изъездил эту страну вдоль и поперек, общался с умнейшими людьми и я могу вам ручаться в том, что обработка данных является лишь причудой, мода на которую продержится не более года. (с) Эксперт, авторитет и профессионал из 1957 г.
Отредактировано 09.08.2017 22:59 Barbar1an . Предыдущая версия .
Re: Непонятная ошибка
От: rameel https://github.com/rsdn/CodeJam
Дата: 09.08.17 23:56
Оценка: +1
Здравствуйте, Barbar1an, Вы писали:

B>Index was outside the bounds of the array.

B>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

B>какой нафиг индекс?


Про многопоточность забыл, List<T> не thread-safe
... << RSDN@Home 1.0.0 alpha 5 rev. 0>>
Re[2]: Непонятная ошибка
От: Barbar1an Украина  
Дата: 10.08.17 07:40
Оценка:
Здравствуйте, rameel, Вы писали:

R>Здравствуйте, Barbar1an, Вы писали:


B>>Index was outside the bounds of the array.

B>>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

B>>какой нафиг индекс?


R>Про многопоточность забыл, List<T> не thread-safe


так этому коду 10 лет а проблеме 1 месяц, и когда она проявляется то проявляется стабильно что не похоже на ошибку синхронизации
Я изъездил эту страну вдоль и поперек, общался с умнейшими людьми и я могу вам ручаться в том, что обработка данных является лишь причудой, мода на которую продержится не более года. (с) Эксперт, авторитет и профессионал из 1957 г.
Отредактировано 10.08.2017 7:45 Barbar1an . Предыдущая версия .
Re[3]: Непонятная ошибка
От: rameel https://github.com/rsdn/CodeJam
Дата: 10.08.17 11:43
Оценка: +1
Здравствуйте, Barbar1an, Вы писали:

B>так этому коду 10 лет а проблеме 1 месяц, и когда она проявляется то проявляется стабильно что не похоже на ошибку синхронизации


Ну значит вам везло или нагрузка не такая уж и конкурентная была
... << RSDN@Home 1.0.0 alpha 5 rev. 0>>
Re[4]: Непонятная ошибка
От: rameel https://github.com/rsdn/CodeJam
Дата: 10.08.17 12:00
Оценка: 6 (1)
Здравствуйте, rameel, Вы писали:

Вот пруф:
using System;
using System.Collections.Generic;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            var list = new List<object>();

            for (var i = 0; i < 40; i++)
            {
                var thread = new Thread(() =>
                {
                    for (var j = 0; j < 10000; j++)
                    {
                        try
                        {
                            list.Add(null);

                        }
                        catch (Exception e)
                        {
                            Console.WriteLine($"{e}\r\n");
                            break;
                        }
                    }
                });

                thread.Start();
            }

            Console.ReadLine();
        }
    }
}
... << RSDN@Home 1.0.0 alpha 5 rev. 0>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.