RejectedSoftware Forums

Sign up

Uncaught exception in `Task` doesn't cause core dump

Hey there,

So, I am getting a core dump, all nice and all, but my stacktrace is this:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000aa5b60 in rt.deh_win64_posix.terminate() ()
(gdb) bt
#0  0x0000000000aa5b60 in rt.deh_win64_posix.terminate() ()
#1  0x0000000000a64085 in _d_throwc ()
#2  0x000000000090ceb1 in vibe.core.core.VibeDriverCore.resumeCoreTask(vibe.core.core.CoreTask, Exception) (this=0x7f0d8e8ca980, event_exception=0x0, ctask=0x7f0d3c2de600)
    at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/core.d:1116
#3  0x000000000090cceb in vibe.core.core.VibeDriverCore.resumeTask(vibe.core.task.Task, Exception, bool) (this=0x7f0d8e8ca980, initial_resume=false, event_exception=0x0, task=...)
    at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/core.d:1092
#4  0x000000000090cc14 in vibe.core.core.VibeDriverCore.resumeTask(vibe.core.task.Task, Exception) (this=0x7f0d8e8ca980, event_exception=0x0, task=...)
    at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/core.d:1086
#5  0x000000000091b332 in onSocketRead (buf_event=0x29c27c8, arg=0x2b8a300) at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/drivers/libevent2_tcp.d:596
#6  0x00007f0d8e0ae2aa in ?? () from /usr/lib/x86_64-linux-gnu/libevent-2.0.so.5
#7  0x000000000000beaf in ?? ()
#8  0x0000000000000000 in ?? ()

so, looking at the according line I se that it is just an error propagation:

	void resumeCoreTask(CoreTask ctask, Exception event_exception = null)
	{
		assert(ctask.thread is Thread.getThis(), "Resuming task in foreign thread.");
		assert(ctask.state == Fiber.State.HOLD, "Resuming fiber that is not on HOLD");

		if( event_exception ){
			extrap();
			ctask.m_exception = event_exception;
		}

		static if (__VERSION__ > 2066)
			auto uncaught_exception = ctask.call!(Fiber.Rethrow.no)();
		else
			auto uncaught_exception = ctask.call(false);
		if (auto th = cast(Throwable)uncaught_exception) {
			extrap();

			assert(ctask.state == Fiber.State.TERM);
			logError("Task terminated with unhandled exception: %s", th.msg);
			logDebug("Full error: %s", th.toString().sanitize);

			// always pass Errors on
			if (auto err = cast(Error)th) throw err; //<- MY EXCEPTION HERE
		} else assert(!uncaught_exception, "Fiber returned exception object that is not a Throwable!?");
	}

Looking at the Std/Err Out I see the stack trace that actually caused my segfault, some problem in my code, not the issue here.

The issue for me is that I don't get a core dump for the stacktrace I see on that Stdout/Stderr. And that stacktrace is not that usefule becasue it has no line information and I can't look at the programs state that way.

Can I configure vibe.d somehow to give me a proper core dump when an exception is not caught in a Task?

cheers

--Marenz

Re: Uncaught exception in `Task` doesn't cause core dump

For what it's worth, it seems this issue can only be fixed directly in the runtime, so I went a head and created a PR:

https://github.com/D-Programming-Language/druntime/pull/1288

Vibe will need a minor modification to make use of that feature then. (Namely passing false to the Fiber c'tor).

I guess it would make sense to be able to globally specify some kind of default behavior regarding that.

On Wed, 06 May 2015 21:38:39 GMT, Mathias L. Baumann wrote:

Hey there,

So, I am getting a core dump, all nice and all, but my stacktrace is this:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000aa5b60 in rt.deh_win64_posix.terminate() ()
(gdb) bt
#0  0x0000000000aa5b60 in rt.deh_win64_posix.terminate() ()
#1  0x0000000000a64085 in _d_throwc ()
#2  0x000000000090ceb1 in vibe.core.core.VibeDriverCore.resumeCoreTask(vibe.core.core.CoreTask, Exception) (this=0x7f0d8e8ca980, event_exception=0x0, ctask=0x7f0d3c2de600)
    at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/core.d:1116
#3  0x000000000090cceb in vibe.core.core.VibeDriverCore.resumeTask(vibe.core.task.Task, Exception, bool) (this=0x7f0d8e8ca980, initial_resume=false, event_exception=0x0, task=...)
    at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/core.d:1092
#4  0x000000000090cc14 in vibe.core.core.VibeDriverCore.resumeTask(vibe.core.task.Task, Exception) (this=0x7f0d8e8ca980, event_exception=0x0, task=...)
    at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/core.d:1086
#5  0x000000000091b332 in onSocketRead (buf_event=0x29c27c8, arg=0x2b8a300) at ../../../.dub/packages/vibe-d-0.7.23/source/vibe/core/drivers/libevent2_tcp.d:596
#6  0x00007f0d8e0ae2aa in ?? () from /usr/lib/x86_64-linux-gnu/libevent-2.0.so.5
#7  0x000000000000beaf in ?? ()
#8  0x0000000000000000 in ?? ()

so, looking at the according line I se that it is just an error propagation:

	void resumeCoreTask(CoreTask ctask, Exception event_exception = null)
	{
		assert(ctask.thread is Thread.getThis(), "Resuming task in foreign thread.");
		assert(ctask.state == Fiber.State.HOLD, "Resuming fiber that is not on HOLD");

		if( event_exception ){
			extrap();
			ctask.m_exception = event_exception;
		}

		static if (__VERSION__ > 2066)
			auto uncaught_exception = ctask.call!(Fiber.Rethrow.no)();
		else
			auto uncaught_exception = ctask.call(false);
		if (auto th = cast(Throwable)uncaught_exception) {
			extrap();

			assert(ctask.state == Fiber.State.TERM);
			logError("Task terminated with unhandled exception: %s", th.msg);
			logDebug("Full error: %s", th.toString().sanitize);

			// always pass Errors on
			if (auto err = cast(Error)th) throw err; //<- MY EXCEPTION HERE
		} else assert(!uncaught_exception, "Fiber returned exception object that is not a Throwable!?");
	}

Looking at the Std/Err Out I see the stack trace that actually caused my segfault, some problem in my code, not the issue here.

The issue for me is that I don't get a core dump for the stacktrace I see on that Stdout/Stderr. And that stacktrace is not that usefule becasue it has no line information and I can't look at the programs state that way.

Can I configure vibe.d somehow to give me a proper core dump when an exception is not caught in a Task?

cheers

--Marenz