Bug #11423
closedruby_cleanup does not reset initialized flag
Description
ruby_setup checks for this static initialized to determine whether to run.
int
ruby_setup(void)
{
    static int initialized = 0;
    int state;
    if (initialized)
	return 0;
    initialized = 1;
But ruby_cleanup fails to reset it, causing future initializations to do nothing. This means an embedded app which runs ruby scripts in a setup/run/cleanup cycle will crash the second time.
        
           Updated by scorpion007 (Alex Budovski) about 10 years ago
          Updated by scorpion007 (Alex Budovski) about 10 years ago
          
          
        
        
      
      Actually, the problem is worse than that: I tried making a simple change to have ruby_cleanup reset the global flag, but it looks like modules never clean up after themselves!
E.g.
void
Init_frozen_strings(void)
{
    assert(!frozen_strings);
    frozen_strings = st_init_table_with_size(&fstring_hash_type, 1000);
}
frozen_strings never gets reset to NULL. Which means the second time ruby_setup is called, this will assert.
        
           Updated by nobu (Nobuyoshi Nakada) about 10 years ago
          Updated by nobu (Nobuyoshi Nakada) about 10 years ago
          
          
        
        
      
      - Description updated (diff)
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: WONTFIX, 2.1: WONTFIX, 2.2: WONTFIX
That cycle is not guaranteed until MVM is supported.
        
           Updated by nobu (Nobuyoshi Nakada) about 10 years ago
          Updated by nobu (Nobuyoshi Nakada) about 10 years ago
          
          
        
        
      
      - Status changed from Open to Closed
Applied in changeset r51511.
vm.c: frozen_strings in rb_vm_t
- vm.c (Init_vm_objects, rb_vm_fstring_table): use frozen_strings
 table in rb_vm_t. [ruby-core:70274] [Bug #11423]
        
           Updated by normalperson (Eric Wong) about 10 years ago
          Updated by normalperson (Eric Wong) about 10 years ago
          
          
        
        
      
      nobu@ruby-lang.org wrote:
That cycle is not guaranteed until MVM is supported.
Is MVM still on the roadmap?  [ruby-core:64626]
I may take another look at cleaning up internals for MVM
        
           Updated by usa (Usaku NAKAMURA) over 8 years ago
          Updated by usa (Usaku NAKAMURA) over 8 years ago
          
          
        
        
      
      - Related to Bug #13380: [PATCH] Remove unused Init_frozen_strings declaration added