Re: ud segfault

2004-12-12 Thread David Liontooth
Steve McIntyre wrote:
OK, so I'm bored. I've just looked at the bug and found the
problem. ud's source is quite ugly, suggesting a novice author. I can
recreate the bug quite readily here, and it's crashing down below a
sprintf() call:
(gdb) bt
#0  0x002a956e9980 in strlen () from /lib/libc.so.6
#1  0x002a956b7c75 in vfprintf () from /lib/libc.so.6
#2  0x002a956d6ec5 in vsprintf () from /lib/libc.so.6
#3  0x002a956be50a in sprintf () from /lib/libc.so.6
#4  0x00401340 in get_kernel_version (kernel_version=0x7fb544 "running 
Linux 2.6.9", IsCurrent=0) at ud.c:150
#5  0x004020c5 in main (argc=1, argv=0x7fb540) at ud.c:822
The reason for this becomes clear once you turn on warnings in the
compilation:
gcc -DPACKAGE=\"ud\" -DVERSION=\"0.7.1\" -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 
-DRETSIGTYPE=void -DHAVE_GETHOSTNAME=1  -I. -I.  -g -O2 -Wall -W -c ud.c
ud.c: In function `get_kernel_version':
ud.c:150: warning: implicit declaration of function `ctime'
ud.c:150: warning: format argument is not a pointer (arg 3)
ctime is returning a pointer rather than an int. Simply adding
"#include " to the top of the ud.c source file fixes this
bug. Prototypes are there for a reason!
Turning on warnings also highlights other silly coding bugs, but I'll
leave those for other people.
 

Cool.  Praised be boredom. And thanks for submitting this to the bug report!
Cheers,
Dave



Re: Bug#271758: ud segfault (was: When will the amd64 port be stable?)

2004-12-12 Thread Steve Kemp
On Sun, Dec 12, 2004 at 05:18:37AM +, Steve McIntyre wrote:
> David Liontooth <[EMAIL PROTECTED]> wrote:
> >Goswin von Brederlow wrote:
> >>
> >>And now the same with -f please. I didn't see a segfault in the starce
> >>and it is probably its child that dies.
> >>
> >>You can also compile the ud with debug infos and run it in gdb.
> >>
> >>MfG
> >>Goswin
> >>  
> >>
> >Hi Goswin,
> >
> >So this is not behavior others are seeing? 
> >I have the pleasure of sending you a thousand EBADF reports below -- 
> >you're likely only interested in the last few lines:
> 
> OK, so I'm bored. I've just looked at the bug and found the
> problem. ud's source is quite ugly, suggesting a novice author. I can
> recreate the bug quite readily here, and it's crashing down below a
> sprintf() call:
> 
> (gdb) bt
> #0  0x002a956e9980 in strlen () from /lib/libc.so.6
> #1  0x002a956b7c75 in vfprintf () from /lib/libc.so.6
> #2  0x002a956d6ec5 in vsprintf () from /lib/libc.so.6
> #3  0x002a956be50a in sprintf () from /lib/libc.so.6
> #4  0x00401340 in get_kernel_version (kernel_version=0x7fb544 
> "running Linux 2.6.9", IsCurrent=0) at ud.c:150
> #5  0x004020c5 in main (argc=1, argv=0x7fb540) at ud.c:822
> 
> The reason for this becomes clear once you turn on warnings in the
> compilation:
> 
> gcc -DPACKAGE=\"ud\" -DVERSION=\"0.7.1\" -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 
> -DRETSIGTYPE=void -DHAVE_GETHOSTNAME=1  -I. -I.  -g -O2 -Wall -W -c ud.c
> ud.c: In function `get_kernel_version':
> ud.c:150: warning: implicit declaration of function `ctime'
> ud.c:150: warning: format argument is not a pointer (arg 3)
> 
> ctime is returning a pointer rather than an int. Simply adding
> "#include " to the top of the ud.c source file fixes this
> bug. Prototypes are there for a reason!
> 
> Turning on warnings also highlights other silly coding bugs, but I'll
> leave those for other people.

  Cheers for that, I will prepare an upload to close all the warnings.

Steve
--
# The Debian Security Audit Project.
http://www.debian.org/security/audit




Re: ud segfault (was: When will the amd64 port be stable?)

2004-12-12 Thread Ron Johnson
On Sun, 2004-12-12 at 12:39 +, Steve McIntyre wrote:
> [EMAIL PROTECTED] wrote:
> >On Sun, 2004-12-12 at 05:18 +, Steve McIntyre wrote:
[snip]
> >> Turning on warnings also highlights other silly coding bugs, but I'll
> >> leave those for other people.
> >
> >Hey, let's start a flame war about the unnecessary use of C in
> >non-core functionality!!!
> 
> I agree with you, actually. ud is a perfect example of an app where C
> is very much the Wrong Thing. From scanning the source, I'd replace it
> with a small shell/perl/python script running out cron if I cared
> enough for what it does...

At one time, back in my Mandrake days, I had such a python script,
that got daemonized at boot.  Then, every 5 seconds, it updated a
record file.  If you ran it in --client mode, it dumped the 
record of uptimes, by either date or longest uptime.

Got lost in the conversion to Debian, back before Woody, though.

-- 
-
Ron Johnson, Jr.
Jefferson, LA USA
PGP Key ID 8834C06B I prefer encrypted mail.

"But a much bigger business is selling anti-spam software. This
is a billion dollar market, and it is rapidly growing. Any simple
and effective solution against spam would defeat revenues and
drive several companies into bankrupt, would make consultants
jobless. ... Have a single, simple, and permanent solution to the
problem and - boom - this billion dollar market is dead. That's
one of the reasons why people are expected to live with spam.
They have to live with it to make them buy anti-spam software.
Content filters are perfect products to keep this market alive."
Hadmut Danisch



signature.asc
Description: This is a digitally signed message part


Re: ud segfault (was: When will the amd64 port be stable?)

2004-12-12 Thread Steve McIntyre
[EMAIL PROTECTED] wrote:
>On Sun, 2004-12-12 at 05:18 +, Steve McIntyre wrote:
>> 
>> The reason for this becomes clear once you turn on warnings in the
>> compilation:
>> 
>> gcc -DPACKAGE=\"ud\" -DVERSION=\"0.7.1\" -DSTDC_HEADERS=1
>-DHAVE_UNISTD_H=1 -DRETSIGTYPE=void -DHAVE_GETHOSTNAME=1  -I. -I. 
>-g -O2 -Wall -W -c ud.c
>> ud.c: In function `get_kernel_version':
>> ud.c:150: warning: implicit declaration of function `ctime'
>> ud.c:150: warning: format argument is not a pointer (arg 3)
>> 
>> ctime is returning a pointer rather than an int. Simply adding
>> "#include " to the top of the ud.c source file fixes this
>> bug. Prototypes are there for a reason!
>> 
>> Turning on warnings also highlights other silly coding bugs, but I'll
>> leave those for other people.
>
>Hey, let's start a flame war about the unnecessary use of C in
>non-core functionality!!!

I agree with you, actually. ud is a perfect example of an app where C
is very much the Wrong Thing. From scanning the source, I'd replace it
with a small shell/perl/python script running out cron if I cared
enough for what it does...

-- 
Steve McIntyre, Cambridge, UK.[EMAIL PROTECTED]
We don't need no education.
We don't need no thought control.




Re: ud segfault (was: When will the amd64 port be stable?)

2004-12-12 Thread Ron Johnson
On Sun, 2004-12-12 at 05:18 +, Steve McIntyre wrote:
> David Liontooth <[EMAIL PROTECTED]> wrote:
> >Goswin von Brederlow wrote:
[snip]
> 
> The reason for this becomes clear once you turn on warnings in the
> compilation:
> 
> gcc -DPACKAGE=\"ud\" -DVERSION=\"0.7.1\" -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 
> -DRETSIGTYPE=void -DHAVE_GETHOSTNAME=1  -I. -I.  -g -O2 -Wall -W -c ud.c
> ud.c: In function `get_kernel_version':
> ud.c:150: warning: implicit declaration of function `ctime'
> ud.c:150: warning: format argument is not a pointer (arg 3)
> 
> ctime is returning a pointer rather than an int. Simply adding
> "#include " to the top of the ud.c source file fixes this
> bug. Prototypes are there for a reason!
> 
> Turning on warnings also highlights other silly coding bugs, but I'll
> leave those for other people.

Hey, let's start a flame war about the unnecessary use of C in
non-core functionality!!!

-- 
-
Ron Johnson, Jr.
Jefferson, LA USA
PGP Key ID 8834C06B I prefer encrypted mail.

"Adventure is a sign of incompetence"
Stephanson, great polar explorer



signature.asc
Description: This is a digitally signed message part


Re: ud segfault (was: When will the amd64 port be stable?)

2004-12-11 Thread Steve McIntyre
David Liontooth <[EMAIL PROTECTED]> wrote:
>Goswin von Brederlow wrote:
>>
>>And now the same with -f please. I didn't see a segfault in the starce
>>and it is probably its child that dies.
>>
>>You can also compile the ud with debug infos and run it in gdb.
>>
>>MfG
>>Goswin
>>  
>>
>Hi Goswin,
>
>So this is not behavior others are seeing? 
>I have the pleasure of sending you a thousand EBADF reports below -- 
>you're likely only interested in the last few lines:

OK, so I'm bored. I've just looked at the bug and found the
problem. ud's source is quite ugly, suggesting a novice author. I can
recreate the bug quite readily here, and it's crashing down below a
sprintf() call:

(gdb) bt
#0  0x002a956e9980 in strlen () from /lib/libc.so.6
#1  0x002a956b7c75 in vfprintf () from /lib/libc.so.6
#2  0x002a956d6ec5 in vsprintf () from /lib/libc.so.6
#3  0x002a956be50a in sprintf () from /lib/libc.so.6
#4  0x00401340 in get_kernel_version (kernel_version=0x7fb544 
"running Linux 2.6.9", IsCurrent=0) at ud.c:150
#5  0x004020c5 in main (argc=1, argv=0x7fb540) at ud.c:822

The reason for this becomes clear once you turn on warnings in the
compilation:

gcc -DPACKAGE=\"ud\" -DVERSION=\"0.7.1\" -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 
-DRETSIGTYPE=void -DHAVE_GETHOSTNAME=1  -I. -I.  -g -O2 -Wall -W -c ud.c
ud.c: In function `get_kernel_version':
ud.c:150: warning: implicit declaration of function `ctime'
ud.c:150: warning: format argument is not a pointer (arg 3)

ctime is returning a pointer rather than an int. Simply adding
"#include " to the top of the ud.c source file fixes this
bug. Prototypes are there for a reason!

Turning on warnings also highlights other silly coding bugs, but I'll
leave those for other people.

-- 
Steve McIntyre, Cambridge, UK.[EMAIL PROTECTED]
There's no sensation to compare with this
Suspended animation, A state of bliss




Re: ud segfault

2004-12-11 Thread Goswin von Brederlow
David Liontooth <[EMAIL PROTECTED]> writes:

> Hi Goswin,
>
> So this is not behavior others are seeing? I have the pleasure of sending you 
> a thousand EBADF reports below -- 

I have no clue. I don't have ud installed and know of noone having it
running. I'm just trying to guide you to finding the problem.

> you're likely only interested in the last few lines:
>
> chdir("/")  = 0
> umask(0)= 022
> ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fb6d0) = -1 EBADF (Bad
> file descriptor)
> open("/etc/localtime", O_RDONLY)= 0
> fstat(0, {st_mode=S_IFREG|0644, st_size=1017, ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0x2a9556b000
> read(0, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0"...,
> 4096) = 1017
> close(0)= 0
> munmap(0x2a9556b000, 4096)  = 0
> getpid()= 11304
> rt_sigaction(SIGPIPE, {0x2a9573b170, [], 0x400}, {SIG_DFL}, 8) = 0
> socket(PF_FILE, SOCK_DGRAM, 0)  = 0
> fcntl(0, F_SETFD, FD_CLOEXEC)   = 0
> connect(0, {sa_family=AF_FILE, path="/dev/log"}, 16) = 0
> sendto(0, "<30>Dec 11 19:34:31 ud[11304]: U"..., 56, 0, NULL, 0) = 56
> rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
> close(0)= 0
> getpid()= 11304
> open("/var/run/ud.pid", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 0
> chmod("/var/run/ud.pid", 0644)  = 0
> fstat(0, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0x2a9556b000
> write(0, "11304\n", 6)  = 6
> close(0)= 0
> munmap(0x2a9556b000, 4096)  = 0
> open("/var/lib/misc/uptime.record", O_RDONLY) = 0
> chmod("/var/lib/misc/uptime.record", 0644) = 0
> fstat(0, {st_mode=S_IFREG|0644, st_size=36, ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0x2a9556b000
> read(0, "0.7.1\n0.00\n\n0.00\n\n0."..., 4096) = 36
> close(0)= 0
> munmap(0x2a9556b000, 4096)  = 0
> open("/proc/uptime", O_RDONLY)  = 0
> fstat(0, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
> 0) = 0x2a9556b000
> read(0, "97472.40 97151.76\n", 1024)= 18
> close(0)= 0
> munmap(0x2a9556b000, 4096)  = 0
> uname({sys="Linux", node="clitunno", ...}) = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> Process 11304 detached
>
> Cheers,
> Dave

As expected nothing shows up as being wrong. You do have to run ud in
gdb and find out where in ud it segfaults.

MfG
Goswin




ud segfault (was: When will the amd64 port be stable?)

2004-12-11 Thread David Liontooth
Goswin von Brederlow wrote:
David Liontooth <[EMAIL PROTECTED]> writes:
 

Dec 11 12:59:13 clitunno ud[6280]: Uptime daemon starting...
Dec 11 12:59:13 clitunno kernel: ud[6280]: segfault at
958a7d00 rip 002a956e9980 rsp 007fbfffecb8 error 4
The daemon really does stop running, every time I try to start
it. Anything else I can try? Strace below.
Cheers,
Dave
# strace ud
   

And now the same with -f please. I didn't see a segfault in the starce
and it is probably its child that dies.
You can also compile the ud with debug infos and run it in gdb.
MfG
   Goswin
 

Hi Goswin,
So this is not behavior others are seeing? 
I have the pleasure of sending you a thousand EBADF reports below -- 
you're likely only interested in the last few lines:

chdir("/")  = 0
umask(0)= 022
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fb6d0) = -1 EBADF (Bad 
file descriptor)
open("/etc/localtime", O_RDONLY)= 0
fstat(0, {st_mode=S_IFREG|0644, st_size=1017, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2a9556b000
read(0, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0"..., 
4096) = 1017
close(0)= 0
munmap(0x2a9556b000, 4096)  = 0
getpid()= 11304
rt_sigaction(SIGPIPE, {0x2a9573b170, [], 0x400}, {SIG_DFL}, 8) = 0
socket(PF_FILE, SOCK_DGRAM, 0)  = 0
fcntl(0, F_SETFD, FD_CLOEXEC)   = 0
connect(0, {sa_family=AF_FILE, path="/dev/log"}, 16) = 0
sendto(0, "<30>Dec 11 19:34:31 ud[11304]: U"..., 56, 0, NULL, 0) = 56
rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
close(0)= 0
getpid()= 11304
open("/var/run/ud.pid", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 0
chmod("/var/run/ud.pid", 0644)  = 0
fstat(0, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2a9556b000
write(0, "11304\n", 6)  = 6
close(0)= 0
munmap(0x2a9556b000, 4096)  = 0
open("/var/lib/misc/uptime.record", O_RDONLY) = 0
chmod("/var/lib/misc/uptime.record", 0644) = 0
fstat(0, {st_mode=S_IFREG|0644, st_size=36, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2a9556b000
read(0, "0.7.1\n0.00\n\n0.00\n\n0."..., 4096) = 36
close(0)= 0
munmap(0x2a9556b000, 4096)  = 0
open("/proc/uptime", O_RDONLY)  = 0
fstat(0, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2a9556b000
read(0, "97472.40 97151.76\n", 1024)= 18
close(0)= 0
munmap(0x2a9556b000, 4096)  = 0
uname({sys="Linux", node="clitunno", ...}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
Process 11304 detached

Cheers,
Dave
# strace -f ud
execve("/usr/bin/ud", ["ud"], [/* 15 vars */]) = 0
uname({sys="Linux", node="clitunno", ...}) = 0
brk(0)  = 0x504000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2a9556a000
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.preload", O_RDONLY)= -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.cache", O_RDONLY)  = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=104400, ...}) = 0
mmap(NULL, 104400, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2a9556b000
close(3)= 0
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or 
directory)
open("/lib/libc.so.6", O_RDONLY)= 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\324\1\0"..., 
640) = 640
fstat(3, {st_mode=S_IFREG|0644, st_size=1294400, ...}) = 0
mmap(NULL, 2353800, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2a9566c000
mprotect(0x2a9578e000, 1165960, PROT_NONE) = 0
mmap(0x2a9586c000, 241664, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 
3, 0x10) = 0x2a9586c000
mmap(0x2a958a7000, 14984, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2a958a7000
close(3)= 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x2a958ab000
arch_prctl(0x1002, 0x2a958ab520)= 0
munmap(0x2a9556b000, 104400)= 0
rt_sigaction(SIGINT, {0x401af0, [INT], SA_RESTART|0x400}, {SIG_DFL}, 
8) = 0
rt_sigaction(SIGHUP, {0x401af0, [HUP], SA_RESTART|0x400}, {SIG_DFL}, 
8) = 0
rt_sigaction(SIGQUIT, {0x401af0, [QUIT], SA_RESTART|0x400}, 
{SIG_DFL}, 8) = 0
rt_sigaction(SIGTERM, {0x401af0, [TERM], SA_RESTART|0x400}, 
{SIG_DFL}, 8) = 0
umask(022)  = 022
brk(0)  = 0x504000
brk(0x525000)   = 0x525000
brk(0)  = 0x525000
open("/proc/uptime", O_RDONLY)