Nim/lib
zah 3b47a689cf
Remove the use of usrToCell in gcMark [backport:1.2] (#17709)
* Remove the use of usrToCell in gcMark [backport:1.2]

Recently, we've discovered a GC crash resulting from inlining of
the memory allocation procs that allowed the compiler to avoid
maintaining any references to the "user pointer" on the stack.
Instead, a "cell pointer" appeared there and all field accesses
were performed with adjusted offsets. This interfered with the
ability of the GC to mark the correct cell in the conservative
stack scans which lead to premature collection of objects.

More details here:
af69b3ceae

This commit closes another theoretical loophole that may lead to
the same problem. If a short proc is accessing both the object and
its reference count in a short sequence of instructions, the compiler
may be enticed to reduce the number of registers being used by storing
only a single pointer to the object and using offsets when reading
and writing fields. A perfectly good strategy would be to store only
the cell pointer, so the reference count updates can be performed
without applying offsets. Accessing the fields of the object requires
offsets anyway, but these can be adjusted at compile-time without any
loss. Following this strategy will lead to the same problem of marking
a wrong cell during the conservative stack scan, leading to premature
collection.

The problem is avoided by not using `usrToCell` in `gcMark`. Since
the cell discovery logic can already handle interior pointers, the
user pointers don't need to be adjusted for the GC to function correctly.
2021-04-14 12:10:01 +02:00
..
arch/x86 Coroutine rework. 2017-02-20 17:24:19 +02:00
core macrocache.nim: removed trailing whitespace 2021-04-11 20:14:44 +02:00
deprecated/pure Replace double backticks with single backticks - Part 2 out of ~6 (#17206) 2021-02-28 23:15:26 -08:00
experimental further progress on rst roles & directives (fix #17646) (#17659) 2021-04-08 19:00:14 +02:00
genode Genode platform fixes (#17521) 2021-04-09 16:29:10 +02:00
genode_cpp Genode platform fixes (#17521) 2021-04-09 16:29:10 +02:00
impure fix RST parsing when no indent after enum.item (fix #17249) (#17257) 2021-03-12 08:33:21 +01:00
js Fix small typos (#17680) 2021-04-09 00:40:19 +02:00
nintendoswitch Rewrite the memory management code for Nintendo Switch (#8169) 2018-07-05 16:33:15 +02:00
packages/docutils restyle RST option lists (#17637) 2021-04-10 09:49:01 +02:00
posix remove redundant void return in stdlib (#17464) 2021-03-23 08:28:53 +01:00
pure remove unnecessary assignment (#17702) 2021-04-12 08:58:46 +02:00
std add number literal jsbigints.big (#17707) 2021-04-13 09:33:28 +02:00
system Remove the use of usrToCell in gcMark [backport:1.2] (#17709) 2021-04-14 12:10:01 +02:00
windows fix #14010(fix std/registry + arc) (#17551) 2021-03-29 10:50:58 +02:00
wrappers fix #17615(runnableExamples silently ignored if placed after some code) (#17619) 2021-04-02 18:26:30 -07:00
cycle.h
nimbase.h fix #16752: threadvar now works with importcpp types; osx now uses native TLS (--tlsEmulation:off), which can be orders of magnitude faster (#16750) 2021-01-27 22:35:43 +01:00
nimhcr.nim fixes #17647 (#17667) 2021-04-07 23:26:53 +02:00
nimhcr.nim.cfg Initial version of the hot-code reloading support for native targets (#10729) 2019-02-26 15:48:55 +01:00
nimrtl.nim use single backtick (#17100) 2021-02-18 22:47:21 -08:00
nimrtl.nim.cfg Initial version of the hot-code reloading support for native targets (#10729) 2019-02-26 15:48:55 +01:00
stdlib.nimble attempt to make the build green again 2017-01-07 02:55:15 +01:00
system.nim iterable[T] (#17196) 2021-04-11 14:25:41 +02:00
system_overview.rst RST backtick refactor (all *.rst except manual.rst and rst_examples.rst) (#17258) 2021-03-18 20:37:55 -07:00