Bug 209130 - The Dtrace PID provider not working with 32 bit daemons in a 64 bit environment.
Summary: The Dtrace PID provider not working with 32 bit daemons in a 64 bit environment.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 10.2-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: Mark Johnston
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-04-28 18:15 UTC by Abhishek Kulkarni
Modified: 2018-01-25 16:01 UTC (History)
3 users (show)

See Also:


Attachments
proposed patch (586 bytes, patch)
2016-05-13 18:20 UTC, Mark Johnston
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Abhishek Kulkarni 2016-04-28 18:15:42 UTC
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.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2016-05-13 18:20:22 UTC
Created attachment 170253 [details]
proposed patch

Could you please try your test case with the attached patch? I've only verified that it compiles.
Comment 2 Abhishek Kulkarni 2016-05-17 18:52:14 UTC
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
Comment 3 Abhishek Kulkarni 2016-07-14 17:35:30 UTC
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
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2016-07-18 04:26:03 UTC
(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.
Comment 5 Abhishek Kulkarni 2016-07-18 05:10:05 UTC
Thanks very mucn Mark. That will be of great help.

Regards
Abhishek Kulkarni
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2016-08-02 21:20:05 UTC
This is fixed across a number of revisions:

r303050, r303531-r303535, r303537 and r303544.
Comment 7 Mark Johnston freebsd_committer freebsd_triage 2018-01-25 16:01:58 UTC
I'm not aware of any remaining issues with tracing 32-bit processes in FreeBSD 12.