3192 – Segfault(iasm.c) asm in a anonymous delegate

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3192 - Segfault(iasm.c) asm in a anonymous delegate
Summary: Segfault(iasm.c) asm in a anonymous delegate
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
Reported: 2009年07月19日 16:38 UTC by lifc0@yahoo.com.cn
Modified: 2014年04月18日 09:12 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description lifc0@yahoo.com.cn 2009年07月19日 16:38:57 UTC
below lines crash dmd 1.046/2.031 on linux and window platfrom:
void func (void delegate () callback) {
	callback();
}
void main () {
	func(() { asm{ int 3; }; });
}
Comment 1 Don 2009年07月20日 00:26:41 UTC
Reduced test case:
void delegate () foo = (){ asm{ int 3; }};
This is segfaulting in iasm.c (line 4269 in DMD2).
if( sc->func->type->nextOf()->isScalar()) // segfaults here: nextOf() is null.
Comment 2 Don 2009年07月20日 00:50:55 UTC
This patch is enough to fix the segfault, and allow the code to compile. I'm not sure if it's correct that nextOf() is null, though -- there may be a deeper problem here.
iasm.c line 4269. (in Statement *AsmStatement::semantic(Scope *sc)):
 asmstate.bReturnax = 1;
- if (sc->func->type->nextOf()->isscalar())
+ if (sc->func->type->nextOf() && sc->func->type->nextOf()->isscalar())
	asmstate.bReturnax = 0;
Comment 3 Walter Bright 2009年07月20日 02:24:23 UTC
For inferring function return type, the nextOf() is null. That would be a problem here, but we never use bReturnax anyway, so just #if out the code.
Comment 4 Don 2009年07月20日 02:38:02 UTC
(In reply to comment #3)
> For inferring function return type, the nextOf() is null.
It'd be great if you could put that in a comment in the definition of nextOf(). I'd never been sure when it's supposed to be non-null, it's one of the least obvious things in the code. Should it become non-null in a later semantic pass?
Also a comment about the cto, ito, sto members of type would be really useful. When should they be non-null?
In a great many of the compiler bugs I've looked at, they're null, but I've not been sure whether the bug is that they're null, or that other code is not dealing with the case that they're null.
Comment 5 Walter Bright 2009年09月03日 13:27:02 UTC
Fixed dmd 1.047 and 2.032


AltStyle によって変換されたページ (->オリジナル) /