Simultaneous diagonalization of two matrices if one does not has $n$ independent eigenvectors I have a small confusion. Suppose there are two $n \times n$ matrices $A$ and $B$ such that $A$ does not has $n$ independent eigenvectors. The $A$ is not diagonalizable. But $A$ and $B$ commute and I can find a matrix that diagonalizes $B$. Doesn't this violate that $A$ is diagonalizable because the same matrix also diagonalizes $A$ which diagonalizes $B$.
Two such matrices are:
$A$
$$
    \begin{matrix}
    1 & 0 & 1 \\
    0 & 0 & 0 \\
    1 & 0 & 1 \\
    \end{matrix}
$$
$B$
$$
    \begin{matrix}
    2 & 1 & 1 \\
    1 & 0 & -1 \\
    1 & -1 & 2 \\
    \end{matrix}
$$

In your example, matrices $A$ and $B$ are both diagonalizable (and both have $n$ independent eigenvectors), so it's not an instance of the thing you're describing:


*

*$A$ has eigenvector $(1,0,1)$ to the eigenvalue $2$, and eigenvectors $(0,1,0)$ and $(1,0,-1)$ to the eigenvalue $0$.

*$B$ has eigenvector $(1,-2,-1)$ to the eigenvalue $-1$, eigenvector $(1,1,-1)$ to the eigenvalue $2$, and eigenvector $(1,0,1)$ to the eigenvalue $3$.


(Also, since $A$ and $B$ are both symmetric in this example, we know in advance that they should be diagonalizable.)
But in general, no: just because $A$ commutes with $B$ and $B$ is diagonalizable, doesn't mean that $A$ is diagonalizable (in the same basis that diagonalizes $B$, or otherwise). For instance, any matrix (diagonalizable or otherwise) commutes with the zero matrix and the identity matrix. 
Also, the Jordan form of a matrix lets us write it as $D + N$ in some basis, where $D$ is diagonal, $N$ is nilpotent (and therefore not diagonalizable in general) and $D$ commutes with $N$, giving us a whole slew of counterexamples.
