Multiple threads could execute mongoc_handshake_data_append concurrently, causing undefined behavior. _mongoc_handshake_freeze() isn't thread-safe either, although it updates a global variable.
mongoc_handshake_data_append is an undocumented function intended for closely integrated drivers like PHPC, but it should be safe to use regardless.