Caller of dynamic library crashes with SIGSEV if D code allocates anything on heap.

Gabor Mezo via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 14 08:31:13 PST 2014


Hello,

I've opened an other thread for this, because this is a different 
issue.

Previous issue is there: 
http://forum.dlang.org/thread/zzjeajhjpzhnvgxquluu@forum.dlang.org#post-vuzttuewxyvuihubgtas:40forum.dlang.org

The current issue is if I build a dynamic library with DUB and 
call externals form another application, and my D code
allocates anything on heap, the calling process crashes with
SIGSEV.

I mean it works:

extern (C)
{
	int ping()
	{
		return 555;
	}
}

But it doesn't:

extern (C)
{
	int ping()
	{
                 try { throw new Exception("foo"); } catch
(Exception ex) { }
		return 555;
	}
}

or this one crashes too:

extern (C)
{
	int ping()
	{
                 auto foo = new Object();
		return 555;
	}
}


More information about the Digitalmars-d mailing list