summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorYuriy Glukhov <yuriy.glukhov@gmail.com>2016-07-11 16:23:15 +0300
committerYuriy Glukhov <yuriy.glukhov@gmail.com>2016-07-11 16:23:15 +0300
commit59d17cb341d4348b16a80c36ecc6e6e3c9f9c6a2 (patch)
tree198e1627008cdd3a5052bd8123225b9267bf423d /lib/system
parent9620e66533c81b8a3b06ecd262928ce98696b995 (diff)
downloadNim-59d17cb341d4348b16a80c36ecc6e6e3c9f9c6a2.tar.gz
Fixed crash with leakDetector and threads enabled.
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/gc.nim22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim
index 3e71b4fe0..a36dbf02b 100644
--- a/lib/system/gc.nim
+++ b/lib/system/gc.nim
@@ -452,10 +452,13 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer =
   gcAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2")
   # now it is buffered in the ZCT
   res.typ = typ
-  when leakDetector and not hasThreadSupport:
-    if framePtr != nil and framePtr.prev != nil:
-      res.filename = framePtr.prev.filename
-      res.line = framePtr.prev.line
+  when leakDetector:
+    res.filename = nil
+    res.line = 0
+    when not hasThreadSupport:
+      if framePtr != nil and framePtr.prev != nil:
+        res.filename = framePtr.prev.filename
+        res.line = framePtr.prev.line
   # refcount is zero, color is black, but mark it to be in the ZCT
   res.refcount = ZctFlag
   sysAssert(isAllocatedPtr(gch.region, res), "newObj: 3")
@@ -503,10 +506,13 @@ proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} =
   sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2")
   # now it is buffered in the ZCT
   res.typ = typ
-  when leakDetector and not hasThreadSupport:
-    if framePtr != nil and framePtr.prev != nil:
-      res.filename = framePtr.prev.filename
-      res.line = framePtr.prev.line
+  when leakDetector:
+    res.filename = nil
+    res.line = 0
+    when not hasThreadSupport:
+      if framePtr != nil and framePtr.prev != nil:
+        res.filename = framePtr.prev.filename
+        res.line = framePtr.prev.line
   res.refcount = rcIncrement # refcount is 1
   sysAssert(isAllocatedPtr(gch.region, res), "newObj: 3")
   when logGC: writeCell("new cell", res)