Nim/lib/system
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
..
mm styleCheck: Fix some inconsistent identifiers (#16177) 2020-12-21 09:41:56 -08:00
alloc.nim fixes #16214 [backport] (#16252) 2020-12-04 17:47:41 +01:00
ansi_c.nim system/excpt: let the OS handle termination on signal (#16712) 2021-02-19 00:29:21 -08:00
arc.nim Replace double backticks with single backticks - Part 1 out of ~6 (#17205) 2021-02-28 23:08:12 -08:00
arithm.nim use lowercase --define switches (#17283) 2021-03-07 12:08:41 +01:00
arithmetics.nim Replace double backticks with single backticks - Part 1 out of ~6 (#17205) 2021-02-28 23:08:12 -08:00
assertions.nim fixes #17033 [backport:1.4] (#17061) 2021-02-17 11:00:03 +01:00
assign.nim followup for #16717: minimized example + improved comment (#16721) 2021-01-15 01:09:58 +01:00
atomics.nim [docs minor] remove unicode in docs comments (#16267) 2020-12-06 05:51:29 +01:00
avltree.nim make AVL tree node part of the memory regions; fixes hard to reproduce channel crashes 2017-01-31 13:08:47 +01:00
basic_types.nim Replace double backticks with single backticks - Part 1 out of ~6 (#17205) 2021-02-28 23:08:12 -08:00
bitmasks.nim ARC now capable of custom extra alignment. Ref, closure and seq support. (#15697) 2020-10-28 14:00:49 +01:00
cellseqs_v1.nim more checking for --gc:arc, no need for valgrind (#14467) 2020-05-29 12:08:17 +02:00
cellseqs_v2.nim arc allocation method aligned (#15588) 2020-10-19 14:50:06 +02:00
cellsets.nim cleaned up the internal documentation (#17524) 2021-03-26 16:27:55 +01:00
cgprocs.nim Initial version of the hot-code reloading support for native targets (#10729) 2019-02-26 15:48:55 +01:00
channels_builtin.nim rename channels to channels_builtin (#17330) 2021-03-12 13:04:32 +01:00
chcks.nim [os:standalone]fix #14011 (#17564) 2021-03-29 17:54:28 +02:00
comparisons.nim implement RFCs/294 ; disallow enum <=> enum conversion (#16351) 2021-04-03 07:15:21 +02:00
countbits_impl.nim follow up #17539 (#17548) 2021-03-29 09:11:07 +08:00
cyclebreaker.nim ORC: prepare for another patent-pending optimization (#15996) 2020-11-18 22:31:06 +01:00
deepcopy.nim ARC now capable of custom extra alignment. Ref, closure and seq support. (#15697) 2020-10-28 14:00:49 +01:00
dollars.nim Replace double backticks with single backticks - Part 1 out of ~6 (#17205) 2021-02-28 23:08:12 -08:00
dyncalls.nim Genode platform fixes (#17521) 2021-04-09 16:29:10 +02:00
embedded.nim ensure the avr example keeps compiling (#17663) 2021-04-07 13:40:57 +02:00
exceptions.nim Replace double backticks with single backticks - Part 1 out of ~6 (#17205) 2021-02-28 23:08:12 -08:00
excpt.nim IC: green tests (#17311) 2021-03-19 16:53:38 +01:00
fatal.nim fix #16499 (#16514) 2021-01-04 18:27:58 +01:00
formatfloat.nim Revert "printing float values will have one more digit. (#13276) [backport]" (#13363) 2020-02-08 09:30:24 +01:00
gc.nim Remove the use of usrToCell in gcMark [backport:1.2] (#17709) 2021-04-14 12:10:01 +02:00
gc2.nim followup #17225: simplify code after removing gc2, generational (#17242) 2021-03-03 13:37:42 +01:00
gc_common.nim fixes #17647 (#17667) 2021-04-07 23:26:53 +02:00
gc_hooks.nim gc:destructors progress 2019-09-16 23:54:31 +02:00
gc_interface.nim fixes #13881 2020-05-12 15:46:24 +02:00
gc_ms.nim Remove the use of usrToCell in gcMark [backport:1.2] (#17709) 2021-04-14 12:10:01 +02:00
gc_regions.nim styleCheck: Fix some inconsistent identifiers (#16177) 2020-12-21 09:41:56 -08:00
hti.nim allow old styled RTTI for arc/orc (#15331) 2020-09-16 14:57:01 +02:00
inclrtl.nim remove all uses of condsyms symbols defined prior to bootstrap nim 0.20.0 (#16918) 2021-02-17 09:32:36 +01:00
indexerrors.nim [other] better error message for IndexError for empty containers (#11476) 2019-06-11 14:34:21 +02:00
integerops.nim fixes #14209 [backport:1.2] (#14213) 2020-05-05 00:48:13 +02:00
io.nim use lowercase --define switches (#17283) 2021-03-07 12:08:41 +01:00
iterators.nim further progress on rst roles & directives (fix #17646) (#17659) 2021-04-08 19:00:14 +02:00
iterators_1.nim Change stdlib imports to use std prefix in most examples (#17202) 2021-02-28 13:17:19 -08:00
jssys.nim [backport:1.4] JS cstring null fixes (#16979) 2021-02-11 17:04:32 +01:00
memalloc.nim [docs]close #12580 (#17549) 2021-03-28 20:21:27 -07:00
memory.nim remove all uses of condsyms symbols defined prior to bootstrap nim 0.20.0 (#16918) 2021-02-17 09:32:36 +01:00
memtracker.nim addQuitProc => addExitProc (#16765) 2021-01-22 19:51:11 +01:00
mmdisp.nim fix #15617(fix compilation failure on -d:useMalloc --gc:none) (#17555) 2021-03-30 20:15:14 +02:00
nimscript.nim Replace double backticks with single backticks - Part 2 out of ~6 (#17206) 2021-02-28 23:15:26 -08:00
orc.nim Replace double backticks with single backticks - Part 2 out of ~6 (#17206) 2021-02-28 23:15:26 -08:00
osalloc.nim add OpenBSD MAP_STACK for coroutines (#14353) 2020-05-16 21:56:52 +02:00
platforms.nim Add 32-bit RISC-V support (#16231) 2020-12-03 17:33:42 +01:00
profiler.nim Give better error message when profiler and memProfiler used at same time (#9948) 2018-12-19 10:02:20 +01:00
repr.nim remove all uses of condsyms symbols defined prior to bootstrap nim 0.20.0 (#16918) 2021-02-17 09:32:36 +01:00
repr_v2.nim repr_v2 improvements (#14992) 2020-07-15 22:04:15 +02:00
reprjs.nim fix #16025 repr now consistent: does not insert trailing newline (#16034) 2020-11-19 12:12:51 -08:00
seqs_v2.nim ARC now capable of custom extra alignment. Ref, closure and seq support. (#15697) 2020-10-28 14:00:49 +01:00
seqs_v2_reimpl.nim arc allocation method aligned (#15588) 2020-10-19 14:50:06 +02:00
setops.nim better setops docs (#16236) 2020-12-03 14:47:44 +01:00
sets.nim close #11330 sets uses optimized countSetBits (#17334) 2021-03-22 00:36:48 +01:00
stacktraces.nim Replace double backticks with single backticks - Part 2 out of ~6 (#17206) 2021-02-28 23:15:26 -08:00
strmantle.nim remove all uses of condsyms symbols defined prior to bootstrap nim 0.20.0 (#16918) 2021-02-17 09:32:36 +01:00
strs_v2.nim rename prepareStrMutation to prepareMutation (#17235) 2021-03-03 08:08:52 +08:00
syslocks.nim use lowercase --define switches (#17283) 2021-03-07 12:08:41 +01:00
sysspawn.nim styleCheck: Fix some inconsistent identifiers (#16177) 2020-12-21 09:41:56 -08:00
sysstr.nim followup #17225: simplify code after removing gc2, generational (#17242) 2021-03-03 13:37:42 +01:00
threadlocalstorage.nim Fix #17299, fix setAffinity for android (#17574) 2021-03-30 08:05:37 +02:00
threads.nim Replace double backticks with single backticks - Part 2 out of ~6 (#17206) 2021-02-28 23:15:26 -08:00
timers.nim miscellaneous bug fixes (#13291) 2020-01-30 10:54:50 +01:00
widestrs.nim use single backtick (#17133) 2021-02-21 00:27:39 -08:00