Shell: fix possible stack overflow in validation.
Ouch! That was a subtle Lwt misuse. With the current (very-old) validator code, when the validation of block is waiting to the validation of its predecessor, a "pending" Lwt thread is created. The validation of the predecessor might also wait on its own predecessor, potentially creating a very long chain of pending validation"... If in the process one of the block is tagged invalid, all the pending "successors" in the chain are 'wakeuped' immediatly and in sequence, potentially blowing the stack in the process. A quick fix is to add an `Lwt_unix.yield` to break the recursion. A better fix is to not create such long chain of "pending" validations. See merge request !59.
This commit is contained in:
parent
a69cb480b6
commit
79f2dca33a
@ -474,6 +474,7 @@ module Context_db = struct
|
|||||||
let net_state = Distributed_db.state v.net_db in
|
let net_state = Distributed_db.state v.net_db in
|
||||||
get_context v block.Block_header.shell.predecessor >>= function
|
get_context v block.Block_header.shell.predecessor >>= function
|
||||||
| Error _ as error ->
|
| Error _ as error ->
|
||||||
|
Lwt_unix.yield () >>= fun () ->
|
||||||
set_context v hash (Error [(* TODO *)]) >>= fun () ->
|
set_context v hash (Error [(* TODO *)]) >>= fun () ->
|
||||||
Lwt.return error
|
Lwt.return error
|
||||||
| Ok _context ->
|
| Ok _context ->
|
||||||
|
Loading…
Reference in New Issue
Block a user