Don't really know what is going on here. Maybe you could provide some insight?
Stack trace:
> IrCore.dll!asCScriptFunction::AddReferences() Line 661 + 0x26 bytes C++
IrCore.dll!asCCompiler::FinalizeFunction() Line 255 C++
IrCore.dll!asCCompiler::CompileFunction(asCBuilder * builder=0x08e23c68, asCScriptCode * script=0x08e33b90, sExplicitSignature * signature=0x00000000, asCScriptNode * func=0x08e8bcc8, asCScriptFunction * outFunc=0x0adb7040) Line 577 C++
IrCore.dll!asCBuilder::CompileFunctions() Line 637 C++
IrCore.dll!asCBuilder::Build() Line 201 C++
IrCore.dll!asCModule::Build() Line 205 + 0xb bytes C++
IrCore.dll!CScriptBuilder::Build() Line 446 + 0x17 bytes C++
IrCore.dll!CScriptBuilder::BuildModule() Line 80 C++
IrCore.dll!Irre::Stage::LoadScriptModule(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & module_name="Stage", const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & file="Stages/Menu/main.ang") Line 262 + 0xe bytes C++
IrCore.dll!Irre::Stage::LoadStage(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & name="Menu") Line 629 + 0xa1 bytes C++
IrCore.dll!Irre::System::InitializeSubsystems() Line 218 + 0x34 bytes C++
Autos as reported by visual studio:
- &byteCode 0x0adb70e0 {array=0x0ae18e20 length=0x00000066 maxLength=0x00000066 ...} asCArray<unsigned long> *
+ array 0x0ae18e20 unsigned long *
length 0x00000066 unsigned int
maxLength 0x00000066 unsigned int
+ buf 0x0adb70ec "ÍÍÍÍÍÍÍÍp†á
?" char [8]
asBC_CALL 0x00000009 int
asBC_CALLINTF 0x0000008b int
- engine 0x08da8338 {isPrepared=true memoryMgr={...} initialContextStackSize=0x00000400 ...} asCScriptEngine *
+ asIScriptEngine {...} asIScriptEngine
isPrepared true bool
+ memoryMgr {cs={...} scriptNodePool={...} byteInstructionPool={...} } asCMemoryMgr
initialContextStackSize 0x00000400 int
+ defaultArrayObjectType 0x08dc0600 {name={...} nameSpace={...} size=0x00000000 ...} asCObjectType *
+ scriptTypeBehaviours {name={...} nameSpace={...} size=0xcdcdcdcd ...} asCObjectType
+ functionBehaviours {name={...} nameSpace={...} size=0xcdcdcdcd ...} asCObjectType
+ objectTypeBehaviours {name={...} nameSpace={...} size=0xcdcdcdcd ...} asCObjectType
+ globalPropertyBehaviours {name={...} nameSpace={...} size=0xcdcdcdcd ...} asCObjectType
+ registeredObjTypes {array=0x08df2ec0 length=0x0000001e maxLength=0x00000020 ...} asCArray<asCObjectType *>
+ registeredTypeDefs {array=0x00000000 length=0x00000000 maxLength=0x00000000 ...} asCArray<asCObjectType *>
+ registeredEnums {array=0x08defcc8 length=0x00000005 maxLength=0x00000008 ...} asCArray<asCObjectType *>
+ registeredGlobalProps {array=0x08e18290 length=0x00000004 maxLength=0x00000004 ...} asCArray<asCGlobalProperty *>
+ registeredGlobalFuncs {array=0x08e08b68 length=0x00000077 maxLength=0x00000080 ...} asCArray<asCScriptFunction *>
+ registeredFuncDefs {array=0x00000000 length=0x00000000 maxLength=0x00000000 ...} asCArray<asCScriptFunction *>
+ stringFactory 0x08dc6908 {refCount={...} gcFlag=false engine=0x08da8338 ...} asCScriptFunction *
configFailed false bool
+ objectTypes {array=0x08e0f200 length=0x00000023 maxLength=0x00000040 ...} asCArray<asCObjectType *>
+ templateSubTypes {array=0x08da88f8 length=0x00000001 maxLength=0x00000001 ...} asCArray<asCObjectType *>
+ templateTypes {array=0x0add2ea8 length=0x00000008 maxLength=0x00000008 ...} asCArray<asCObjectType *>
+ globalProperties {array=0x08e97b60 length=0x0000000c maxLength=0x00000010 ...} asCArray<asCGlobalProperty *>
+ freeGlobalPropertyIds {array=0x00000000 length=0x00000000 maxLength=0x00000000 ...} asCArray<int>
+ scriptFunctions {array=0x0add3aa0 length=0x00000488 maxLength=0x00000800 ...} asCArray<asCScriptFunction *>
+ freeScriptFunctionIds {array=0x00000000 length=0x00000000 maxLength=0x00000000 ...} asCArray<int>
+ signatureIds {array=0x0adaa2f8 length=0x000000a9 maxLength=0x00000100 ...} asCArray<asCScriptFunction *>
+ importedFunctions {array=0x00000000 length=0x00000000 maxLength=0x00000000 ...} asCArray<sBindInfo *>
+ freeImportedFunctionIdxs {array=0x00000000 length=0x00000000 maxLength=0x00000000 ...} asCArray<int>
+ refCount {value=0x00000004 } asCAtomic
+ scriptModules {array=0x08da89b0 length=0x00000001 maxLength=0x00000001 ...} asCArray<asCModule *>
+ lastModule 0x08e6b028 {name={...} engine=0x08da8338 builder=0x08e23c68 ...} asCModule *
isBuilding true bool
deferValidationOfTemplateTypes false bool
+ tok {engine=0x08da8338 alphaKeywordMap={...} nonAlphaKeywordMap={...} } asCTokenizer
+ classTypes {array=0x08e95800 length=0x00000019 maxLength=0x00000020 ...} asCArray<asCObjectType *>
+ templateInstanceTypes {array=0x0add2f08 length=0x00000008 maxLength=0x00000008 ...} asCArray<asCObjectType *>
+ funcDefs {array=0x08e960b8 length=0x00000003 maxLength=0x00000004 ...} asCArray<asCScriptFunction *>
+ scriptSectionNames {array=0x08e27588 length=0x00000016 maxLength=0x00000020 ...} asCArray<asCString *>
typeIdSeqNbr 0x00000038 int
+ mapTypeIdToDataType {root=0x08dd4410 dummy={...} count=0x00000038 } asCMap<int,asCDataType *>
+ gc {engine=0x08da8338 gcNewObjects={...} gcOldObjects={...} ...} asCGarbageCollector
+ defaultGroup {groupName={...} refCount=0x00000000 objTypes={...} ...} asCConfigGroup
+ configGroups {array=0x08da8bc8 length=0x00000001 maxLength=0x00000001 ...} asCArray<asCConfigGroup *>
+ currentGroup 0x08da8b44 {groupName={...} refCount=0x00000000 objTypes={...} ...} asCConfigGroup *
defaultAccessMask 0x00000001 unsigned long
+ defaultNamespace {length=0x00000000 dynamic=0xcdcdcd00 <Bad Ptr> local=0x08da8bdc "" } asCString
msgCallback true bool
+ msgCallbackFunc {func=0x101f0ac9 baseOffset=0x00000000 callConv=ICC_CDECL ...} asSSystemFunctionInterface
msgCallbackObj 0x00000000 void *
+ jitCompiler 0x00000000 asIJITCompiler *
+ stringConstants {array=0x0ae06b50 length=0x00000012 maxLength=0x00000020 ...} asCArray<asCString *>
+ stringToIdMap {root=0x0adf3000 dummy={...} count=0x00000012 } asCMap<asCStringPointer,int>
userData 0x08da8030 void *
cleanEngineFunc 0x00000000 void (asIScriptEngine *)*
cleanModuleFunc 0x00000000 void (asIScriptModule *)*
cleanContextFunc 0x00000000 void (asIScriptContext *)*
cleanFunctionFunc 0x00000000 void (asIScriptFunction *)*
cleanObjectTypeFunc 0x00000000 void (asIObjectType *)*
+ engineCritical {criticalSection={...} } asCThreadCriticalSection
+ ep {allowUnsafeReferences=false optimizeByteCode=true copyScriptSections=true ...} asCScriptEngine::<unnamed-type-ep>
- engine->scriptFunctions {array=0x0add3aa0 length=0x00000488 maxLength=0x00000800 ...} asCArray<asCScriptFunction *>
+ array 0x0add3aa0 asCScriptFunction * *
length 0x00000488 unsigned int
maxLength 0x00000800 unsigned int
+ buf 0x08da8948 "" char [8]
func 0x00000000 int
n 0x00000002 unsigned int
+ this 0x0adb7040 {refCount={...} gcFlag=true engine=0x08da8338 ...} asCScriptFunction * const
Cancel
Save
I'll need help in reproducing the problem so I can investigate it.
The crash is happening because the variable 'func' is 0. engine->scriptFunctions[0] is always null, so the call to AddRef() is invalid here.
However, the real question is why func is 0. I need your help to figure out the scenario in which this happens.
Can you show me the script code for the function that is being compiled? You can determine which it is with the following variables:
this->objectType->name (class name, if objectType is not 0)
this->name (function or method name)
Or even better, perhaps you can create a small script that reproduces the problem so I can incorporate it in my test suite and debug it myself?
By the way, which version of AngelScript are you using?
Cancel
Save
Alright, I'll take a look at the script when I get home from work. I am using the latest version of angelscript (2.23.0 tag in SVN).
Cancel
Save
Sorry it took me so long. Work. Here is what I have.
The class type is END_MenuItem, and the function name is the same, so I am assuming it is the constructor. I don't know if script functions are being called at this point or not, but if that is the case then they shouldn't be because I took out all instances of the class to debug this problem.
The class is a hierarchy involving a subclass and an interface. See their code below.
funcdef void END_MENUITEM_FUNC(END_MenuItem@ item);
class END_MenuItem : Widget
{
private Vector3 m_DrawColor;
private END_MENUITEM_FUNC@ m_Func;
private string@ m_Font;
private string@ m_Text;
private int mSize;
private bool bStringMeasured;
END_MenuItem(string@ font,int size,string@ txt,END_MENUITEM_FUNC@ f)
{
END_MenuMode mode = END_MenuMode::MAIN;
@m_Func = @f;
@m_Font = @font;
@m_Text = @txt;
mSize = size;
m_DrawColor = RGBA( 255,255,255,255 );
bStringMeasured = false;
}
void OnMousePressed(Mouse mouse)
{
// Left Mouse Button
if(mouse == Mouse::ONE) {
}
}
void OnMouseReleased(Mouse mouse)
{
}
void OnRender()
{
Canvas@ c = Canvas();
c.DrawString( m_Font,Position,m_DrawColor,mSize,m_Text );
}
void SetText( string@ txt ) { m_Text = txt; }
};
class Widget : IWidget
{
private IWidget@ mParent;
private Rect mGeometry;
private Vector2 mPosition;
private bool bIsVisible;
private uint uiZOrder;
private array<IWidget@> arrChildren;
Widget( IWidget@ parent = null )
{
@mParent = @parent;
if(mParent is null) {
@mParent = Ir_GUIRoot.Root;
}
bIsVisible = true;
}
bool OnUpdate(float delta_t) { return false; }
bool OnRender() { return false; }
bool OnDestroyed() { return false; }
bool OnCharInsert(uint8 ch) { return false; }
bool OnKeyPressed(Keys key) { return false; }
bool OnKeyReleased(Keys key) { return false; }
bool OnMouseMoved(const Vector2&in delta) { return false; }
bool OnMousePressed(Mouse mouse) { return false; }
bool OnMouseReleased(Mouse mouse) { return false; }
bool Update(float delta_t) final
{
for(uint i=0;i<arrChildren.length;i++)
{
arrChildren.OnUpdate(delta_t);
}
return false;
}
bool Render() final
{
for(uint i=0;i<arrChildren.length;i++)
{
if(arrChildren.IsVisible)
arrChildren.OnRender();
}
return false;
}
bool Destroyed() final
{
for(uint i=0;i<arrChildren.length;i++)
{
arrChildren.OnDestroyed();
}
return true;
}
bool CharInsert(uint8 ch) final
{
for(uint i=arrChildren.length-1;i>=0;i--)
{
if(arrChildren.CharInsert(ch)) {
return true;
}
}
return OnCharInsert(ch);
}
bool KeyPressed(Keys key) final
{
for(uint i=arrChildren.length-1;i>=0;i--)
{
if(arrChildren.KeyPressed(key)) {
return true;
}
}
return OnKeyPressed(key);
}
bool KeyReleased(Keys key) final
{
for(uint i=arrChildren.length-1;i>=0;i--)
{
if(arrChildren.KeyReleased(key)) {
return true;
}
}
return OnKeyReleased(key);
}
bool MouseMoved(const Vector2&in delta) final
{
for(uint i=arrChildren.length-1;i>=0;i--)
{
arrChildren.MouseMoved(delta);
}
OnMouseMoved(delta);
return false;
}
bool MousePressed(Mouse mouse) final
{
for(uint i=0;i<arrChildren.length;i++)
{
// Short Circuit
if(arrChildren.MousePressed(mouse)) {
return true;
}
}
return OnMousePressed(mouse);
}
bool MouseReleased(Mouse mouse) final
{
for(uint i=0;i<arrChildren.length;i++)
{
// Short Circuit
if(arrChildren.MousePressed(mouse)) {
return true;
}
}
return false;
}
// Methods
void AddChild( IWidget@ widget )
{
for(uint i=0;i<arrChildren.length;i++)
{
IWidget@ child = arrChildren;
if(widget.ZOrder < child.ZOrder) {
arrChildren.insertAt(i,widget);
break;
}
}
}
// Properties.
IWidget@ Parent {
get const { return mParent; }
}
Vector2 Position {
get const { return mPosition; }
set { mPosition = value; }
}
Rect Geometry {
get const { return mGeometry; }
set { mGeometry = value; }
}
bool IsVisible {
get const { return bIsVisible; }
set { bIsVisible = value; }
}
uint ZOrder {
get const { return uiZOrder; }
set { uiZOrder = value; }
}
};
interface IWidget
{
bool Update(float delta_t);
bool Render();
bool Destroyed();
bool CharInsert(uint8 ch);
bool KeyPressed(Keys key);
bool KeyReleased(Keys key);
bool MouseMoved(const Vector2&in delta);
bool MousePressed(Mouse mouse);
bool MouseReleased(Mouse mouse);
// Event callbacks.
bool OnUpdate(float delta_t);
bool OnRender();
bool OnDestroyed();
bool OnCharInsert(uint8 ch);
bool OnKeyPressed(Keys key);
bool OnKeyReleased(Keys key);
bool OnMouseMoved(const Vector2&in delta);
bool OnMousePressed(Mouse mouse);
bool OnMouseReleased(Mouse mouse);
// Methods
void AddChild( IWidget@ widget );
// Properties.
IWidget@ Parent { get const; }
Vector2 Position { get const; set; }
Rect Geometry { get const; set; }
bool IsVisible { get const; set; }
uint ZOrder { get const; set; }
};
EDIT: Just as I thought, excluding the file that defined END_MenuItem allows the program to run.
Cancel
Save
Thanks. I'll try to reproduce the problem in my tests.
Looking at the script I suspect it may be the END_MENUITEM_FUNC callback function in the parameter list that is triggering the bug.
Cancel
Save
My suspicion was incorrect. I've reduced the problem to the following script
class END_MenuItem : Widget
{
END_MenuItem()
{
}
};
class Widget
{
Widget( Widget@ parent = null )
{
}
};
The bug is caused when the base class doesn't have a default constructor, and the derived class doesn't explicitly call the base class' constructor with the appropriate arguments. As the compiler didn't see an explicit call to any of the base class' constructors it tries to call the default constructor which until version 2.22.1 was implemented automatically.
The correct behaviour in this case is for AngelScript to give an error message to tell the script writer to explicitly call the base constructor with super(...);.
I'll work on implementing this verification and appropriate error message, but until then you can work around the problem in 3 ways:
1. Explicitly call the base class' constructor with 'super(null);'
2. Implement a default constructor in the Widget class
3. Configure AngelScript to automatically provide the default constructor with engine->SetEngineProperty(asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true);
Regards,
Andreas
Cancel
Save
Bug fixed in revision 1252.
Thanks,
Andreas
Cancel
Save