|
FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
Segmentation fault
hi
why using freecolor -o on my freeBSD 7.0 , I get Segmentation fault ? Code:
bsd# freecolor -o total used free shared buffers cached Mem: 509852 175180 334672 0 0 268 Swap: 2048000 0 2048000 Segmentation fault |
|
|||
thx, but could you pls give some more details, how this should work ?
Last edited by ccc; 25th June 2008 at 12:07 AM. |
|
|||
I've done:
Code:
# echo 'WITH_DEBUG=yes' >> /etc/make.conf # cd /usr/ports/sysutils/freecolor # make deinstall clean # make install clean Code:
# freecolor -o total used free shared buffers cached Mem: 509852 168140 341712 0 0 360 Swap: 2048000 0 2048000 # should I leave WITH_DEBUG=yes in /etc/make.conf ? |
|
|||
Leaving WITH_DEBUG in will just compile the ports with debugging info. As a user you're generally not going to need it (i.e. a waste of your time)
10 to 1, it was the reinstall of freecolor that fixed it, not that you compiled it with WITH_DEBUG. |
|
||||
No, if I compile it without debug I have the same error, when I use WITH_DEBUG it works fine...
Not sure what's going on here ... I'll look tomorrow...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. |
|
|||
That is odd. I don't use freecolor myself so I didn't actually check.
|
|
||||
Ah, the ever-unpopular heisenbug.
When I had one of them, it turned out to be an uninitialized variable. Building it with debug zeroed off the variable, and things worked. Mind you, that was my own code, and own mistake. Best of luck tracking it down!
__________________
The only dumb question is a question not asked. The only dumb answer is an answer not given. |
|
||||
think i found the bug.
it triggers a segfault only when compiled with optimization enabled (-DWITH_DEBUG switches off optimization). the bug causes the return address from main to be corrupted resulting in a segfault, here's a patch, put this in /usr/ports/sysutils/freecolor/files/patch-freecolor.c: Code:
--- freecolor.c.bak 2005-10-19 01:39:52.000000000 +0530 +++ freecolor.c 2008-06-28 19:16:13.000000000 +0530 @@ -62,9 +62,6 @@ #include <unistd.h> #include <stdlib.h> #include <stdio.h> -#ifndef NO_GETOPT -#include <getopt.h> -#endif #define BARLEN 35 #define HEADERLEN 14 #define VERSION "0.8.7" @@ -76,9 +73,9 @@ void bargraph(float percent, float secondper, char marks[BARLEN+HEADERLEN],int usefull) { char percentone[BARLEN], percenttwo[BARLEN], remain[BARLEN]; unsigned int numberofmarks, numofmarkstwo, remainnum; - numberofmarks=(int) ((float) (BARLEN*(percent/100))); - if (!usefull) numofmarkstwo=(int) ((float) (BARLEN*(secondper/100))); else numofmarkstwo=(BARLEN-numberofmarks); - remainnum=BARLEN-(numberofmarks+numofmarkstwo); + numberofmarks=(int) ((float) ((BARLEN-1)*(percent/100))); + if (!usefull) numofmarkstwo=(int) ((float) ((BARLEN-1)*(secondper/100))); else numofmarkstwo=((BARLEN-1)-numberofmarks); + remainnum=(BARLEN-1)-(numberofmarks+numofmarkstwo); memset(percentone, '#', numberofmarks); memset(percenttwo, '%', numofmarkstwo); memset(remain, '.', remainnum); Last edited by ephemera; 28th June 2008 at 02:20 PM. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Segmentation fault error139 | delboy | FreeBSD Ports and Packages | 8 | 9th July 2009 06:32 PM |
page fault error 12 | Mr-Biscuit | FreeBSD General | 2 | 23rd December 2008 11:58 AM |
MYSQL 's fault? | disappearedng | FreeBSD General | 3 | 14th October 2008 11:53 PM |
Segmentation fault (11) - Apache | ijk | FreeBSD Ports and Packages | 16 | 15th July 2008 11:04 AM |
MySQL C library - segmentation fault on mysql_select_db() when using CC optimisation | gor | OpenBSD Packages and Ports | 7 | 10th June 2008 11:42 PM |