bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] valgrind finds uninitialised bytes in readline


From: Rasmus Villemoes
Subject: Re: [Bug-readline] valgrind finds uninitialised bytes in readline
Date: Tue, 11 Sep 2012 18:48:21 +0000
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Chet Ramey <address@hidden> writes:

> On 1/30/12 4:41 AM, Jeremy Hall wrote:
>> Hi
>> 
>> readline 6.2
>> 
>> This is after a single call to readline()
>> 
>> ==5441== Syscall param socketcall.sendmsg(msg.msg_name) points to
>> uninitialised byte(s)
>> ==5441==    at 0x41E1FA1: sendmsg (socket.S:64)
>> ==5441==    by 0x40C0E1C: readline (readline.c:346)
>
> That's interesting.  Readline doesn't call sendmsg().

I see the same thing. RHEL 6.3, glibc 2.12, readline 6.0. 

$ cat rlsm.c 
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>

int main(void) {
  char *line;
  while ((line = readline("type stuff: ")) != NULL) {
    printf("You wrote '%s'\n", line);
    free(line);
  }
  return 0;
}

$ gcc -o rlsm rlsm.c -lreadline
$ strace -e trace=desc,network,file -o rlsm.strace ./rlsm
type stuff: 
You wrote ''
type stuff: 
You wrote ''
type stuff: <C-d>
$ grep -C5 sendmsg rlsm.strace
write(1, "type stuff: ", 12)            = 12
read(0, "\r", 1)                        = 1
write(1, "\n", 1)                       = 1
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
socket(PF_NETLINK, SOCK_RAW, 9)         = 3
sendmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, 
msg_iov(2)=[{"\21\0\0\0d\4\1\0\0\0\0\0\0\0\0\0", 16}, {"\0", 1}], 
msg_controllen=0, msg_flags=0}, 0) = 17
close(3)                                = 0
ioctl(0, TIOCGWINSZ, {ws_row=33, ws_col=127, ws_xpixel=1162, ws_ypixel=499}) = 0
ioctl(0, TIOCSWINSZ, {ws_row=33, ws_col=127, ws_xpixel=1162, ws_ypixel=499}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig -icanon -echo ...}) = 0


As you say, readline does not call sendmsg(), so readline is obviously
not the problem. The socket()/sendmsg() calls disappear when I download 
readline 6.0
(or 6.1), compile it and link statically against it. On my ubuntu
machine (which has readline 6.1), the socket()/sendmsg() calls do not
appear at all. I tried using gdb to catch the sendmsg system call and
give me a stack trace, but the necessary debugging symbols are
missing, so it appeared as in the valgrind output above.

-- 
Rasmus Villemoes
<http://rasmusvillemoes.dk/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]