How can we take derivatives on $UV$ w.r.t a vector $\mathbf{x}$ by using the chain rule and $d(UV)=dU\cdot V + U\cdot dV$? There is an example about this question on Page 564 in Chapter 11 of B&V's Convex Optimization book. It presents the gradient and Hessian matrix of the following log barrier function,

$$\tag{11.5}
\phi(x)=-\sum_{i=1}^m \log(-f_i(x))
$$
$$
\nabla \phi(x)=\sum_{i=1}^m\frac{1}{-f_i(x)} \nabla f_i(x)\\
\nabla^2 \phi(x)=\sum_{i=1}^m\frac{1}{f_i(x)^2} \nabla f_i(x)\nabla f_i(x)^T+\sum_{i=1}^m\frac{1}{-f_i(x)} \nabla^2 f_i(x)
$$

I could not figure out the first term of the Hessian. According to the chain rule and the product rule, $U=\frac{1}{-f_i(x)}$ and $V=\nabla f_i(x)$, and $dU=\frac{1}{f_i(x)^2}\nabla f_i(x)$. Hence, the first term of the Hessian is supposed to be $dU\cdot V=\frac{1}{f_i(x)^2}\nabla f_i(x)\cdot \nabla f_i(x)$, but it does not satisfy the requirement of matrix product for dimensionality since $\nabla f_i(x)$ is a vector. I know the quoted form for the first term of Hessian meets the dimensionality requirement and makes sense in the respective of dimensionality consistency with the second term. Can anybody give me some instruction on this kind of case for calculating derivatives using both chain rule and pruduct rule simultaneously? I will appreciate any instructions.

Because of the nature of the cost function,
we can reason on a single component
and sum everything at the end.
The differential readily writes
$$
d\phi
= 
\frac{-df_n}{f_n}
$$
Introducing the gradient column vector
$\nabla f_n(\mathbf{x})$ , we can write
$
df_n
=
(\nabla f_n)^T d\mathbf{x}
$.
The gradient is thus
$$
\mathbf{g}
=
\frac{\partial \phi}{\partial \mathbf{x}}
=
\frac{-1}{f_n} \nabla f_n (\mathbf{x})
$$
Introducing the Hessian matrix
$d\nabla f_n = 
\mathbf{H}_{f_n} d\mathbf{x}$,
it follows that
\begin{eqnarray*}
d\mathbf{g}
&=&
\frac{df_n}{f_n^2} \nabla f_n (\mathbf{x}) 
-\frac{1}{f_n} (d\nabla f_n) \\
&=&
\frac{1}{f_n^2} \nabla f_n (\mathbf{x})
(\nabla f_n)^T d\mathbf{x}  
-\frac{1}{f_n} \mathbf{H}_{f_n} d\mathbf{x}
\end{eqnarray*}
The Hessian is thus
$$
\mathbf{H}_\phi=
\frac{1}{f_n^2} \nabla f_n (\mathbf{x})
(\nabla f_n)^T 
-\frac{1}{f_n} \mathbf{H}_{f_n}
$$
