Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


- - - - -

crash in ctx->GetLineNumber


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 11 February 2013 - 10:19 PM

Hi smile.png

script code:

 

 

 

// Global scope
Object @obj = CraeteObject();

 

 

 

 

// C++

Object *CreateObject()
{
    asIScriptContext *ctx = asGetActiveContext();


    assert( ctx );


    int stack_size = ctx->GetCallstackSize();


    if( stack_size > 0 )
    {    
        const char *script_section;


        int line = ctx->GetLineNumber(0, 0, &script_section); // Crash
    }
}
 

 



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 12 February 2013 - 07:41 AM

Thanks. I'll look into this.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 12 February 2013 - 01:12 PM

I couldn't recreate the problem. I believe this has already been fixed in the latest revision. 

 

Could you try the latest revision and let me know if the problem still happens for you? 


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#4 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 19 February 2013 - 10:24 PM

 in revision 1564 - problem resolved itselfsmile.png



#5 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 28 February 2013 - 06:12 AM

Hi egane)

 

 

 in revision 1564 - problem resolved itselfsmile.png

I made ​​a mistake - Its not true! 

 

 

 

I couldn't recreate the problem. I believe this has already been fixed in the latest revision. 

 

Could you try the latest revision and let me know if the problem still happens for you? 

I had to strain to find it)

 

So! Bug show, if we use empty file, but not empty as this "" - emty as that " // not use source"!

 

for reproducte bug, you a need use two files! 

First file:

 

 

Text @a = scene.Cr();
 

Second file:

 

 

// file with out work body!
 

Scene::Cr

 

 

void *Scene::Cr()
{
    asIScriptContext *ctx = asGetActiveContext();
    const char *script_section;
    int line = ctx->GetLineNumber(0, 0, &script_section);
    return nullptr;
}
 

 

if not use second file, bug not showing


#6 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 28 February 2013 - 10:17 AM

Thanks. I'll try again with this additional information.

 

 

May I ask how on earth you're coming up with all these odd scenarios? wink.png


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#7 bollµ   Members   -  Reputation: 354

Like
0Likes
Like

Posted 28 February 2013 - 11:17 AM

I'm wondering about that as well :) You catch around two bugs every week :D


a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)


#8 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 28 February 2013 - 08:17 PM

I'm sorry, but I still can't reproduce the problem.

 

I wrote the following test based on what you provided:

 

 

 
class TestLN
{
public:
void *TestLineNumber()
{
    asIScriptContext *ctx = asGetActiveContext();
    const char *script_section;
    int line = ctx->GetLineNumber(0, 0, &script_section);
    return 0;
}
};
 

bool Test()
{
    bool fail = false;

    // Test crash in GetLineNumber
    // http://www.gamedev.net/topic/638656-crash-in-ctx-getlinenumber/
    {
        asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
        engine->RegisterInterface("foo");
        engine->RegisterObjectType("Test", 0, asOBJ_REF | asOBJ_NOCOUNT);
        engine->RegisterObjectMethod("Test", "foo @TestLineNumber()", asMETHOD(TestLN, TestLineNumber), asCALL_THISCALL);
 
        TestLN t;
        engine->RegisterGlobalProperty("Test test", &t);
 
        asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
        mod->AddScriptSection("a","foo @f = test.TestLineNumber();");
        mod->AddScriptSection("b"," // nothing to compile");
        int r = mod->Build();
        if( r < 0 )
            TEST_FAILED;
        engine->Release();
    }
    return fail;
}


 

What do I need to change to reproduce the crash?


Edited by Andreas Jonsson, 28 February 2013 - 08:19 PM.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#9 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 28 February 2013 - 09:24 PM

What do I need to change to reproduce the crash?

 

 my engine can use multiply tabs, and any tab use asIScritpEngine. If exemple i open 5 tabs in debug mode, script compilation time ~2300 msec ( 5 tabs is over 10 second ), I all time use save and load byte code smile.png

 

Problem show after save and load byte code, use can use this exemple:

 

 

 

class CBytecodeStream : public asIBinaryStream
{
public:
    CBytecodeStream() {wpointer = 0;rpointer = 0;}


    void Write(const void *ptr, asUINT size) 
    {
        if( size == 0 ) 
            return; 
        buffer.resize(buffer.size() + size);
        memcpy(&buffer[wpointer], ptr, size); 
        wpointer += size;
    }
    void Read(void *ptr, asUINT size) 
    {
        memcpy(ptr, &buffer[rpointer], size); 
        rpointer += size;
    }


    int rpointer;
    int wpointer;
    std::vector<asBYTE> buffer;
} script_stream;


class TestLN
{
public:
    void *TestLineNumber()
    {
        asIScriptContext *ctx = asGetActiveContext();
        const char *script_section;
        int line = ctx->GetLineNumber(0, 0, &script_section);
        return 0;
    }
};


void Reg( asIScriptEngine *engine ){


    engine->RegisterInterface("foo");
    engine->RegisterObjectType("Test", 0, asOBJ_REF | asOBJ_NOCOUNT);
    engine->RegisterObjectMethod("Test", "foo @TestLineNumber()", asMETHOD(TestLN, TestLineNumber), asCALL_THISCALL);


    TestLN t;
    engine->RegisterGlobalProperty("Test test", &t);
}


bool Test()
{
    bool fail = false;


    // Test crash in GetLineNumber
    // http://www.gamedev.net/topic/638656-crash-in-ctx-getlinenumber/
    {
        asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);


        Reg( engine );


        asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
        mod->AddScriptSection("b"," // nothing to compile");
        mod->AddScriptSection("a","foo @f = test.TestLineNumber();");
        int r = mod->Build();


        script_stream.wpointer = 0;
        mod->SaveByteCode( &script_stream );


        asIScriptEngine *engine2 = asCreateScriptEngine(ANGELSCRIPT_VERSION);
        asIScriptModule *mod2 = engine2->GetModule(0, asGM_ALWAYS_CREATE );


        Reg( engine2 );


        script_stream.rpointer = 0;
        mod2->LoadByteCode( &script_stream );


        assert( r >= 0 );
        engine->Release();
    }
    return fail;
}
 

 

 

I'm wondering about that as well smile.png You catch around two bugs every week biggrin.png

the Russian saying - not I such, life suchrolleyes.gif



#10 bollµ   Members   -  Reputation: 354

Like
0Likes
Like

Posted 28 February 2013 - 11:45 PM

that's really deep...


a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)


#11 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 01 March 2013 - 07:04 AM

Thanks. I'll give this a try.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#12 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 01 March 2013 - 10:58 AM

Finally. I've reproduced the problem now. Thanks a lot for the help.

 

I'll work on the fix, and should have it ready for check-in by tonight.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#13 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
0Likes
Like

Posted 01 March 2013 - 05:10 PM

I've fixed this in revision 1578.

 

Regards,

Andreas


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS