The background color and the frame are drawn for every line separately. listings assumes a certain line height and such graphic errors appear if the real height is larger than that. From your image I would guess you are using a larger font for the line numbers than for the normal text. You should set numberstyle to the same or smaller size than the normal text.
In my test I get the same white lines if the numberstyle is larger than the basicstyle (left) but not if it is smaller (right) or the same size.

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\begin{document}
\begin{minipage}{.2\textwidth}
\begin{lstlisting}[basicstyle=\scriptsize,numberstyle=\large,backgroundcolor=\color{black!20},numbers=left,frame=lrtb]
some code
more code
more code
more code
more code
more code
more code
more code
more code
\end{lstlisting}
\end{minipage}\hspace{2cm}%
\begin{minipage}{.2\textwidth}
\begin{lstlisting}[basicstyle=\scriptsize,numberstyle=\tiny,backgroundcolor=\color{black!20},numbers=left,frame=lrtb]
some code
more code
more code
more code
more code
more code
more code
more code
more code
\end{lstlisting}
\end{minipage}
\end{document}