3719 – forward references can cause out-of-memory error

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3719 - forward references can cause out-of-memory error
Summary: forward references can cause out-of-memory error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch
Depends on:
Blocks:
Reported: 2010年01月18日 11:29 UTC by Rainer Schuetze
Modified: 2015年06月09日 01:27 UTC (History)
1 user (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 Rainer Schuetze 2010年01月18日 11:29:00 UTC
If there are forward references that are not resolved for a long time, dmd can waste a lot of memory and cpu-cycles. 
It's not easy to create a small test case, but qtd fails to compile with "out of memory" without the following patch:
Module::runDeferredSemantic() should not retry between every new symbol in a class or struct, but only when some sensible progress is made (e.g. if Module::dprogress > 0). runDeferredSemantic() must then be forced to run once before running semantic2() on the modules.
Index: mars.c
===================================================================
--- mars.c	(revision 336)
+++ mars.c	(working copy)
@@ -1109,6 +1109,12 @@
 if (global.errors)
 	fatal();
 
+ if(modules.dim)
+ { // last chance to resolve deferred symbols
+	Module::dprogress = 1;
+	((Module *)modules.data[0])->runDeferredSemantic(); // should be static instead
+ }
+
 // Do pass 2 semantic analysis
 for (i = 0; i < modules.dim; i++)
 {
Index: module.c
===================================================================
--- module.c	(revision 336)
+++ module.c	(working copy)
@@ -938,6 +938,8 @@
 {
 size_t len;
 
+ if(dprogress == 0)
+	return;
 static int nested;
 if (nested)
 	return;
Comment 1 Walter Bright 2010年01月19日 18:52:34 UTC
Changeset 342
Comment 2 Walter Bright 2010年01月30日 22:41:54 UTC
fixed dmd 1.056 and 2.040


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