Hello folks. I am currently developing quite a complex project in
Mruby + c. Needless to say, I like what I find out; the tool is
quite productive and quite performing.

I currently work for a University. The code will eventually manage a
laboratory with much hardware, for the purpose of studying the motion
of the human body (a so-called sensimotricity lab). 

The project has already several Pthreads (started from C) plus a
couple of parallel-running Mruby virtual machines operating from their
independent processes (communicating via Unix sockets with the main
process).

I am experiencing a sporadic crash with this message:

*** Error in `mruby/bin/mruby': free(): invalid next size (fast): 0x0000000002828ec0 ***

Via gdb I traced the problem to mrb_incremental_gc being called from
mrb_obj_alloc, and eventually obj_free being called for an Array
object where ((struct RArray*)obj)->ptr happens to be NULL. 

I locally solved this problem by changing the body of mrb_free from

  (mrb->allocf)(mrb, p, 0, mrb->allocf_ud);

to

  if(p)
    (mrb->allocf)(mrb, p, 0, mrb->allocf_ud);

but I have no way to know if this is the proper way to handle the
problem I encounter.

This only happens when the application is being started (thus when
allocating lots of objects), and it happens about once every 5-10
runs, tending to happen in short sequences sometime (2 or 3 one after
the other). Obviously, with the same code and same input data.

Another problem I have is that, also sporadically, when I interrupt my
application with Ctrl-C, I get something like

*** Error in `mruby/bin/mruby': corrupted double-linked list: 0x000000000205df00 ***

this is more messy to debug because the process does not crash (I must
hit Ctrl-C a few more times to make it halt) and if I attach gdb to
the running PID I find that the stack is corrupted. This may very well
be due to my free procedures for classes that have C data structures,
but I was wondering if someone had ideas about how this may be
debugged.

I imagine that the main discussions about Mruby are in Japanese, and I
must very shamefully admit that I do not go much further than counting
from 1 to 10 in Japanese (thanks to my past Aikido years ;-). But
there has to be some place where I can raise these issues.

Thanks in advance - I may be contacted privately if you think this
subject is a bit off-topic for the ruby-talk list.

Carlo

-- 
  *         Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido / fluido.as             che bisogno ci sarebbe
  *               di parlare tanto di amore e di rettitudine? (Chuang-Tzu)