Turn GC off at boot on Windows

This is to stop crashes like:

    .\miniruby.exe: [BUG] Segmentation fault
    ruby 3.4.0dev (2024-03-26T15:38:26Z pull/10370/merge 040ea2ae2f) [x64-mswin64_140]

    -- Control frame information -----------------------------------------------
    c:0001 p:0000 s:0003 E:000d00 DUMMY  [FINISH]

    -- Threading information ---------------------------------------------------
    Total ractor count: 1
    Ruby thread count for this ractor: 1

    -- C level backtrace information -------------------------------------------
    C:\Windows\SYSTEM32\ntdll.dll(NtWaitForSingleObject+0x14) [0x00007FFA091AFC74]
    C:\Windows\System32\KERNELBASE.dll(WaitForSingleObjectEx+0x93) [0x00007FFA05BB4513]
    D:\a\ruby\ruby\build\miniruby.exe(rb_print_backtrace+0x3e) [0x00007FF64E536EFE] d:\a\ruby\ruby\src\vm_dump.c:844
    D:\a\ruby\ruby\build\miniruby.exe(rb_vm_bugreport+0x1ae) [0x00007FF64E5370B2] d:\a\ruby\ruby\src\vm_dump.c:1154
    D:\a\ruby\ruby\build\miniruby.exe(rb_bug_for_fatal_signal+0x77) [0x00007FF64E3FF357] d:\a\ruby\ruby\src\error.c:1087
    D:\a\ruby\ruby\build\miniruby.exe(sigsegv+0x71) [0x00007FF64E4C79E5] d:\a\ruby\ruby\src\signal.c:926
    C:\Windows\System32\ucrtbase.dll(seh_filter_exe+0x233) [0x00007FFA0521CE03]
    D:\a\ruby\ruby\build\miniruby.exe(`__scrt_common_main_seh'::`1'::filt$0+0x16) [0x00007FF64E594DA0] f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:269
    C:\Windows\SYSTEM32\VCRUNTIME140.dll(_C_specific_handler+0x9f) [0x00007FF9E54AF73F]
    C:\Windows\SYSTEM32\ntdll.dll(_chkstk+0x11f) [0x00007FFA091B4C2F]
    C:\Windows\SYSTEM32\ntdll.dll(RtlWalkFrameChain+0x14bf) [0x00007FFA09114CEF]
    C:\Windows\SYSTEM32\ntdll.dll(KiUserExceptionDispatcher+0x2e) [0x00007FFA091B399E]
    D:\a\ruby\ruby\build\miniruby.exe(newobj_of+0x6d) [0x00007FF64E418615] d:\a\ruby\ruby\src\gc.c:2949
    D:\a\ruby\ruby\build\miniruby.exe(rb_wb_protected_newobj_of+0x32) [0x00007FF64E41C7DA] d:\a\ruby\ruby\src\gc.c:2974
    D:\a\ruby\ruby\build\miniruby.exe(str_new0+0x64) [0x00007FF64E4E7F48] d:\a\ruby\ruby\src\string.c:887
    D:\a\ruby\ruby\build\miniruby.exe(rb_enc_str_new+0x40) [0x00007FF64E4D89B8] d:\a\ruby\ruby\src\string.c:945
    D:\a\ruby\ruby\build\miniruby.exe(iseq_compile_each0+0xdd7) [0x00007FF64E3B4A23] d:\a\ruby\ruby\src\compile.c:10368
    D:\a\ruby\ruby\build\miniruby.exe(iseq_compile_each+0x74) [0x00007FF64E3B3C40] d:\a\ruby\ruby\src\compile.c:9971
This commit is contained in:
Peter Zhu 2024-03-26 14:25:41 -04:00
Родитель 19916bac96
Коммит aa794cc5a2
2 изменённых файлов: 7 добавлений и 0 удалений

5
gc.c
Просмотреть файл

@ -1910,6 +1910,11 @@ rb_objspace_alloc(void)
rb_darray_make_without_gc(&objspace->weak_references, 0); rb_darray_make_without_gc(&objspace->weak_references, 0);
// TODO: debug why on Windows Ruby crashes on boot when GC is on.
#ifdef _WIN32
dont_gc_on();
#endif
return objspace; return objspace;
} }

2
vm.c
Просмотреть файл

@ -4198,7 +4198,9 @@ Init_VM(void)
*/ */
rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new()); rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new());
#ifdef _WIN32
rb_objspace_gc_enable(vm->objspace); rb_objspace_gc_enable(vm->objspace);
#endif
} }
vm_init_redefined_flag(); vm_init_redefined_flag();