From ee468b6d495ff50135bcc08c240bbebc336a83b1 Mon Sep 17 00:00:00 2001 From: Jack Applegame Date: Thu, 29 Sep 2016 14:48:48 +0400 Subject: [PATCH 1/2] Fix range violation in multithreaded application compiled with -profile=gc option Possible related issue https://issues.dlang.org/show_bug.cgi?id=14511 --- src/rt/profilegc.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rt/profilegc.d b/src/rt/profilegc.d index f750808892..a3fcabf121 100644 --- a/src/rt/profilegc.d +++ b/src/rt/profilegc.d @@ -94,8 +94,13 @@ static ~this() // Merge foreach (name, entry; newCounts) { - globalNewCounts[name].count += entry.count; - globalNewCounts[name].size += entry.size; + auto ptr = name in globalNewCounts; + if(ptr) { + ptr.count += entry.count; + ptr.size += entry.size; + } else { + globalNewCounts[name] = entry; + } } } else From a6f139313b612223c2b035bd22abd9a7cd4503d1 Mon Sep 17 00:00:00 2001 From: Jack Applegame Date: Thu, 29 Sep 2016 15:06:59 +0400 Subject: [PATCH 2/2] Fix code style --- src/rt/profilegc.d | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rt/profilegc.d b/src/rt/profilegc.d index a3fcabf121..5b197976cc 100644 --- a/src/rt/profilegc.d +++ b/src/rt/profilegc.d @@ -95,10 +95,13 @@ static ~this() foreach (name, entry; newCounts) { auto ptr = name in globalNewCounts; - if(ptr) { + if (ptr) + { ptr.count += entry.count; ptr.size += entry.size; - } else { + } + else + { globalNewCounts[name] = entry; } }