D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5009 - TraceHandler not being called on Access Violation
Summary: TraceHandler not being called on Access Violation
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-07 02:54 UTC by Benjamin Thaut
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Benjamin Thaut 2010-10-07 02:54:34 UTC
The TraceHandler that is built into the core runtime is not being called on Access Violation errors. Try this piece of sourcecode:

import std.stdio;
import core.runtime;

Throwable.TraceInfo TraceHandler1(void* ptr){
	writefln("TraceHandler1");
	return null;
}

Throwable.TraceInfo TraceHandler2(void* ptr){
	writefln("TraceHandler2");
	return null;
}

void main(string[] argv){
	Runtime.traceHandler(&TraceHandler1);
	try {
		int[] array = new int[20];
		array[20] = 0;
	}
	catch(Error e){
	}
	
	Runtime.traceHandler(&TraceHandler2);
	
	int* ptr = null;
	*ptr = 0;
}

TraceHandler2 is never being called. I tested this with dmd 2.046, 2.048 and 2.049.
Comment 1 Benjamin Thaut 2013-02-09 03:55:31 UTC
Fixed in https://github.com/D-Programming-Language/druntime/pull/368