DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 24th June 2008
ccc ccc is offline
Shell Scout
 
Join Date: May 2008
Posts: 97
Thanked 0 Times in 1 Post
Default 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
Reply With Quote
  #2   (View Single Post)  
Old 24th June 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,051
Thanked 198 Times in 156 Posts
Default

Works fine for me (7 STABLE Jun 5).

Try rebuilding the port with -DWITH_DEBUG and running it with gdb.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #3   (View Single Post)  
Old 24th June 2008
ccc ccc is offline
Shell Scout
 
Join Date: May 2008
Posts: 97
Thanked 0 Times in 1 Post
Default

Quote:
Originally Posted by Carpetsmoker View Post
Works fine for me (7 STABLE Jun 5).

Try rebuilding the port with -DWITH_DEBUG and running it with gdb.
thx, but could you pls give some more details, how this should work ?

Last edited by ccc; 25th June 2008 at 12:07 AM.
Reply With Quote
  #4   (View Single Post)  
Old 25th June 2008
ccc ccc is offline
Shell Scout
 
Join Date: May 2008
Posts: 97
Thanked 0 Times in 1 Post
Default

I've done:
Code:
# echo 'WITH_DEBUG=yes' >> /etc/make.conf
# cd /usr/ports/sysutils/freecolor
# make deinstall clean
# make install clean
and Segmentation fault is gone:
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 ?
Reply With Quote
  #5   (View Single Post)  
Old 25th June 2008
Nirbo Nirbo is offline
Real Name: Nicholas Kirby
Fdisk Soldier
 
Join Date: May 2008
Location: Edmonton, Alberta, Canada
Posts: 68
Thanked 11 Times in 9 Posts
Default

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.
Reply With Quote
  #6   (View Single Post)  
Old 25th June 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,051
Thanked 198 Times in 156 Posts
Default

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.
Reply With Quote
  #7   (View Single Post)  
Old 25th June 2008
Nirbo Nirbo is offline
Real Name: Nicholas Kirby
Fdisk Soldier
 
Join Date: May 2008
Location: Edmonton, Alberta, Canada
Posts: 68
Thanked 11 Times in 9 Posts
Default

That is odd. I don't use freecolor myself so I didn't actually check.
Reply With Quote
  #8   (View Single Post)  
Old 25th June 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Thanked 40 Times in 39 Posts
Default

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.
Reply With Quote
  #9   (View Single Post)  
Old 28th June 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 08:00 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick