Re: odd segfault when adding -lutil
Hey thanks a million! I looked on your homepage and didn't find any paypal address listed so I'm going to donate in your name to Theo. I think when you two meet Theo should buy you a beer with part of the money. :-), or any other beverage in case you don't like beer. Thanks again! Donation sent. -peter On 08/08/17 01:36, Jeremie Courreges-Anglas wrote: > On Mon, Aug 07 2017, "Peter J. Philipp" wrote: >> Hi, > Hi, > >> I'm writing to misc because I did a change with my programming project and >> it doesn't work, in fact the program does not start up but in the dynamic >> linking stage (it seems) cores on segmentation violation. I have tried >> different architectures (amd64 and octeon) and -current and both have the >> same problem, but I develop mostly on 6.1. When I run it through a debugger >> I get this: >> >> (gdb) run >> Starting program: /usr/local/sbin/delphinusdnsd >> (no debugging symbols found) >> >> Program received signal SIGSEGV, Segmentation fault. >> 0x18c933300c94 in ?? () from /usr/local/sbin/delphinusdnsd >> (gdb) bt >> #0 0x18c933300c94 in ?? () from /usr/local/sbin/delphinusdnsd >> #1 0x18c933300b3e in ?? () from /usr/local/sbin/delphinusdnsd >> #2 0x in ?? () >> >> Apparently somewhere in the program something jumps to location 0 and from >> there it's downhill. >> >> Also the very first system call (a geteuid()) does not get called making me >> think it's before main() has been called. I'm completely boggled by this. >> >> # kdump | grep -3 geteuid >> # >> >> The last committed snapshot of my program is found here, and afaik it works: >> >> http://delphinusdns.org/delphinusdnsd-snapshot.tgz >> >> The changes I'm working on now which causes this weird behaviour is to tie in >> imsg into my program and that means linking -lutil with this program. I've >> checked if there was any macro collisions with TAILQ's or RB_HEAD's and >> tried >> to move those out of the way but still I get the segmentation fault. >> >> If anyone has an idea as to what could be the cause of this I'd be grateful. > Your program blows up the stack right at the start of main(), and gdb > doesn't seem to handle this very nicely. egdb from ports shows you > the faulty instruction in the listing of ''disas main'', gdb from base > doesn't seem to do that (but you can still find it out manually). > > Increasing the max stack size with ulimit -s, reducing the size of the > parent_ibuf and child_ibuf arrays, or allocating them in a different way > would work around those issues. > > [...] >
Re: odd segfault when adding -lutil
On Mon, Aug 07 2017, "Peter J. Philipp" wrote: > Hi, Hi, > I'm writing to misc because I did a change with my programming project and > it doesn't work, in fact the program does not start up but in the dynamic > linking stage (it seems) cores on segmentation violation. I have tried > different architectures (amd64 and octeon) and -current and both have the > same problem, but I develop mostly on 6.1. When I run it through a debugger > I get this: > > (gdb) run > Starting program: /usr/local/sbin/delphinusdnsd > (no debugging symbols found) > > Program received signal SIGSEGV, Segmentation fault. > 0x18c933300c94 in ?? () from /usr/local/sbin/delphinusdnsd > (gdb) bt > #0 0x18c933300c94 in ?? () from /usr/local/sbin/delphinusdnsd > #1 0x18c933300b3e in ?? () from /usr/local/sbin/delphinusdnsd > #2 0x in ?? () > > Apparently somewhere in the program something jumps to location 0 and from > there it's downhill. > > Also the very first system call (a geteuid()) does not get called making me > think it's before main() has been called. I'm completely boggled by this. > > # kdump | grep -3 geteuid > # > > The last committed snapshot of my program is found here, and afaik it works: > > http://delphinusdns.org/delphinusdnsd-snapshot.tgz > > The changes I'm working on now which causes this weird behaviour is to tie in > imsg into my program and that means linking -lutil with this program. I've > checked if there was any macro collisions with TAILQ's or RB_HEAD's and tried > to move those out of the way but still I get the segmentation fault. > > If anyone has an idea as to what could be the cause of this I'd be grateful. Your program blows up the stack right at the start of main(), and gdb doesn't seem to handle this very nicely. egdb from ports shows you the faulty instruction in the listing of ''disas main'', gdb from base doesn't seem to do that (but you can still find it out manually). Increasing the max stack size with ulimit -s, reducing the size of the parent_ibuf and child_ibuf arrays, or allocating them in a different way would work around those issues. [...] -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
odd segfault when adding -lutil
Hi, I'm writing to misc because I did a change with my programming project and it doesn't work, in fact the program does not start up but in the dynamic linking stage (it seems) cores on segmentation violation. I have tried different architectures (amd64 and octeon) and -current and both have the same problem, but I develop mostly on 6.1. When I run it through a debugger I get this: (gdb) run Starting program: /usr/local/sbin/delphinusdnsd (no debugging symbols found) Program received signal SIGSEGV, Segmentation fault. 0x18c933300c94 in ?? () from /usr/local/sbin/delphinusdnsd (gdb) bt #0 0x18c933300c94 in ?? () from /usr/local/sbin/delphinusdnsd #1 0x18c933300b3e in ?? () from /usr/local/sbin/delphinusdnsd #2 0x in ?? () Apparently somewhere in the program something jumps to location 0 and from there it's downhill. Also the very first system call (a geteuid()) does not get called making me think it's before main() has been called. I'm completely boggled by this. # kdump | grep -3 geteuid # The last committed snapshot of my program is found here, and afaik it works: http://delphinusdns.org/delphinusdnsd-snapshot.tgz The changes I'm working on now which causes this weird behaviour is to tie in imsg into my program and that means linking -lutil with this program. I've checked if there was any macro collisions with TAILQ's or RB_HEAD's and tried to move those out of the way but still I get the segmentation fault. If anyone has an idea as to what could be the cause of this I'd be grateful. What follows after my signature is the diff I'm working on and my dmesg.boot: Thanks, -peter Index: axfr.c === RCS file: /var/cvsroot/delphinusdns/delphinusdnsd/axfr.c,v retrieving revision 1.10 diff -u -p -u -r1.10 axfr.c --- axfr.c 11 Jul 2017 15:57:16 - 1.10 +++ axfr.c 7 Aug 2017 16:30:31 - @@ -30,7 +30,7 @@ #include "ddd-db.h" -void axfrloop(int *, int, char **, ddDB *); +void axfrloop(int *, int, char **, ddDB *, struct imsgbuf *ibuf); void axfr_connection(int, char *, int, ddDB *); intbuild_header(ddDB *, char *, char *, struct question *, int); intbuild_soa(ddDB *, char *, int, struct domain *, struct question *); @@ -101,8 +101,8 @@ static struct notifyentry { extern int domaincmp(struct node *e1, struct node *e2); RB_HEAD(domaintree, node) rbhead; -RB_PROTOTYPE_STATIC(domaintree, node, entry, domaincmp) -RB_GENERATE_STATIC(domaintree, node, entry, domaincmp) +RB_PROTOTYPE_STATIC(domaintree, node, rbentry, domaincmp) +RB_GENERATE_STATIC(domaintree, node, rbentry, domaincmp) static const char rcsid[] = "$Id: axfr.c,v 1.10 2017/07/11 15:57:16 pjp Exp $"; @@ -301,7 +301,7 @@ insert_notifyslave(char *address, char * } void -axfrloop(int *afd, int sockcount, char **ident, ddDB *db) +axfrloop(int *afd, int sockcount, char **ident, ddDB *db, struct imsgbuf *ibuf) { fd_set rset; Index: db.c === RCS file: /var/cvsroot/delphinusdns/delphinusdnsd/db.c,v retrieving revision 1.2 diff -u -p -u -r1.2 db.c --- db.c28 Jun 2017 09:40:54 - 1.2 +++ db.c7 Aug 2017 16:30:31 - @@ -46,8 +46,8 @@ domaincmp(struct node *e1, struct node * RB_HEAD(domaintree, node) rbhead = RB_INITIALIZER(&rbhead); -RB_PROTOTYPE(domaintree, node, entry, domaincmp) -RB_GENERATE(domaintree, node, entry, domaincmp) +RB_PROTOTYPE(domaintree, node, rbentry, domaincmp) +RB_GENERATE(domaintree, node, rbentry, domaincmp) Index: dd-convert.c === RCS file: /var/cvsroot/delphinusdns/delphinusdnsd/dd-convert.c,v retrieving revision 1.70 diff -u -p -u -r1.70 dd-convert.c --- dd-convert.c27 Jun 2017 05:41:02 - 1.70 +++ dd-convert.c7 Aug 2017 16:30:31 - @@ -148,7 +148,7 @@ extern char * base32hex_encode(u_char *i extern int domaincmp(struct node *e1, struct node *e2); RB_HEAD(domaintree, node) rbhead; -RB_GENERATE_STATIC(domaintree, node, entry, domaincmp) +RB_GENERATE_STATIC(domaintree, node, rbentry, domaincmp) Index: ddd-db.h === RCS file: /var/cvsroot/delphinusdns/delphinusdnsd/ddd-db.h,v retrieving revision 1.4 diff -u -p -u -r1.4 ddd-db.h --- ddd-db.h26 Jun 2017 20:28:50 - 1.4 +++ ddd-db.h7 Aug 2017 16:30:31 - @@ -463,7 +463,7 @@ typedef struct __dddb { sizeof(struct domain_nsec3param) + sizeof(struct domain_ds) ) struct node { -RB_ENTRY(node) entry; /* the node entry */ +RB_ENTRY(node) rbentry;/* the node entry */ char domainname[256]; /* domain name key name */ int len; /* length of domain name */ char *data; /* data it points to */ @@ -476,6 +476,11 @@ struct c