Bug 6422 - grep and segfault
Summary: grep and segfault
Status: RESOLVED INVALID
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.18.x
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-11 03:15 UTC by Arseniy
Modified: 2014-02-25 13:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
here is screenshot (17.95 KB, image/png)
2013-08-11 03:15 UTC, Arseniy
Details
busybox config file (23.17 KB, application/octet-stream)
2013-08-13 01:58 UTC, Arseniy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arseniy 2013-08-11 03:15:25 UTC
Created attachment 5006 [details]
here is screenshot

Hi, when try to use grep as: "grep -r "insmod" ." it sometimes crashes cause of segmentation fault. working path is /. busybox version is 1.18.4.
Comment 1 Denys Vlasenko 2013-08-12 00:42:41 UTC
(In reply to comment #0)
> Created attachment 5006 [details]
> here is screenshot
> 
> Hi, when try to use grep as: "grep -r "insmod" ." it sometimes crashes cause of
> segmentation fault. working path is /. busybox version is 1.18.4.

Try newer version.
Attach your .config file to this bug.
Run the command under strace and attach the log.
Comment 2 Arseniy 2013-08-13 01:58:42 UTC
Created attachment 5036 [details]
busybox config file
Comment 3 Arseniy 2013-08-13 02:02:18 UTC
http://pastebin.com/YNnyS95S
here is strace output
Comment 4 Denys Vlasenko 2013-08-14 22:13:11 UTC
The strace output you posted ends with:

...
lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("./proc/stclkrv_core", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
getdents64(0x5, 0x5b37a0, 0x8000, 0x800000) = 136
lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x29558000
read(6,  <unfinished ...>


IOW: there is no segfault in strace output. grep is just stuck trying to read some /proc file.
Comment 5 Arseniy 2013-08-15 01:50:49 UTC
(In reply to comment #4)
> The strace output you posted ends with:
> 
> ...
> lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> open("./proc/stclkrv_core",
> O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
> getdents64(0x5, 0x5b37a0, 0x8000, 0x800000) = 136
> lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
> fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x29558000
> read(6,  <unfinished ...>
> 
> 
> IOW: there is no segfault in strace output. grep is just stuck trying to read
> some /proc file.

it is sigsegv, because after last line read(6,  <unfinished ...> strace prints "killed by SISEGV", sorry, i didn't copy it earlier
Comment 6 Denys Vlasenko 2013-08-20 23:20:02 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > The strace output you posted ends with:
> > 
> > ...
> > lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> > open("./proc/stclkrv_core",
> > O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
> > getdents64(0x5, 0x5b37a0, 0x8000, 0x800000) = 136
> > lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> > open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
> > fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> > old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> > 0x29558000
> > read(6,  <unfinished ...>
> > 
> > 
> > IOW: there is no segfault in strace output. grep is just stuck trying to read
> > some /proc file.
> 
> it is sigsegv, because after last line read(6,  <unfinished ...> strace prints
> "killed by SISEGV", sorry, i didn't copy it earlier

This isn't how SIGSEGV is shown in strace output. It should look like this:

...
last_syscall(args)    = result
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_USER, si_pid=22713, si_uid=0} ---
+++ killed by SIGSEGV +++
Comment 7 Arseniy 2013-08-21 02:28:40 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > The strace output you posted ends with:
> > > 
> > > ...
> > > lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> > > open("./proc/stclkrv_core",
> > > O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
> > > getdents64(0x5, 0x5b37a0, 0x8000, 0x800000) = 136
> > > lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> > > open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
> > > fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> > > old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> > > 0x29558000
> > > read(6,  <unfinished ...>
> > > 
> > > 
> > > IOW: there is no segfault in strace output. grep is just stuck trying to read
> > > some /proc file.
> > 
> > it is sigsegv, because after last line read(6,  <unfinished ...> strace prints
> > "killed by SISEGV", sorry, i didn't copy it earlier
> 
> This isn't how SIGSEGV is shown in strace output. It should look like this:
> 
> ...
> last_syscall(args)    = result
> --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_USER, si_pid=22713, si_uid=0} ---
> +++ killed by SIGSEGV +++

Ok:
...
lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("./proc/stclkrv_core", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
getdents64(0x5, 0x5b3240, 0x8000, 0x800000) = 136
lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x29558000
read(6,  <unfinished ...>
+++ killed by SIGSEGV +++

So.. it means that there is bug in strace?:)
Comment 8 Denys Vlasenko 2013-08-21 06:07:09 UTC
(In reply to comment #7)
> > > it is sigsegv, because after last line read(6,  <unfinished ...> strace prints
> > > "killed by SISEGV", sorry, i didn't copy it earlier
> > 
> > This isn't how SIGSEGV is shown in strace output. It should look like this:
> > 
> > ...
> > last_syscall(args)    = result
> > --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_USER, si_pid=22713, si_uid=0} ---
> > +++ killed by SIGSEGV +++
> 
> Ok:
> ...
> lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> open("./proc/stclkrv_core",
> O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
> getdents64(0x5, 0x5b3240, 0x8000, 0x800000) = 136
> lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
> fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x29558000
> read(6,  <unfinished ...>
> +++ killed by SIGSEGV +++
> 
> So.. it means that there is bug in strace?:)

I doubt that the above is a valid strace output. SEGV can't kill processes *inside* syscalls. I know: I am one of strace developers.

Does "cat </proc/stclkrv_core/odf >/dev/null" work?
Comment 9 Arseniy 2013-08-22 02:16:29 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > > > it is sigsegv, because after last line read(6,  <unfinished ...> strace prints
> > > > "killed by SISEGV", sorry, i didn't copy it earlier
> > > 
> > > This isn't how SIGSEGV is shown in strace output. It should look like this:
> > > 
> > > ...
> > > last_syscall(args)    = result
> > > --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_USER, si_pid=22713, si_uid=0} ---
> > > +++ killed by SIGSEGV +++
> > 
> > Ok:
> > ...
> > lstat64("./proc/stclkrv_core", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> > open("./proc/stclkrv_core",
> > O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = 5
> > getdents64(0x5, 0x5b3240, 0x8000, 0x800000) = 136
> > lstat64("./proc/stclkrv_core/odf", {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> > open("./proc/stclkrv_core/odf", O_RDONLY|O_LARGEFILE) = 6
> > fstat64(6, {st_mode=S_IFREG|0444, st_size=37, ...}) = 0
> > old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> > 0x29558000
> > read(6,  <unfinished ...>
> > +++ killed by SIGSEGV +++
> > 
> > So.. it means that there is bug in strace?:)
> 
> I doubt that the above is a valid strace output. SEGV can't kill processes
> *inside* syscalls. I know: I am one of strace developers.
> 
> Does "cat </proc/stclkrv_core/odf >/dev/null" work?

Thank you, the reason was that this cat crashed with seg fault:)