7478 – stack overflow compiling with -deps -release -inline -noboundscheck

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7478 - stack overflow compiling with -deps -release -inline -noboundscheck
Summary: stack overflow compiling with -deps -release -inline -noboundscheck
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice, pull
: 6951 (view as issue list)
Depends on:
Blocks:
Reported: 2012年02月09日 18:55 UTC by phyphor0
Modified: 2012年05月15日 21:39 UTC (History)
4 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 phyphor0 2012年02月09日 18:55:03 UTC
One source file:
import std.stdio;
void main() {}
Compile with the following command line:
dmd -noboundscheck -inline -release -deps=temp.dep main.d
All arguments are needed, as is the import. main() is not.
Version 2.057
Comment 1 Don 2012年03月30日 17:14:49 UTC
It is crashing in AttribDeclaration::inlineScan(),
 for (size_t i = 0; i < d->dim; i++)
 { Dsymbol *s = (*d)[i];
 s->inlineScan(); // <---- crashes here
It isn't a null pointer, it seems to be an invalid vtable (memory corruption?)
Comment 2 Don 2012年04月05日 06:15:31 UTC
I can reproduce this on Windows7, but not on Linux64.
This is the worst heisenbug I've ever seen. Although it's possible to reduce the test case a bit, the reduction makes no sense -- changing an unused list of anonymous enums from 9 to 8 items makes the bug go away, for example.
It seems to be either a stack overflow or an out of memory condition, because the faulting location jumps around if you make changes to the test case.
Worse, some changes don't just crash; they cause the windows command prompt to hang afterwards.
Comment 3 Don 2012年05月14日 04:11:50 UTC
My test of this on Linux was incorrect. It happens there too.
valgrind shows the problem lies in this code (mars.c, line 1320) 
 if (global.params.moduleDeps != NULL)
 {
 assert(global.params.moduleDepsFile != NULL);
 File deps(global.params.moduleDepsFile);
 OutBuffer* ob = global.params.moduleDeps;
 deps.setbuffer((void*)ob->data, ob->offset);
 deps.writev();
------> note that file 'deps' has already been destroyed at this point!!!!
 }
 // Scan for functions to inline
 if (global.params.useInline)
 {
 /* The problem with useArrayBounds and useAssert is that the
 * module being linked to may not have generated them, so if
 * we inline functions from those modules, the symbols for them will
 * not be found at link time.
 */
 if (!global.params.useArrayBounds && !global.params.useAssert)
 {
 // Do pass 3 semantic analysis on all imported modules,
 // since otherwise functions in them cannot be inlined
 for (size_t i = 0; i < Module::amodules.dim; i++)
 {
 m = Module::amodules[i];
 if (global.params.verbose)
 printf("semantic3 %s\n", m->toChars());
 m->semantic3();
----> now semantic3 can encounter an import, which will add write to the outbuffer, that was already free'd.
I love valgrind.
Comment 5 Don 2012年05月14日 07:55:23 UTC
Bug 6951 seems to be the same as this one.
Comment 6 github-bugzilla 2012年05月15日 19:55:43 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/e0739df44af7f459de82ad5582cf662dd036237d
Fix issue 7478 stack overflow compiling with -deps -release -inline -noboundscheck
valgrind ftw!
https://github.com/D-Programming-Language/dmd/commit/c029f71d3eb0312205595c63559dff487d27bc29
Merge pull request #947 from donc/heisenbug7478
 7478 stack overflow compiling with -deps -release -inline -noboundscheck
Comment 7 Don 2012年05月15日 21:39:08 UTC
*** Issue 6951 has been marked as a duplicate of this issue. ***


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