This patch seems to fix the problem.
diff --git i/src/xdisp.c w/src/xdisp.c
index 563cf473cf..a2d605f3ea 100644
--- i/src/xdisp.c
+++ w/src/xdisp.c
@@ -22679,9 +22679,11 @@ maybe_produce_line_number (struct it *it)
&& it->what != IT_EOB)
tem_it.face_id = current_lnum_face_id;
- else if (display_line_numbers_major_tick > 0
+ else if (!beyond_zv
+ && display_line_numbers_major_tick > 0
&& (lnum_to_display % display_line_numbers_major_tick == 0))
tem_it.face_id = merge_faces (it->w, Qline_number_major_tick,
0, DEFAULT_FACE_ID);
- else if (display_line_numbers_minor_tick > 0
+ else if (!beyond_zv
+ && display_line_numbers_minor_tick > 0
&& (lnum_to_display % display_line_numbers_minor_tick == 0))
tem_it.face_id = merge_faces (it->w, Qline_number_minor_tick,