Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htop quits unexpectedly after SortBy (with workaround) #2

Open
kfigiela opened this issue Dec 30, 2009 · 7 comments
Open

htop quits unexpectedly after SortBy (with workaround) #2

kfigiela opened this issue Dec 30, 2009 · 7 comments

Comments

@kfigiela
Copy link

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.

@xyb3rt
Copy link

xyb3rt commented Jan 13, 2010

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
Copy link

xyb3rt commented Jan 13, 2010

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]]);

@bitboxer
Copy link

bitboxer commented Apr 5, 2010

AndyA can you add this patch to your repo?

@andyzweb
Copy link

andyzweb commented Apr 8, 2011

how can I apply that patch to my copy?

@xyb3rt
Copy link

xyb3rt commented Apr 8, 2011

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

@xavierlacot
Copy link

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

@stepchud
Copy link

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants