From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 2 Aug 2005 16:42:16 -0600 From: "Ronald G. Minnich" To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] debugging p9p threads question Topicbox-Message-UUID: 728058fe-ead0-11e9-9d60-3106f5b1d025 I'm hacking on sshnet and have truncated it and ported it to linux, but it is not quite baked. One odd thing I've seen: I've truncated the last bit of it to this: void threadmain(int argc, char **argv) { char *user, *service; /* fmtinstall('B', mpfmt); fmtinstall('H', encodefmt); */ service = nil; user = nil; ARGBEGIN{ case 'B': /* undocumented, debugging */ doabort = 1; break; case 'D': /* undocumented, debugging */ debuglevel = strtol(EARGF(usage()), nil, 0); break; case '9': /* undocumented, debugging */ chatty9p++; break; case 's': service = EARGF(usage()); break; default: usage(); }ARGEND if(argc) usage(); // sshmsgchan = chancreate(sizeof(Msg*), 16); fsreqchan = chancreate(sizeof(Req*), 0); fsreqwaitchan = chancreate(sizeof(void*), 0); fsclunkchan = chancreate(sizeof(Fid*), 0); fsclunkwaitchan = chancreate(sizeof(void*), 0); proccreate(fsnetproc, nil, 8192); threadpostmountsrv(&fs, service, nil, MREPL|MCREATE); fprint(2, "threadpostmountsrv RETURNS!~!!!!!!\n"); threadexitsall(0); } If I run this program, the fsnetproc will get a SIGUSR1, but not long after, will get a SIGUSR2; in fact, it gets the SIGUSR2 after the first time the server sends it a send and the does a recv. If I do this: . . . proccreate(fsnetproc, nil, 8192); threadpostmountsrv(&fs, service, nil, MREPL|MCREATE); fprint(2, "threadpostmountsrv RETURNS!~!!!!!!\n"); while(1) yield(); threadexitsall(0); } Then the program will run, just fine. Any idea what I could have done to break things? I have also done this to fsnetproc: void fsnetproc(void*v) { ulong path; Alt a[4]; Fid *fid; Req *r; threadsetname("fsthread"); a[0].op = CHANRCV; a[0].c = fsclunkchan; a[0].v = &fid; a[1].op = CHANRCV; a[1].c = fsreqchan; a[1].v = &r; #ifdef NO a[2].op = CHANRCV; a[2].c = sshmsgchan; a[2].v = &m; a[3].op = CHANEND; #endif for(;;){ . . . So I don't think the unitialized sshmsgchan should be a problem. I'm actually more interested in this question: how do you go about debugging this sort of problem? What's your favorite way to see what's going on? strace is pretty good, but not perfect. Do you use acid, or ... thanks ron