On Sunday, 4 May 2014 at 09:42:17 UTC, Alex wrote:
Hello,

I am trying to use the std.log module that is here:

https://github.com/linkrope/log.d

And I encountered a segmentation fault using dmd 2.065 on a Linux 64 platform. The reduced test case is this:

//============================================================================
import std.stdio;
import std.log;

private class CHello {
        
        ~this() {
info("info - destructor"); //info, warning, error segfault; however, writefln works
        }
}

void main(string[] args) { CHello chello = new CHello(); }
//============================================================================

Is this a bug?

Maybe, maybe not. As rule of thumb, you can't allocate during a GC cleaning cycles, and class destructors are usually called during a GC cleaning cycle.

This means it is usually unsafe to call *anything* that could potentially allocate in a destructor.

I don't know the details of the log module. AFAIK, the code itself doesn't *seem* to allocate anything to just log, but it does seem to use a singleton logger object.

Could you try to log a single "info" in your main, and see if it resolves the issue?

We'd need to contact the author directly too about this issue.

Reply via email to