diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2024-06-12 15:07:53 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2024-06-12 16:12:46 -0400 |
| commit | 7c46aa5ed4573ca04e6ffe1b19191e8227db2ab3 (patch) | |
| tree | 200f11722d47d4c2262290154a7c5e6d4f6a56fa | |
| parent | 94a8f05f00185df6063dd2ce2939b96713806c7a (diff) | |
[Bug #20577] Fix freeing symbols when RUBY_FREE_AT_EXIT
Dynamic symbols point to a fstring. When we free the symbol, we hash the
fstring to remove it from the table. However, the fstring could have
already been freed, which can cause a crash.
This commit changes it to remove the reference to the fstring before
freeing the symbol so we can avoid this crash.
| -rw-r--r-- | gc.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -4336,6 +4336,17 @@ rb_objspace_call_finalizer_i(VALUE obj, void *data) case T_FILE: obj_free(objspace, obj); break; + case T_SYMBOL: + if (rb_free_at_exit) { + if (RSYMBOL(obj)->fstr && + (BUILTIN_TYPE(RSYMBOL(obj)->fstr) == T_NONE || + BUILTIN_TYPE(RSYMBOL(obj)->fstr) == T_ZOMBIE)) { + RSYMBOL(obj)->fstr = 0; + } + + obj_free(objspace, obj); + } + break; case T_NONE: break; default: |
