• 10
• 12
• 12
• 14
• 17

Passing delegate by value to vararg parameter causes crash

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

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 on other sites

Thanks for the detailed bug report. I'll investigate and fix this.

Share on other sites

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.