Tested for a sample daemon on Stock FreeBSD 10.2 Release with 32 bit and 64 bit executables. The daemon had an orphan child process running a while loop with sleep(). Pasted below is the code for the sample daemon : int main() { pid_t process_id = 0; // Create child process process_id = fork(); if (process_id < 0) { printf("fork failed!\n"); exit(1); } // killing the parent if (process_id > 0) { printf("The process id of the child is :%d" , process_id); exit(0); } while (1) { sleep(1); } } * The child process’s pid was then traced for using dtrace –n ‘pid$target:::entry {} ‘ -p < pid of the child process > * The dtrace test on the 32 bit daemon reported a segmentation fault : signal 11 and resulted into a core. The backtrace of the core looked like : Core was generated by `daemon'. Program terminated with signal 11, Segmentation fault. #0 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x08054802 in .cerror () at ../../../../../src/bsd/lib/libc/i386/sys/cerror.S:62 #2 0x0804991f in __sleep (seconds=1) at ../../../../../src/bsd/lib/libc/gen/sleep.c:63 #3 0x08048232 in main () at ../../../../../src/junos/usr.sbin/dump_proc/daemon.c:27 * The dtrace test on the 64 bit daemon did not report any errors and was traced correctly.
Created attachment 170253 [details] proposed patch Could you please try your test case with the attached patch? I've only verified that it compiles.
Hello Mark, Thanks. I made the proposed change, rebuilt the required modules and ran the test on a 64 bit image. The issue was still seen on the 64 bit image with a segmentation fault. The following error message was reported Dtrace: pid 741 terminated by signal 11. Thanks and Regards Abhishek Kulkarni
Hello Mark, Just following up on this. Was there any update or new patch upon this issue which could be tested for. Thanks and Regards Abhishek Kulkarni
(In reply to Abhishek Kulkarni from comment #3) Sorry for the delay. I spent some more time on this on the weekend and found quite a few other bugs that needed to be fixed. I have a patch which fixes all the problems I found using my test program, but it's very rough and not close to being in a committable state. I'll work on it further this week and try to get the changes committed soon.
Thanks very mucn Mark. That will be of great help. Regards Abhishek Kulkarni
This is fixed across a number of revisions: r303050, r303531-r303535, r303537 and r303544.
I'm not aware of any remaining issues with tracing 32-bit processes in FreeBSD 12.