Error information can be lost during high concurrency
Closed this issue · 0 comments
When the API encounters an error, it generally calls virGetLastError() and "stashes" the pointer to the libvirt error object, which is returned to the user, wrapped up an an Error object. The getters on the Error object look at the various fields of the "stashed" virErrorPtr struct.
However, according to the libvirt documentation:
The error object is kept in thread local storage so separate threads can safely use this function concurrently. Note that it does not take a copy, so error information can be lost if the current thread obtains this pointer, calls another libvirt function, and then tries to access this pointer.
So if the same worker thread gets re-used before the consumer has "read" the error object, the information gets lost.