1753698 Members
4838 Online
108799 Solutions
New Discussion юеВ

fork() hangs

 
Christopher Cooper
New Member

fork() hangs

I'm in the process of building and deploying an application that one of our customer's wrote in our environment for testing. The normal flow of the program is that it forks off a child process to run as a daemon, and then the parent process terminates. This program works fine in our customer's environment, but in our environment, when the call to "fork()" is made, it never returns and there is no sign of a child process. This seems very odd as based on the API documentation, a -1 should be returned if there is an error. Has anyone ever seen this behavior before? Any ideas regarding how I can debug this problem further? We are running "Compaq Tru64 UNIX V5.1 (Rev. 732)". Thanks!

Chris
3 REPLIES 3
Ralf Puchner
Honored Contributor

Re: fork() hangs

First of all, check if the latest patchkit are installed on the machine.

Use the "trace" or "truss" (not part of the OS) to verify proper execution.

Another method is to use the kerneldebugger (kdbx) or debugging code within your application - but this is generic development work (and I'm wondering why this is not your first choice of troubleshooting).

Also check the limits of the processes/memory (ulimit -a) maybe it is only a simple resource issue.


Help() { FirstReadManual(urgently); Go_to_it;; }
Christopher Cooper
New Member

Re: fork() hangs

Ralf,

Thanks for the tips. I am unfamiliar with the "trace" or "truss" tools, but will look into getting them installed on our machine if they aren't already there.

I have tried using the "ladebug" debugger to inspect the program while it is hung, but the information that I have gotten hasn't been particularly insightful. In case it means anything to you, I have included the stack trace below.

Thanks again!

Chris

(ladebug) tlist
Thread Name State Substate Policy Pri
------ ------------------------- --------------- ----------- ------------ ---
1 default thread blocked mut 779 SCHED_OTHER 19
>* -1 manager thread blk SCS SCHED_RR 19
-2 null thread for VP 2 running VP 2 null thread -1

(ladebug) thread 1
Thread Name State Substate Policy Pri
------ ------------------------- --------------- ----------- ------------ ---
> 1 default thread blocked mut 779 SCHED_OTHER 19

(ladebug) where
>0 0x3ff805ca8cc in __hstTransferRegisters(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#1 0x3ff805af454 in __osTransferContext(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#2 0x3ff805a39c0 in __dspTransferContext(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#3 0x3ff805a1064 in __dspDispatch(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#4 0x3ff805ab66c in UnknownProcedure32FromFile8(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#5 0x3ff805ab054 in UnknownProcedure31FromFile8(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#6 0x3ff805abb9c in UnknownProcedure34FromFile8(0xf, 0x1, 0x3ffc01b83c0, 0x3ff805ae430, 0x3ffc01b2000, 0x20000a0f600) in /usr/shlib/libpthread.so
#7 0x3ff80f331d0 in aio_prefork(0xf, 0x1, 0x3ffc01d19e0, 0x100000, 0x0, 0x20000a0f600) in /usr/shlib/libaio.so
#8 0x3ff8018e8f8 in __do_atfork(0xf, 0x1, 0x3ffc01d19e0, 0x100000, 0x0, 0x20000a0f600) in /usr/shlib/libc.so
#9 0x3ff800d0700 in __fork(0xf, 0x1, 0x3ffc01d19e0, 0x100000, 0x0, 0x20000a0f600) in /usr/shlib/libc.so
#10 0x1202809dc in ((PwocApp*)0x1402096e8)->initDaemon() "/usr/users/pricer/Cardinal/builds/pwoc/rel3_6/pwocapp.cpp":574
#11 0x12027f408 in ((PwocApp*)0x1402096e8)->PwocApp(argc=2, argv=0x11fffc018) "/usr/users/pricer/Cardinal/builds/pwoc/rel3_6/pwocapp.cpp":361
#12 0x12027a910 in main(argc=2, argv=0x11fffc018) "/usr/users/pricer/Cardinal/builds/pwoc/rel3_6/main.cpp":44
#13 0x12024cc68 in __start(0xf, 0x1, 0x3ffc01d19e0, 0x100000, 0x0, 0x20000a0f600) in pwoc

Re: fork() hangs

In case anyone is interested, I discovered that the "fork()" hang is being caused by our application being linked against both the "aio" and "aio_raw" libraries. If I remove one or other from the library list, all seems well. Does anyone know somewhere where I can read more about these two libraries?

Chris