简体   繁体   English

子进程在退出功能上出现段错误

[英]Child processes gives seg fault on exit function

My environment: 我的环境:

  • FreeBSD 9.1 and I got a pre-forked multi-process environment. FreeBSD 9.1和我得到了一个预分支的多进程环境。
  • A main process, a poller to manage workers (to decide busy or avaiable) and workers. 一个主要过程,一个轮询器,用于管理工人(确定忙碌或有空)和工人。

If I send a SIGTERM to main process it is all right, if count of workers is not high. 如果我发送SIGTERM到主进程中,那么工人数不高就可以了。 If high (x > 20) I get seg faults. 如果high (x > 20)则会出现段错误。

I got two truss outputs, one of them is normal exit and the other has seg fault. 我有两个桁架输出,其中一个是正常出口,另一个是段错误。

gdb output of core file : 核心文件的gdb输出:

Die: DW_TAG_unspecified_type (abbrev = 62, offset = 1535499)
    has children: FALSE
    attributes:
        DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /usr/local/lib/gcc46/libstdc++.so.6]
Die: DW_TAG_unspecified_type (abbrev = 62, offset = 1535499)
    has children: FALSE
    attributes:
        DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /usr/local/lib/gcc46/libstdc++.so.6]

truss output of normal exited process: 正常退出过程的桁架输出:

> close(0)                                         = 0 (0x0) close(7)   
> = 0 (0x0) gettimeofday({1360957175.665250 },0x0)           = 0 (0x0) write(5,"2013-02-15 21:39:35.665 [64591] "...,64) = 64 (0x40) close(5)
> = 0 (0x0)
> 
> sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x
> 0) = 0 (0x0)
> 
> sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
> 
> .............. .............. so many same sigprocmask call
> 
> 
> sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x
> 0) = 0 (0x0)
> sigprocmask(SIG_SETMASK,0x0,0x0)                 = 0 (0x0)
> process exit, rval = 0

process, that has seg fault : 进程,存在段错误:

> gettimeofday({1360954514.547064 },0x0)           = 0 (0x0)
> write(5,"2013-02-15 20:55:14.547 [7580] I"...,63) = 63 (0x3f)
> close(5)                                         = 0 (0x0)
> SIGNAL 11 (SIGSEGV)
> process exit, rval = 0

It gives seg fault when the process tries to call sigprocmask. 当进程尝试调用sigprocmask时,它将产生seg错误。 I didn't call sigprocmask explicitly and suspect race condition for call to sigprocmask. 我没有明确调用sigprocmask,也没有怀疑调用sigprocmask的竞争条件。 Did you encounter race condition, that is related with sigprocmask ? 您是否遇到了与sigprocmask有关的竞赛条件?

It gives seg fault when the process tries to call sigprocmask 当进程尝试调用sigprocmask时,它会给出seg错误

I don't see that. 我没看到 It seems, the crash follows the closing of the 5th file-descriptor. 看来,崩溃是在第5个文件描述符关闭之后发生的。 It further appears, the descriptor 5 gets a log-message (with a timestamp) written right before getting closed. 进一步看来,描述符5在关闭之前就获得了日志消息(带有时间戳)。

Your "master" daemon tries to clean-up, and dies trying. 您的“主”守护程序尝试进​​行清理,然后尝试死亡。 I suggest, attaching gdb to it at run time -- just before sending the SIGTERM. 我建议在运行时将gdb附加到它-在发送SIGTERM之前。 When the SIGTERM is sent, tell gdb to continue. 发送SIGTERM后,告诉gdb继续。

When the SIGSEGV is sent, investigate. 发送SIGSEGV后,进行调查。

I'd also highly recommend running the daemon under valgrind. 我也强烈建议在valgrind下运行守护程序。 You are likely to catch a lot of nits that way... 您可能会通过这种方式抓到很多尼特...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM