[centos-users 1358] Re: phpで大量のメールを配信しようとするとたまに失敗します。

choice info @ choice-site.com
2010年 4月 27日 (火) 14:15:02 JST


中出です。

レス、ありがとうございます。


> > ですので、sendmailに渡す際、popenに失敗しているのかなぁと
> > 思います。
> 
>  write で EPIPE が発生しているので、popen が成功してから write するま
> での間に(つまり起動直後に)sendmail コマンドが終了してしまっているのか
> な、と思います。
> 

# sudo sh -c "strace -f php ./mailtest.php > trace.log 2>&1"

のようにして子プロセスのログもとってみたところ、
該当箇所のログは以下のような感じとなっていました。
Segmentation faultが出ているようです。
なぜ、Segmentation faultとなるのでしょう。


●ログ
clone(Process 18263 attached
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7f7c728) = 18263
[pid 18263] close(4)                    = 0
[pid 18263] dup2(3, 0)                  = 0
[pid 18263] close(3)                    = 0
[pid 18263] execve("/bin/sh", ["sh", "-c", "/usr/sbin/sendmail -t -i"], [/* 20 vars */]) = 0
[pid 18263] brk(0)                      = 0x935e000
[pid 18263] access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
[pid 18263] open("/etc/ld.so.cache", O_RDONLY) = 3
[pid 18263] fstat64(3, {st_mode=S_IFREG|0644, st_size=41901, ...}) = 0
[pid 18263] mmap2(NULL, 41901, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f97000
[pid 18263] close(3)                    = 0
[pid 18263] open("/lib/libtermcap.so.2", O_RDONLY) = 3
[pid 18263] read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\372\203\0004\0\0\0"..., 512) = 512
[pid 18263] fstat64(3, {st_mode=S_IFREG|0755, st_size=13084, ...}) = 0
[pid 18263] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f96000
[pid 18263] mmap2(0x83f000, 14568, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x83f000
[pid 18263] mmap2(0x842000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2) = 0x842000
[pid 18263] close(3)                    = 0
[pid 18263] open("/lib/libdl.so.2", O_RDONLY) = 3
[pid 18263] read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\32~\0004\0\0\0"..., 512) = 512
[pid 18263] fstat64(3, {st_mode=S_IFREG|0755, st_size=16428, ...}) = 0
[pid 18263] mmap2(0x7e1000, 12408, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7e1000
[pid 18263] mmap2(0x7e3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0x7e3000
[pid 18263] close(3)                    = 0
[pid 18263] open("/lib/libc.so.6", O_RDONLY) = 3
[pid 18263] read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340\357j\0004\0\0\0"..., 512) = 512
[pid 18263] fstat64(3, {st_mode=S_IFREG|0755, st_size=1611564, ...}) = 0
[pid 18263] mmap2(0x699000, 1332676, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x699000
[pid 18263] mprotect(0x7d8000, 4096, PROT_NONE) = 0
[pid 18263] mmap2(0x7d9000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13f) = 0x7d9000
[pid 18263] mmap2(0x7dc000, 9668, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7dc000
[pid 18263] close(3)                    = 0
[pid 18263] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f95000
[pid 18263] set_thread_area({entry_number:-1 -> 6, base_addr:0xb7f956c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
[pid 18263] mprotect(0x7e3000, 4096, PROT_READ) = 0
[pid 18263] mprotect(0x7d9000, 8192, PROT_READ) = 0
[pid 18263] mprotect(0x690000, 4096, PROT_READ) = 0
[pid 18263] munmap(0xb7f97000, 41901)   = 0
[pid 18263] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 18263] open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3
[pid 18263] close(3)                    = 0
[pid 18263] brk(0)                      = 0x935e000
[pid 18263] brk(0x937f000)              = 0x937f000
[pid 18263] open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
[pid 18263] fstat64(3, {st_mode=S_IFREG|0644, st_size=56450656, ...}) = 0
[pid 18263] mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7d95000
[pid 18263] mmap2(NULL, 962560, PROT_READ, MAP_PRIVATE, 3, 0x2e43) = 0xb7caa000
[pid 18263] close(3)                    = 0
[pid 18263] getuid32()                  = 0
[pid 18263] getgid32()                  = 0
[pid 18263] geteuid32()                 = 0
[pid 18263] getegid32()                 = 0
[pid 18263] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 18263] time(NULL)                  = 1272336853
[pid 18263] open("/proc/meminfo", O_RDONLY) = 3
[pid 18263] fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
[pid 18263] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ca9000
[pid 18263] read(3, "MemTotal:      2075284 kB\nMemFre"..., 4096) = 771
[pid 18263] close(3)                    = 0
[pid 18263] munmap(0xb7ca9000, 4096)    = 0
[pid 18263] rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 18263] rt_sigaction(SIGQUIT, {0x1, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] uname({sys="Linux", node="www.mail-hikaku.net", ...}) = 0
[pid 18263] stat64("/home/redadmin", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 18263] stat64(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 18263] getpid()                    = 18263
[pid 18263] open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
[pid 18263] fstat64(3, {st_mode=S_IFREG|0644, st_size=25462, ...}) = 0
[pid 18263] mmap2(NULL, 25462, PROT_READ, MAP_SHARED, 3, 0) = 0xb7ca3000
[pid 18263] close(3)                    = 0
[pid 18263] getppid()                   = 5905
[pid 18263] stat64(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 18263] stat64("/usr/bin/sh", 0xbff5c730) = -1 ENOENT (No such file or directory)
[pid 18263] stat64("/bin/sh", {st_mode=S_IFREG|0755, st_size=735004, ...}) = 0
[pid 18263] access("/bin/sh", X_OK)     = 0
[pid 18263] access("/bin/sh", R_OK)     = 0
[pid 18263] stat64("/bin/sh", {st_mode=S_IFREG|0755, st_size=735004, ...}) = 0
[pid 18263] access("/bin/sh", X_OK)     = 0
[pid 18263] access("/bin/sh", R_OK)     = 0
[pid 18263] getpgrp()                   = 5903
[pid 18263] rt_sigaction(SIGCHLD, {0x807aa60, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 18263] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 18263] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 18263] rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, {0x1, [], 0}, 8) = 0
[pid 18263] rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, {0x807aa60, [], 0}, 8) = 0
[pid 18263] execve("/usr/sbin/sendmail", ["/usr/sbin/sendmail", "-t", "-i"], [/* 20 vars */]) = -1 EINVAL (Invalid argument)
[pid 18263] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
Process 18263 detached
<... waitpid resumed> [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV}], 0) = 18263
--- SIGCHLD (Child exited) @ 0 (0) ---
munmap(0xb7c90000, 4096)                = 0
write(1, "PHP>>> cnt : 3052 ret : \n", 25PHP>>> cnt : 3052 ret : 
) = 25
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({1, 0}, {1, 0})               = 0


では、失礼します。
----



centos-users メーリングリストの案内