Left side is finite but right side becomes infinte despite using correct series expansions I want to evaluate (for integer $n,p$)
$$ 
L_p = \sum_{m=1}^{n-1} \ln \left(  4 \sin^2 \frac{m \pi }{n}\right)  e^{- 2\pi i p m
/n}
$$
and I have got two tools
$$ 
\sum_{k=1}^{\infty} \frac{\cos kx}{k} = - \frac{1}{2} \ln \left(4 \sin ^2 \frac{x}{2}\right) 
$$
and
$$ 
\sum_{k=1}^{n-1} r^{k} \cos kx =  \frac{1 - r \cos x - r^{n} \cos (nx) + r^{n+1} \cos (nx -x)}{r^2 + 1 - 2 r \cos x} -1
$$
both of which are formulas tabulated in Gradshteyn, and I've individually
verified them. (I couldn't derive the first myself, but second was easy to prove.)
Plugging in $L_p$, we get
$$ 
L_p =  \sum_{m=1}^{n-1} \left[-2 \sum_{k=1}^{\infty}  \frac{\cos \left(  k \cdot  \frac{2 m \pi}{n}\right)}{k}\right] e^{- 2\pi i p m/n}
$$
and exchanging the sum (as I understand can always be done according to this
question), this becomes
$$ 
L_p\; = -2\sum_{k=1}^{\infty}  \frac{1}{k} \cdot  \left[  \sum_{m=1}^{n-1} e^{-2 \pi i p m/n} \cdot  \cos \left( m \cdot  \frac{2\pi k}{n}\right)\right]
$$
Setting $r = e^{-2 \pi i p/n}$, $x= 2\pi k/n$ and using above formula, the inner sum becomes $-1$.  which means
$$ 
L_p = 2 \sum_{k=1}^{\infty} \frac{1}{k}  
$$
which is of course divergent, but the left side was finite because $m=0$ never
occurs in the sum.
What is going wrong, and how can I get $L_p$?
 A: You have correctly obtained $$L_p=-2\sum_{k=1}^\infty\frac{A_k}{k},\quad A_k=\sum_{m=1}^{n-1}e^{-2\pi imp/n}\cos(2mk\pi/n),$$ but $A_k$ is not always equal to $-1$: in fact $2A_k=B_{p-k}+B_{p+k}-2$, where $$B_j=\sum_{m=0}^{n-1}e^{-2\pi imj/n}=\begin{cases}n,&n\mid j\\0,&n\nmid j\end{cases}\qquad(j\in\mathbb{Z})$$ Thus, thanks to $\sum_{k=1}^m A_k=0$ (and $A_{m+k}=A_k$), the sum $\sum_{k=1}^\infty A_k/k$ converges.
As for a "closed form", we get $L_p=S_p+S_{-p}$ where, for $0<j\leqslant n$,
\begin{align*}
S_j&=\sum_{k=1}^\infty\frac{1-B_{j-k}}{k}\\&=\lim_{N\to\infty}\sum_{k=1}^{nN}\frac{1-B_{j-k}}{k}\\&=\lim_{N\to\infty}\left(\sum_{k=1}^{nN}\frac1k-\sum_{k=0}^{N-1}\frac{n}{nk+j}\right)\\&=\lim_{N\to\infty}\left[\sum_{k=1}^{nN}\frac1k-\sum_{k=1}^N\frac1k+\sum_{k=0}^{N-1}\left(\frac1{k+1}-\frac1{k+j/n}\right)\right]\\&=\log n+\gamma+\psi(j/n)
\end{align*}
using the digamma function $\psi$, and clearly $S_{n+j}=S_j$ for any $j\in\mathbb{Z}$. This gives an expression for $L_p$ using two values of $\psi$, or just one of them if we apply the reflection formula. But we cannot get rid of $\psi$ completely (not using Gauss's digamma theorem - and we don't, since it would essentially bring us back to the beginning of the question; in fact the above is a way to prove this theorem).
A: 
$$  L_p\; = -2\sum_{k=1}^{\infty}  \frac{1}{k} \cdot  \left[  \sum_{m=1}^{n-1} e^{-2 \pi i p m/n} \cdot  \cos \left( m \cdot  \frac{2\pi k}{n}\right)\right] $$ Setting $r = e^{-2 \pi i p/n}$, $x= 2\pi k/n$ and using above formula, the inner sum becomes $-1$.

I did not attempt to reproduce the calculation, but it is not possible that you could have eliminated two unknowns, $p$ and $k$, by summing over $m$. Also you didn't tell us what $p$ is.
For example set $p=0$ then all of the $r=1$ so you are left with cosines. What I think you have done is to neglect $p$ when you did that expansion.

which
means $$  L_p = 2 \sum_{k=1}^{\infty} \frac{1}{k}   $$ which is of
course divergent, but the left side was finite because $m=0$ never
occurs in the sum.
What is going wrong, and how can I get $L_p$?

I confirmed numerically that your second formula for $L_p$ was correct, and also the expansions you're using, so I would look at the final expansion where you remove both of $p$ and $k$.
See here for an online-runnable version of the numeric checks.
