htop-osx icon indicating copy to clipboard operation
htop-osx copied to clipboard

htop quits unexpectedly after SortBy (with workaround)

Open kfigiela opened this issue 15 years ago • 7 comments

Just after pressing F6 (SortBy) command htop quits printing following to the console: "htop 0.8.2.1 aborted. Please report bug at http://htop.sf.net". This happens with self-built htop from Git source as well as with the one that comes from MacPorts.

There's a workaround, after starting htop open "Kill" menu, and then cancel. After this, sort works fine.

kfigiela avatar Dec 30 '09 10:12 kfigiela

The fuFunctions array for the Sort Screen's FunctionBar is not ended with a NULL Pointer, thus strdup reads from invalid address when creating this FunctionBar. The following patch (unified diff) adds a NULL Pointer to the two fuFunctions arrays in htop.c not ending in an NULL pointer:

--- htop.c.orig 2010-01-13 18:04:07.000000000 +0100 +++ htop.c 2010-01-13 15:29:55.000000000 +0100 @@ -651,7 +651,7 @@

      Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
  •     char\* fuFunctions[2] = {"Set    ", "Cancel "};
    
  •     char\* fuFunctions[] = {"Set    ", "Cancel ", NULL};
      void\* set = pickFromVector(panel, affinityPanel, 15, headerHeight, fuFunctions, defaultBar);
      if (set) {
         unsigned long new = AffinityPanel_getAffinity(affinityPanel);
    
    @@ -690,7 +690,7 @@ { Panel* sortPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true, ListItem_compare); Panel_setHeader(sortPanel, "Sort by");
  •     char\* fuFunctions[2] = {"Sort  ", "Cancel "};
    
  •     char\* fuFunctions[] = {"Sort  ", "Cancel ", NULL};
      ProcessField\* fields = pl->fields;
      for (int i = 0; fields[i]; i++) {
         char\* name = String_trim(Process_fieldTitles[fields[i]]);
    

xyb3rt avatar Jan 13 '10 17:01 xyb3rt

Sorry, I forgot the

 tags!
--- htop.c.orig 2010-01-13 18:04:07.000000000 +0100
+++ htop.c  2010-01-13 15:29:55.000000000 +0100
@@ -651,7 +651,7 @@
          
          Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
 
-         char* fuFunctions[2] = {"Set    ", "Cancel "};
+         char* fuFunctions[] = {"Set    ", "Cancel ", NULL};
          void* set = pickFromVector(panel, affinityPanel, 15, headerHeight, fuFunctions, defaultBar);
          if (set) {
             unsigned long new = AffinityPanel_getAffinity(affinityPanel);
@@ -690,7 +690,7 @@
       {
          Panel* sortPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true, ListItem_compare);
          Panel_setHeader(sortPanel, "Sort by");
-         char* fuFunctions[2] = {"Sort  ", "Cancel "};
+         char* fuFunctions[] = {"Sort  ", "Cancel ", NULL};
          ProcessField* fields = pl->fields;
          for (int i = 0; fields[i]; i++) {
             char* name = String_trim(Process_fieldTitles[fields[i]]);

xyb3rt avatar Jan 13 '10 17:01 xyb3rt

AndyA can you add this patch to your repo?

bitboxer avatar Apr 05 '10 10:04 bitboxer

how can I apply that patch to my copy?

andyzweb avatar Apr 08 '11 00:04 andyzweb

Something like: `patch -u < FILE'. See the patch man-page for more details.

xyb3rt avatar Apr 08 '11 10:04 xyb3rt

I can confirm that applying this patch worked for me. Thanks!

xavierlacot avatar Jul 04 '11 20:07 xavierlacot

See my recent comment/pull request for the applied patch. Hopefully AndyA will accept it since I like htop on osx and this was the one bug that was buggin' me. :)

stepchud avatar Jul 12 '11 16:07 stepchud