D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19489 - Null function call results in no stack trace
Summary: Null function call results in no stack trace
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2018-12-15 04:25 UTC by Ahmet Sait
Modified: 2019-12-28 17:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ahmet Sait 2018-12-15 04:25:23 UTC
void function() f = null;
f();

Calling a null function pointer results gives:
object.Error@(0): Access Violation
----------------
Program exited with code 1


void function() f = cast(void function())1;
f();

Calling a non-null function pointer gives:
object.Error@(0): Access Violation
----------------
0x00000001
0x00423FDB in _Dmain at D:\NX 1337\Projects\BlendUI\src\blendui\main.d(23)
0x00436353 in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll().__lambda1()
0x004362D5 in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()
0x0043616F in _d_run_main
0x00424038 in main at D:\NX 1337\Projects\BlendUI\src\blendui\math\size.d(7)
0x00454FE9 in mainCRTStartup
0x76C28484 in BaseThreadInitThunk
0x771C302C in RtlValidSecurityDescriptor
0x771C2FFA in RtlValidSecurityDescriptor
Program exited with code 1


My quick glance at the trace handler source it seems like null is being used for determining length of a fixed size stack buffer. (sigh..) This is a rather frustrating bug and trivial to fix. I had to boot up linux and use gdb to just debug this nonsense.
Comment 1 Dlang Bot 2019-12-08 17:11:19 UTC
@ahmetsait updated dlang/druntime pull request #2862 "Fix issue 19489 - Null function call results in no stack trace" fixing this issue:

- Fix issue 19489 - Null function call results in no stack trace
  
  Removes questionable function address checks

https://github.com/dlang/druntime/pull/2862
Comment 2 Dlang Bot 2019-12-28 17:56:52 UTC
dlang/druntime pull request #2862 "Fix issue 19489 - Null function call results in no stack trace" was merged into master:

- 1028578eaf0e4a0a7414c3b6d5a099bd529d3979 by Ahmet Sait:
  Fix issue 19489 - Null function call results in no stack trace

https://github.com/dlang/druntime/pull/2862