Issue 15235 - inline asm: silent ICE (segfault) in asm_add_exp()
Summary: inline asm: silent ICE (segfault) in asm_add_exp()
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 normal
Assignee: Cauterite
URL: http://dpaste.dzfl.pl/701f26f64385
Keywords: diagnostic, iasm, pull
Depends on:
Blocks:
 
Reported: 2015-10-22 15:14 UTC by Cauterite
Modified: 2020-05-23 01:13 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 Cauterite 2015-10-22 15:14:12 UTC
See: http://dpaste.dzfl.pl/701f26f64385

(in case dpaste is offline:)

This statement:
	asm {mov [EBP - (0 - 0)], EAX;};
crashes DMD with no error message.

The crash is an access violation in asm_add_exp():
	Line 3953: o2 = asm_mul_exp(); // o2 is now null
	Line 3960: o2->disp = - o2->disp; // segfault
Comment 1 Cauterite 2015-10-28 14:37:50 UTC
After some more thorough testing:

void main() {
	asm {
		mov [+], EAX; // syntax error
		mov [-], EAX; // syntax error
		mov [*], EAX; // segfault
		mov [****], EAX; // segfault
		mov [/], EAX; // syntax error
		mov [EBX+], EAX; // compiles (?!)
		mov [EBX-], EAX; // segfault
		mov [EBX+*], EAX; // segfault
		mov [EBX*], EAX; // segfault
		mov [EBX*EBX*], EAX; // segfault
		mov [*EBX], EAX; // segfault
		mov [/EBX], EAX; // syntax error

		mov [EBX+EBX+EBX], EAX; // prints the same error message 20 times
	};
};
Comment 3 Cauterite 2016-08-19 21:53:37 UTC
Previous pull request closed; this will now be fixed by the patch for issue 15257:
https://github.com/dlang/dmd/pull/6068
Comment 4 basile-z 2019-02-28 18:08:49 UTC
Downgraded to diagnostic. Nowadays just

void main()
{
    asm {
	mov [EBX+EBX+EBX], EAX; // prints the same error message 20 times
    }
}      

is still there and all the segfaults are not happening anymore
Comment 5 Dlang Bot 2020-05-19 22:49:26 UTC
@benjones created dlang/dmd pull request #11166 "Fix issue 15235" fixing this issue:

- fix issue 15235.  Return after spotting an asm syntax error rather than goto-ing it 10 times

https://github.com/dlang/dmd/pull/11166
Comment 6 Dlang Bot 2020-05-23 01:13:27 UTC
dlang/dmd pull request #11166 "Fix issue 15235: inline asm: silent ICE (segfault) in asm_add_exp()" was merged into master:

- 185fd7155ea1dc7b22ed4b995ae12208d86f62e1 by Ben Jones:
  fix issue 15235.  Return after spotting an asm syntax error rather than goto-ing it 10 times

https://github.com/dlang/dmd/pull/11166