I am currently trying to write a multi-format (JSON and msgpack)
multi-transport (TCP, Unix ports, file ports) RPC server and client egg
for Chicken. I have a decent architecture for my program (I think) but I
currently face an inexplicable bug that randomly appear and that I
I used a simple actor model to handle concurrency in a clean way:
actors communicate through message passing and handle their internal
states in a single thread so that race conditions are impossible. To
implement this model I used srfi-18 threads, mailbox and COOPS classes.
An actor is an instance of a class inheriting from the <actor>
base class I defined. It loops over its mailbox and run actions for each
message it received.
The software isn't complete yet but I am working on the test suite to
validate the features before going any further. Here is my problem:
When I am running the test suite I run the server on a separate
thread (for now each actor of the server is on another thread too) and I
try to send messages. however, I got the following error:
Warning (#<thread: sch>): in thread: (mailbox-send!) bad argument type - not a mailbox: #f
Indeed, this is a "virtual" class (never instantiated directly but
supposed to be inherited) and the child classes never access or
overwrite private-* attributes (that why they got this prefix).
Here it appears to be the one-shot slot from the scheduler class that
correspond to this #f but I got the same bug with different actors and
different slots from the corresponding classes.
I was then wondering if I got something wrong or if there is a deeper bug in the combo srfi-18/coops/mailbox.
If you want to have a look at the complete code you can find it at
https://github.com/Lattay/chicken-meta-rpc. You may want to look at
src/main/actor.scm (definition of the actor base class) or to
src/main/server.scm (definitions of the actual actors).
If you want to try it you may run `make test`. Dependencies are matchable, mailbox, srfi 18 and 69 and coops.
Hoping someone could help, thank you for reading so far.
PS: I don't ask for a code review (do it if you feels like it though)
since it is not a fun thing to do but I want to check if this bug ring a bell for
some of you.