Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack trace missing for null object access in module constructor #18652

Open
dlangBugzillaToGithub opened this issue Aug 19, 2013 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Andrej Mitrovic (@AndrejMitrovic) reported this on 2013-08-19T03:09:24Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=10851

CC List

Description

-----
shared static this()
{
    class C
    {
        void foo() { }
    }

    C c;
    c.foo();
}

void main()
{
}
-----

$ dmd -g -run test.d
> object.Error: Access Violation

When using the same code in main, a proper stack trace is returned:

-----
module test;

void main()
{
    class C
    {
        void foo() { }
    }

    C c;
    c.foo();
}
-----

object.Error: Access Violation
----------------
0x0040201B in _Dmain at C:\dev\code\d_code\stack_trace_working.d(11)
0x004028E4 in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).v
oid runMain()
0x00402974 in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).v
oid runAll()
0x00402251 in _d_run_main
0x00402074 in main
0x004141AD in mainCRTStartup
0x766C33CA in BaseThreadInitThunk
0x77C19ED2 in RtlInitializeExceptionChain
0x77C19EA5 in RtlInitializeExceptionChain

Tested on Win 7 64bit.
@dlangBugzillaToGithub
Copy link
Author

kekeniro2 commented on 2013-10-25T21:11:54Z

I hit this.

Written in core.runtime.d :
static this()
{
    // NOTE: Some module ctors will run before this handler is set, so it's
    //       still possible the app could exit without a stack trace.  If
    //       this becomes an issue, the handler could be set in C main
    //       before the module ctors are run.
    Runtime.traceHandler = &defaultTraceHandler;
}

At least, it had better be changed to 'shared static this'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant