From owner-freebsd-smp Fri Jun 13 13:56:50 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id NAA19421 for smp-outgoing; Fri, 13 Jun 1997 13:56:50 -0700 (PDT) Received: from george.lbl.gov (george-2.lbl.gov [131.243.2.12]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id NAA19413; Fri, 13 Jun 1997 13:56:46 -0700 (PDT) Received: (jin@localhost) by george.lbl.gov (8.6.10/8.6.5) id NAA22863; Fri, 13 Jun 1997 13:56:40 -0700 Date: Fri, 13 Jun 1997 13:56:40 -0700 From: "Jin Guojun[ITG]" Message-Id: <199706132056.NAA22863@george.lbl.gov> To: smp@csn.net Subject: Re: (kern/3827) : was ASUS P/I-P65UP5 with C-P55T2D Cc: bugs@FreeBSD.ORG, smp@FreeBSD.ORG Sender: owner-smp@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The problem has been narrowed to a very small program at below. It appears to happen at subroutine level. That is, the open/freopn works in main() program, but fails in subroutine. To replace the subroutine call at line 7 in main(), marked /* replace HERE */, with the body of openread() , then, program works. So, what can cause this problem? ---------------------------------------------- /* openread.c */ #include main(int argc, char **argv) { openread(argc > 1 ? argv[1] : "openread.c"); /* replace HERE */ } openread(char *fn) /* if put body below into main, then it works */ { FILE * fp = stdin; int c; if (!(fp=fopen(fn, "rb"))) exit(1); while( (c = fgetc(fp)) != EOF) fputc(c, stdout); if (!(fp=freopen(fn, "rb", stdin))) exit(2); while (fread(&c, sizeof(c), 1, fp) == 1) fwrite(&c, sizeof(c), 1, stdout); fclose(fp); } ------------------------------------------------ to load: cc -g openread.c -lc_r ------------------------------------------------ xxgdb can't trace this program, but gdb can. It hangs at _thread_sys_sigprocmask() call. Because I am not fimilar with thread_sys_calls(), would some one help me on solving it? Any information, hints, and comments are appreciated. thanks, -Jin ======================================= Below is the gdb tracing: gdb a.out GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.16 (i386-unknown-freebsd), Copyright 1996 Free Software Foundation, Inc... (gdb) l 1 /* openread.c */ 2 3 #include 4 5 main(int argc, char **argv) 6 { 7 openread(argc > 1 ? argv[1] : "openread.c"); 8 } 9 10 openread(char *fn) (gdb) b 7 Breakpoint 1 at 0x1594: file openread.c, line 7. (gdb) run Starting program: /export/src/ccs-lib/tools/x11/tuner/FreeBSD/a.out Breakpoint 1, main (argc=1, argv=0xefbfda5c) at openread.c:7 7 openread(argc > 1 ? argv[1] : "openread.c"); (gdb) s openread (fn=0x1580 "openread.c") at openread.c:12 12 FILE * fp = stdin; (gdb) s 15 if (!(fp=fopen(fn, "rb"))) (gdb) s fopen (file=0x1580 "openread.c", mode=0x15b4 "rb") at /usr/src/lib/libc_r/../libc/stdio/fopen.c:57 57 if ((flags = __sflags(mode, &oflags)) == 0) (gdb) s __sflags (mode=0x15b4 "rb", optr=0xefbfda0c) at /usr/src/lib/libc_r/../libc/stdio/flags.c:63 63 switch (*mode++) { (gdb) s 66 ret = __SRD; (gdb) s 67 m = O_RDONLY; (gdb) s 68 o = 0; (gdb) s 69 break; (gdb) s 89 if (*mode == '+' || (*mode == 'b' && mode[1] == '+')) { (gdb) s 93 *optr = m | o; (gdb) s 95 } (gdb) s fopen (file=0x1580 "openread.c", mode=0x15b4 "rb") at /usr/src/lib/libc_r/../libc/stdio/fopen.c:59 59 if ((fp = __sfp()) == NULL) (gdb) s __sfp () at /usr/src/lib/libc_r/../libc/stdio/findfp.c:105 105 if (!__sdidinit) (gdb) s 106 __sinit(); (gdb) s __sinit () at /usr/src/lib/libc_r/../libc/stdio/findfp.c:173 173 __cleanup = _cleanup; /* conservative */ (gdb) s 174 __sdidinit = 1; (gdb) s 175 } (gdb) s __sfp () at /usr/src/lib/libc_r/../libc/stdio/findfp.c:107 107 for (g = &__sglue;; g = g->next) { (gdb) s 108 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) (gdb) s 109 if (fp->_flags == 0) (gdb) s 108 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) (gdb) s 109 if (fp->_flags == 0) (gdb) s 108 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) (gdb) s 109 if (fp->_flags == 0) (gdb) s 108 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) (gdb) s 111 if (g->next == NULL && (g->next = moreglue(NDYNAMIC)) == NULL) (gdb) s 107 for (g = &__sglue;; g = g->next) { (gdb) s 108 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) (gdb) s 109 if (fp->_flags == 0) (gdb) s 116 fp->_flags = 1; /* reserve this slot; caller sets real flags */ (gdb) s 117 fp->_p = NULL; /* no current pointer */ (gdb) s 118 fp->_w = 0; /* nothing to read or write */ (gdb) s 119 fp->_r = 0; (gdb) s 120 fp->_bf._base = NULL; /* no buffer */ (gdb) s 121 fp->_bf._size = 0; (gdb) s 122 fp->_lbfsize = 0; /* not line buffered */ (gdb) s 123 fp->_file = -1; /* no file */ (gdb) s 125 fp->_ub._base = NULL; /* no ungetc buffer */ (gdb) s 126 fp->_ub._size = 0; (gdb) s 127 fp->_lb._base = NULL; /* no line buffer */ (gdb) s 128 fp->_lb._size = 0; (gdb) s 130 } (gdb) s fopen (file=0x1580 "openread.c", mode=0x15b4 "rb") at /usr/src/lib/libc_r/../libc/stdio/fopen.c:61 61 if ((f = open(file, oflags, DEFFILEMODE)) < 0) { (gdb) s open (path=0x1580 "openread.c", flags=0) at /usr/src/lib/libc_r/uthread/uthread_open.c:45 45 int mode = 0; (gdb) s 50 _thread_kern_sig_block(&status); (gdb) s _thread_kern_sig_block (status=0xefbfd9ec) at /usr/src/lib/libc_r/uthread/uthread_kern.c:952 952 _thread_sys_sigprocmask(SIG_SETMASK, &sig_to_block, &oset); (gdb) s Hanging HERE !!!