0

I am receiving this error when I rescue in my MRuby code:

arena overflow error

I am not familiar with this term and how to fix it. Here is a sample of my C program:

while (true) {
  SDL_Event event;
  if (SDL_PollEvent(&event)) {
    if (event.type == SDL_QUIT) break; //exit the loop

    switch(event.type) {
      case SDL_KEYDOWN:
        if (event.key.keysym.sym == SDLK_LEFT)  { key = "left"; code = "input_received(:left)"; }
        //...
        printf("Key down: %s\n", key);
        mrb_load_string(mrb, code);
        break;
    }
  }

  // Re-render each iteration
  mrb_load_string(mrb, "render()"); //<-- this is the line that causes the error
}
Andrew
  • 227,796
  • 193
  • 515
  • 708

1 Answers1

0

Block the code which allocated temporary objects with mrb_gc_arena_save/mrb_gc_arena_restore.

int ai = mrb_gc_arena_save(mrb);
// creating temporary objects
mrb_gc_arena_restore(mrb, ai);
mattn
  • 7,571
  • 30
  • 54