justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

GC race condition when tracing large objects #472

Closed justinethier closed 3 years ago

justinethier commented 3 years ago

Observed the GC thread segfaults when running the array1 benchmark when cyclone has been compiled with debug and profiling flags set (-p -pg and NO -O2 flag), and the non-macro version of gc_mark_black is used.

justinethier commented 3 years ago

The issue seems to be that the GC can be tracing the contents of a huge array (in this case 1 MB) before all of the array members are initialized.

The crash does not occur if Cyc_make_vector is modified to initialize the vector object to a data type with no children (such as double_type) and if the type is only set properly after all array initialization has completed.

justinethier commented 3 years ago

Fixed and have not observed any further crashes with the changes in place. Closing.