Bug 219578 - app-portage/ufed-0.40-r7: SIGFPE (division by zero) when displaying help
Bug#: 219578 Product:  Portage Development Version: 2.1 Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: truedfx@gentoo.org Reported By: Martin.vGagern@gmx.net
Component: Tools
URL: 
Summary: app-portage/ufed-0.40-r7: SIGFPE (division by zero) when displaying help
Keywords:  
Status Whiteboard: 
Opened: 2008-04-28 09:26 0000
Description:   Opened: 2008-04-28 09:26 0000
I was running ufed in a terminal window with 61 lines of 213 columns. Whenever
I tried to display the help text, ufed died. It left the terminal in non-echo
mode, so I had to reset it again.

Debugging the ufed-curses interface, I found the culprit:
ufed-curses.c: static void drawscrollbar(void): line 112:

  mvwaddch(w, 1+(wHeight(Scrollbar)-3)*topy
  /(items->prev->top+items->prev->height-(wHeight(List)-1)), 0, ACS_BLOCK);

for which the debugger gave me these values in my case:
  /(             50 +             1     -(52           -1))

So the cause of the SIGFPE that gets raised is a division by zero. Haven't
tried to understand what this line is supposed to do in general or in my
special case.

After a couple of tries I always encountered bug 219577 as well, so I had to
switch to a text console to allow gpm connections to get processed. Otherwise
ufed would not even display its list.

------- Comment #1 From Harald van Dijk 2008-04-28 16:40:59 0000 -------
Thanks for the report! I hadn't considered terminal windows large enough to
display the whole of the help at once, and the line you've copied here tries to
calculate the position of the scroll thumb. Clearly, if everything's displayed
already, there's no need to scroll, so I've fixed this in ufed-0.40-r8 by
skipping the code in that case.