Questions & answers bug in the fake netlayer code
On the fake-netlayer-v2
branch there is a bug when you run the fake-netlayer tests. To reproduce this switch to the branch and enter the guix environment and run the following:
$ ./pre-inst-env guile tests/ocapn/netlayer/test-fake.scm
This will produce the following error:
;; === Caught error: ===
;; message: #<<message> to: #<local-object ^internal-handler> resolve-me: #f args: (#<<cmd-send-message> msg: #<<questioned> message: #<<message> to: #<<question-finder> debug-name: "tKundC"> resolve-me: #<local-object ^resolver> args: ("Arthur")> answer-this-question: #<<question-finder> debug-name: "eYtqlO">>>)>
;; exception: #<&compound-exception components: (#<&error> #<&origin origin: #f> #<&message message: "No such entry in questions ~S"> #<&irritants irritants: (#<<question-finder> debug-name: "tKundC">)> #<&exception-with-kind-and-args kind: misc-error args: (#f "No such entry in questions ~S" (#<<question-finder> debug-name: "tKundC">) #f)>)>
In goblins/vat.scm:
210:6 13 (vat-loop)
In ice-9/control.scm:
91:24 12 (call-with-escape-continuation _)
In ice-9/boot-9.scm:
1752:10 11 (with-exception-handler _ _ #:unwind? _ # _)
In goblins/vat.scm:
202:8 10 (handle-incoming-message _)
In goblins/core.scm:
2172:6 9 (actormap-churn _ _ #:catch-errors? _ # _)
1731:8 8 (call-with-fresh-syscaller _ #<procedure 7fd919f0b230 a…>)
2118:11 7 (_ _ _)
In ice-9/boot-9.scm:
1752:10 6 (with-exception-handler _ _ #:unwind? _ # _)
In goblins/core.scm:
2103:12 5 (do-call)
1444:21 4 (_handle-message _)
1112:9 3 (_$ #<local-object ^internal-handler> (#<<cmd-send-mes…>))
In goblins/ocapn/captp.scm:
925:31 2 (_ _)
766:24 1 (marshall-to #<<question-finder> debug-name: "tKundC">)
In ice-9/boot-9.scm:
1685:16 0 (raise-exception _ #:continuable? _)
This seems to be due to the utils resolve-vow-and-return-result
function, if you perform the same test code (in the context of the fake-netlayer test):
(define bobs-message-getter
(lambda ()
(define bob-vow
(<- a-mycapn 'enliven bob-locator-sref))
(<- bob-vow "Arthur")))
(define bobs-message-vow
(a-vat bobs-message-getter))
(a-vat
(lambda ()
(on bobs-message-vow
(lambda (i-heard)
(pk 'i-heard i-heard)))))
This works and will report (i-heard "Hello Arthur, my name is Bob!")
, however if you wrap it in a run-fibers
the problem occurs:
(define bobs-message-getter
(lambda ()
(define bob-vow
(<- a-mycapn 'enliven bob-locator-sref))
(<- bob-vow "Arthur")))
(run-fibers
(lambda ()
(define bobs-message-vow
(a-vat bobs-message-getter))
;; This will fix the issue if uncommented
;; (sleep 1)
(a-vat
(lambda ()
(on bobs-message-vow
(lambda (i-heard)
(pk 'i-heard i-heard)))))
It seems that when the problem occurs, it's trying to send a message to a question finder which doesn't yet exist in our questions table (or the other vat's answers table). I'm wondering if this is a re-ordering problem caused by running it in fibers somehow.