执行使用LuaBridge映射的内部对象的脚本后,Lua命令行可执行文件崩溃。
static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
{
(void)ud; (void)osize; /* not used */
if (nsize == 0)
>{
free(ptr);
return NULL;
}
else
return realloc(ptr, nsize);
}
代码
Exception thrown at 0x50B8461D (ucrtbased.dll) in Compiler.exe: 0xC0000005: Access violation reading location 0x0FFB868C.
错误
<#
IEnumerable<PropertyMetadata> properties = ModelMetadata.Properties;
foreach (PropertyMetadata property in properties)
{
if(property.IsComplexType)
{
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.LoadFile("C:\\myFullAssemblyPath\\bin\\Release\\myAssembly.dll");
Type myType = myAssembly.GetType(property.TypeName);
if(myType == null)
{
#>
<th>TODO: Unable to render complex type (cannot load class from assembly). </th>
<#
}
else
{
foreach(var currentComplexProperty in myType.GetProperties())
{
string fullComplexName = property.PropertyName + "." + currentComplexProperty.Name;
#>
<th id="<#= fullComplexName #>">
<#= fullComplexName #>
</th>
<#
}
}
}
}
#>
如果存在此异常的处理程序,则可以安全地继续该程序。
有关如何处理此问题的任何提示。显然这可能是我们代码中的内存分配问题,但Lua应该正确处理吗?