BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000906 [BusyBox] Other crash sometimes 06-16-06 14:23 06-27-06 11:15
Reporter mnuss View Status public  
Assigned To BusyBox
Priority normal Resolution fixed  
Status closed   Product Version
Summary 0000906: top fails with "top: Can't find process info in /proc" on some systems
Description I noticed top was failing consistently on some systems, but worked fine on other systems.
Additional Information After looking through the code I realized that the following line in libbb/procps.c was causing buf to sometimes contain garbage characters following the contents of /proc/ID/stat:

  n = read_to_buf(status, buf);

I don't know the details of the implmentation of strrchr, but the lack of a null terminator causes it to return 0 instead of the desired address:

  name = strrchr(buf, ')');

which causes this check to pass:

  if(name == 0 || name[1] != ' ')

making it skip the current entry; thus the function never returns > 0 and never increments ntop in the loop in top_main, causing top to bail out:

  while ((p = procps_scan(0)) != 0) {
      int n = ntop;
      
      top = xrealloc(top, (++ntop)*sizeof(procps_status_t));
          memcpy(top + n, p, sizeof(procps_status_t));
  }
  
  if (ntop == 0) {
      bb_error_msg_and_die("Can't find process info in /proc");
  }

Simple proposed fix attached.
Attached Files  procps.c.patch [^] (323 bytes) 06-16-06 14:23

- Relationships

- Notes
(0001428)
mnuss
06-16-06 14:32

Sorry, just to clarify, there was a mistake in my description of the issue. The call to strrchr isn't returning 0; it's returning the *wrong* address - one of the garbage characters at the end of the string must happen to be a closing parenthesis, so it's returning that index instead of the one we want. Which is why the next character isn't the expected space.
 
(0001462)
landley
06-27-06 11:15

svn 15532
 

- Issue History
Date Modified Username Field Change
06-16-06 14:23 mnuss New Issue
06-16-06 14:23 mnuss Status new => assigned
06-16-06 14:23 mnuss Assigned To  => BusyBox
06-16-06 14:23 mnuss File Added: procps.c.patch
06-16-06 14:25 mnuss Issue Monitored: mnuss
06-16-06 14:32 mnuss Note Added: 0001428
06-27-06 11:15 landley Status assigned => closed
06-27-06 11:15 landley Note Added: 0001462
06-27-06 11:15 landley Resolution open => fixed
06-27-06 11:15 landley Fixed in Version  => 1.2.x


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker