tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: freeradius startup crash



On Wed, Dec 19, 2018 at 03:36:40AM +0000, maya%netbsd.org@localhost wrote:
> Maybe simpler

With the help of kern/53800 I got the right fix, and it was accepted
upstream. I will commit this to pkgsrc in a few hours, when I will
have my keys at hand.
 
--- src/lib/debug.c.orig
+++ src/lib/debug.c
@@ -105,13 +105,21 @@
 
 static TALLOC_CTX *talloc_null_ctx;
 static TALLOC_CTX *talloc_autofree_ctx;
 
+/*
+ * On BSD systems, ptrace(PT_DETACH) uses a third argument for
+ * resume address, with the magic value (void *)1 to resume where
+ * process stopped. Specifying NULL there leads to a crash because
+ * process resumes at address 0.
+ */  
 #ifdef HAVE_SYS_PTRACE_H
 #  ifdef __linux__
 #    define _PTRACE(_x, _y) ptrace(_x, _y, NULL, NULL)
+#    define _PTRACE_DETACH(_x) ptrace(PT_DETACH, _x, NULL, NULL)
 #  else
 #    define _PTRACE(_x, _y) ptrace(_x, _y, NULL, 0)
+#    define _PTRACE_DETACH(_x) ptrace(PT_DETACH, _x, (void *)1, NULL)
 #  endif
 
 #  ifdef HAVE_CAPABILITY_H
 #    include <sys/capability.h>
@@ -205,9 +213,9 @@
                                fprintf(stderr, "Writing ptrace status to parent                                  failed: %s", fr_syserror(errno));
                        }
 
                        /* Detach */
-                       _PTRACE(PT_DETACH, ppid);
+                       _PTRACE_DETACH(ppid);
                        exit(0);
                }
 
                ret = DEBUG_STATE_ATTACHED;


-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index