NHibernate - ResetParametersIndexesForTheCommand堆腐败

时间:2017-05-02 18:45:51

标签: .net nhibernate iis-7.5 cil

有没有人知道可能导致这种情况的原因?

NHibernate中的这一行导致应用程序崩溃。

  

if(effectiveParameterLocations.Length> 0)//先前存在的参数

我唯一的猜测是,effectiveParameterLocations没有以某种方式具有Length属性。

该应用程序是一个Web应用程序,NHibernate成功连接到数据库,从一个表中获取一组对象,通过这个代码,同时设置查询它崩溃的下一组对象。

public void ResetParametersIndexesForTheCommand(int singleSqlParametersOffset)
    {
        // a better place could be the Bind of each IParameterSpecification but we have to do it before bind values
        // in this way the same parameter of a dynamic-filter will be set with two different parameter-names in the same command (when it is a command-set). 
        if (singleSqlParametersOffset < 0)
        {
            throw new AssertionFailure("singleSqlParametersOffset < 0 - this indicate a bug in NHibernate ");
        }
        // due to IType.NullSafeSet(System.Data.IDbCommand , object, int, ISessionImplementor) the SqlType[] is supposed to be in a certain sequence.
        // this mean that found the first location of a parameter for the IType span, the others are in secuence
        foreach (IParameterSpecification specification in Specifications)
        {
            string firstParameterId = specification.GetIdsForBackTrack(factory).First();
            int[] effectiveParameterLocations = SqlQueryParametersList.GetEffectiveParameterLocations(firstParameterId).ToArray();

         if (effectiveParameterLocations.Length > 0) // Parameters previously present might have been removed from the SQL at a later point.
            {
                int firstParamNameIndex = effectiveParameterLocations.First() + singleSqlParametersOffset;
                foreach (int location in effectiveParameterLocations)
                {
                    int parameterSpan = specification.ExpectedType.GetColumnSpan(factory);
                    for (int j = 0; j < parameterSpan; j++)
                    {
                        sqlQueryParametersList[location + j].ParameterPosition = firstParamNameIndex + j;
                    }
                }
            }
        }
    }

我认为这是因为DILE -

.method public hidebysig final virtual newslot instance void 
ResetParametersIndexesForTheCommand(int32 singleSqlParametersOffset) cil managed 
{
//Code size 229 (0xe5)
//Token: 0x0600440a
.maxstack 16
.locals init (class [mscorlib]System.Collections.Generic.IEnumerator`1<class NHibernate.Param.IParameterSpecification> V_0,
  class NHibernate.Param.IParameterSpecification V_1,
  string V_2,
  int32[] V_3,
  int32 V_4,
  int32[] V_5,
  int32 V_6,
  int32 V_7,
  int32 V_8,
  int32 V_9)
ldarg.1
ldc.i4.0
bge IL_0012
ldstr "singleSqlParametersOffset < 0 - this indicate a bug in NHibernate "
newobj instance void NHibernate.AssertionFailure::.ctor(string)
throw
ldarg.0
call instance class [mscorlib]System.Collections.Generic.IEnumerable`1<class NHibernate.Param.IParameterSpecification> NHibernate.SqlCommand.SqlCommandImpl::get_Specifications()
callvirt instance class [mscorlib]System.Collections.Generic.IEnumerator`1<!0> class [mscorlib]System.Collections.Generic.IEnumerable`1<class NHibernate.Param.IParameterSpecification>::GetEnumerator()
stloc.0
.try
{
    br IL_00c7
    ldloc.0
    callvirt instance !0 class [mscorlib]System.Collections.Generic.IEnumerator`1<class NHibernate.Param.IParameterSpecification>::get_Current()
    stloc.1
    ldloc.1
    ldarg.0
    ldfld class NHibernate.Engine.ISessionFactoryImplementor NHibernate.SqlCommand.SqlCommandImpl::factory
    callvirt instance class [mscorlib]System.Collections.Generic.IEnumerable`1<string> NHibernate.Param.IParameterSpecification::GetIdsForBackTrack(class NHibernate.Engine.IMapping)
    call !!0 [System.Core]System.Linq.Enumerable::First<string>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>)
    stloc.2
    ldarg.0
    call instance class [mscorlib]System.Collections.Generic.List`1<class NHibernate.SqlCommand.Parameter> NHibernate.SqlCommand.SqlCommandImpl::get_SqlQueryParametersList()
    ldloc.2
    call class [mscorlib]System.Collections.Generic.IEnumerable`1<int32> NHibernate.Param.ParametersBackTrackExtensions::GetEffectiveParameterLocations(class [mscorlib]System.Collections.Generic.IList`1<class NHibernate.SqlCommand.Parameter>, string)
    call !!0[] [System.Core]System.Linq.Enumerable::ToArray<int32>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>)
    stloc.3
    ldloc.3
    ldlen
    conv.i4
    ldc.i4.0
    ble IL_00c7
    ldloc.3                          KAABBOOOOOOOMMMM!!!!
    call !!0 [System.Core]System.Linq.Enumerable::First<int32>(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!0>)
    ldarg.1
    add
    stloc.s V_4
    ldloc.3                            
    stloc.s V_5
    ldc.i4.0
    stloc.s V_6
    br IL_00bf
    ldloc.s V_5
    ldloc.s V_6
    ldelem.i4
    stloc.s V_7
    ldloc.1
    callvirt instance class NHibernate.Type.IType NHibernate.Param.IParameterSpecification::get_ExpectedType()
    ldarg.0
    ldfld class NHibernate.Engine.ISessionFactoryImplementor NHibernate.SqlCommand.SqlCommandImpl::factory
    callvirt instance int32 NHibernate.Type.IType::GetColumnSpan(class NHibernate.Engine.IMapping)
    stloc.s V_8
    ldc.i4.0
    stloc.s V_9
    br IL_00b3
    ldarg.0
    ldfld class [mscorlib]System.Collections.Generic.List`1<class NHibernate.SqlCommand.Parameter> NHibernate.SqlCommand.SqlCommandImpl::sqlQueryParametersList
    ldloc.s V_7
    ldloc.s V_9
    add
    callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<class NHibernate.SqlCommand.Parameter>::get_Item(int32)
    ldloc.s V_4
    ldloc.s V_9
    add
    newobj instance void valuetype [mscorlib]System.Nullable`1<int32>::.ctor(!0)
    callvirt instance void NHibernate.SqlCommand.Parameter::set_ParameterPosition(valuetype [mscorlib]System.Nullable`1<int32>)
    ldloc.s V_9
    ldc.i4.1
    add
    stloc.s V_9
    ldloc.s V_9
    ldloc.s V_8
    blt.s IL_008e
    ldloc.s V_6
    ldc.i4.1
    add
    stloc.s V_6
    ldloc.s V_6
    ldloc.s V_5
    ldlen
    conv.i4
    blt.s IL_006c
   ldloc.0
    callvirt instance bool [mscorlib]System.Collections.IEnumerator::MoveNext()
    brtrue IL_0023
    leave IL_00e4
} //end try
finally
{
    ldloc.0
    brfalse IL_00e3
    ldloc.0
    callvirt instance void [mscorlib]System.IDisposable::Dispose()
    endfinally
} //end finally
ret
} //end of method NHibernate.SqlCommand.SqlCommandImpl::ResetParametersIndexesForTheCommand

单步执行KABOOM行只会以未处理的堆损坏错误退出该线程 -

Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8
Faulting module name: ntdll.dll, version: 6.1.7601.23677, time stamp: 0x589c957a
Exception code: 0xc0000374
Fault offset: 0x000ce8fb
Faulting process id: 0x1c50
Faulting application start time: 0x01d2c36a0e8b882e
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Windows\SysWOW64\ntdll.dll
Report Id: 50a95bb0-2f5e-11e7-9e4f-0050569641a1

有问题的表格中填充的对象看起来很正常,并且有六个列都是简单的东西,标准的poco。

生成的查询有1个参数。

爆炸前的查询 -

SELECT this_.Id as Id25_0_, this_.Source_Name as Source2_25_0_, this_.Description as Descript3_25_0_, this_.Enabled as Enabled25_0_, this_.Last_Updated_Time as Last5_25_0_, this_.Last_Updated_User as Last6_25_0_, this_.Class_Property_Name as Class7_25_0_ FROM Template_Fields_Profile this_ WHERE this_.Enabled = 1 and this_.Class_Property_Name is not null

感谢

0 个答案:

没有答案