Skip to content

Commit

Permalink
Merge pull request #568 from klickverbot/7127-dwarf-crash
Browse files Browse the repository at this point in the history
Issue 7127 - Const-related infinite recursion in DWARF generation
  • Loading branch information
WalterBright committed Dec 18, 2011
2 parents 9d6ba97 + 22481e2 commit a7df55e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/backend/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,10 +1568,21 @@ unsigned dwarf_typidx(type *t)
return 0;

if (t->Tty & mTYconst)
{ tnext = type_copy(t);
{ // We make a copy of the type to strip off the const qualifier and
// recurse, and then add the const abbrev code. To avoid ending in a
// loop if the type references the const version of itself somehow,
// we need to set TFforward here, because setting TFforward during
// member generation of dwarf_typidx(tnext) has no effect on t itself.
unsigned short old_flags = t->Tflags;
t->Tflags |= TFforward;

tnext = type_copy(t);
tnext->Tcount++;
tnext->Tty &= ~mTYconst;
nextidx = dwarf_typidx(tnext);

t->Tflags = old_flags;

code = nextidx
? dwarf_abbrev_code(abbrevTypeConst, sizeof(abbrevTypeConst))
: dwarf_abbrev_code(abbrevTypeConstVoid, sizeof(abbrevTypeConstVoid));
Expand Down
14 changes: 14 additions & 0 deletions test/compilable/debuginfo.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRED_ARGS: -g

struct Bug7127a {
const(Bug7127a)* self;
}

struct Bug7127b {
void function(const(Bug7127b) self) foo;
}

void main() {
Bug7127a a;
Bug7127b b;
}

0 comments on commit a7df55e

Please sign in to comment.