[vox-tech] Mystery Segmentation Faults: grep and sed

Peter Jay Salzman p at dirac.org
Tue Dec 28 11:10:25 PST 2004


On Tue 28 Dec 04, 11:59 AM, Dylan Beaudette <dylan at iici.no-ip.org> said:
> Good morning!
> 
> Last night all was well with my G4 powerbook, even after a rather large
> number of updates from and apt-get update && apt-get upgrade.
> 
> However, this morning, I noticed some strange segmentation faults when the
> machine was starting. They all seemed to be happening after a sed command
> was issued. I tried manually using sed and grep, and both now seem to be
> giving segementation faults!
> 
> here is a quick example with the output of strace included:
> 
> --------------------snip----------------------
> dylan at pbg4:~$ echo "food" | grep -i food
> Segmentation fault
> 
> dylan at pbg4:~$ strace echo "food" | grep -i food
> execve("/bin/echo", ["echo", "food"], [/* 27 vars */]) = 0
> uname({sys="Linux", node="pbg4", ...})  = 0
> brk(0)                                  = 0x10013680
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x30016000
> 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
> fstat64(3, {st_mode=S_IFREG|0644, st_size=72216, ...}) = 0
> mmap(NULL, 72216, PROT_READ, MAP_PRIVATE, 3, 0) = 0x30027000
> 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\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\322"...,
> 512) = 512
> fstat64(3, {st_mode=S_IFREG|0644, st_size=1298544, ...}) = 0
> mmap(0xfea1000, 1370024, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xfea1000
> mprotect(0xffd3000, 116648, PROT_NONE)  = 0
> mmap(0xffe1000, 49152, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_FIXED, 3, 0x130000) = 0xffe1000
> mmap(0xffed000, 10152, PROT_READ|PROT_WRITE|PROT_EXEC,
> MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffed000
> close(3)                                = 0
> munmap(0x30027000, 72216)               = 0
> brk(0)                                  = 0x10013680
> brk(0x10034680)                         = 0x10034680
> brk(0)                                  = 0x10034680
> brk(0x10035000)                         = 0x10035000
> open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=3202928, ...}) = 0
> mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0x30027000
> close(3)                                = 0
> fstat64(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x30017000
> write(1, "food\n", 5)                   = -1 EPIPE (Broken pipe)
> --- SIGPIPE (Broken pipe) @ 0 (0) ---
> +++ killed by SIGPIPE +++
> Segmentation fault
> -----------------------snip-----------------------
 
Hi Dylan,

I don't believe this isn't the actual segfault.  I think you want to do:

   strace -ff -s"99" foo | bar

What you show here is simply writing to a pipe.  The pipe broke because the
thing on the other end segfaulted (I *think*).  This shows echo.  You want
to show grep.  Again, "I think".  ;)

What kernel are you running?  Someone on the Opera Linux mailing list
complained of strange segfaults after upgrading his kernel.  Sounds a tad
similar.  I don't recall his kernel version, but I believe it was 2.6.8 and
he said that it also happens with 2.6.9 (I'm sure the Opera launcher, a
shell script, uses sed and/or grep among other things).  Come to think of
it, he was also a Debian user.

Hmmmmm.......

> can anyone make any sense of all of this? for some reason my sed and grep
> broke between yesterday night and this morning.... and i imagine that it
> had something to do with the update last night.
> 
> any ideas would be greatly appreciated!
 
If you can stomach the traffic, debian-user is, IMHO the best general
technical mailing list on the net.  In its heyday, I thought vox-tech was
nearly as good (but I'm biased...)  :)

Pete

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's "Fearful Symmetry"

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D


More information about the vox-tech mailing list