Jump to content
  • Advertisement
Sign in to follow this  
Solokiller

Passing delegate by value to vararg parameter causes crash

This topic is 729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Passing a delegate by value to a vararg parameter causes a crash.

 

The following code causes the crash in 2.31.1:

funcdef void Foo();

class Bar
{    
    void bar()
    {
        Print( "works\n" );
    }
}

void test()
{    
    dictionary foo;
    
    foo.set( "bar", Foo( Bar().bar ) );
    
    Foo@ pFoo;
    
    foo.get( "bar", @pFoo );
    
    pFoo();
}

dictionary::set's second parameter is ?& in, which fails to handle this case. Using @Foo instead of Foo causes it to work as expected.

 

A complete program that triggers this problem can be downloaded here: https://dl.dropboxusercontent.com/u/46048979/AS_FuncDefBug.rar

 

Generic functions taking ref objects for vararg parameters are a bit hard to deal with. Seems like they sometimes have their ref count incremented by the engine, but not always. Sometimes i'd double free one, and if i don't, i end up leaking a reference. Seems to be related to this problem.

Edited by Solokiller

Share this post


Link to post
Share on other sites
Advertisement

Thanks. I don't think the reference counting issue is caused by the library itself, i found some incorrect reference handling issues in my code and fixed it. Seems good now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!