Andrew Kyle Purtell created ZOOKEEPER-5125:
----------------------------------------------
Summary: (C client) zoo_multi error handling crashes, misreads
results, and hangs
Key: ZOOKEEPER-5125
URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5125
Project: ZooKeeper
Issue Type: Bug
Components: c client
Reporter: Andrew Kyle Purtell
Assignee: Andrew Kyle Purtell
The C client's multi() path has several related defects.
When a synchronous `zoo_multi()` call fails, the err fields of the
`zoo_op_result_t` array stay uninitialized, so an application might mistake a
failed sub-operation as a success. `NULL` ops or results arrays will crash the
client instead of returning an error. On an expired or unrecoverable handle,
the client still queues requests, so a synchronous call can block forever, for
example a zero count `zoo_multi()`.
Inside a multi op handling the server answers a container create with a
`Create2Response`, which holds a path and a stat. However the client decodes it
as a `CreateResponse` which doesn't know about the stat, so every result after
it will be decoded in a misaligned manner, essentially reading garbage.
The fix fills every result slot with the failure code on all failure paths, and
returns `ZBADARGUMENTS` for NULL arrays. New requests on an unrecoverable
handle are refused at once. Each sub-result is decoded correctly. A reply with
more or fewer results than operations returns `ZMARSHALLINGERROR` instead of
crashing the application.
New mock server tests Zookeeper_multiFailure and real server test
Zookeeper_multi::testCreateContainer cover these cases.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)