kern/75758: Hard system hangs on tty code
Slawa Olhovchenkov
slw at zxy.spb.ru
Mon Jan 3 18:50:20 GMT 2005
>Number: 75758
>Category: kern
>Synopsis: Hard system hangs on tty code
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jan 03 18:50:20 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Slawa Olhovchenkov
>Release: FreeBSD 6.0-CURRENT i386
>Organization:
no
>Environment:
System: FreeBSD notebook.acropolis.ru 6.0-CURRENT FreeBSD 6.0-CURRENT #5: Mon Jan 3 13:33:38 MSK 2005 root at notebook.acropolis.ru:/usr/obj/usr/src/sys/BOOK i386
i386, FreeBSD 6.0-CURRENT i386
>Description:
6-current totally hangs by this program, from user, not root.
No responds on keys pressed, Control-Alt-ESC, switching console and etc.
System run in infinite loop in sys/kern/tty.c:ttread()
===
read:
splx(s);
/*
* Input present, check for input mapping and processing.
*/
first = 1;
if (ISSET(lflag, ICANON | ISIG))
goto slowcase;
for (;;) {
char ibuf[IBUFSIZ];
int icc;
icc = imin(uio->uio_resid, IBUFSIZ);
/* XXX uio_resid==0 => icc=0 */
icc = q_to_b(qp, ibuf, icc);
/* icc == 0 */
if (icc <= 0) {
if (first)
goto loop;
===
>How-To-Repeat:
Run this test program and type any. System immediately hangs.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#define cfmakeraw(ptr) (ptr)->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\
|IGNCR|ICRNL|IXON);\
(ptr)->c_oflag &= ~OPOST;\
(ptr)->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);\
(ptr)->c_cflag &= ~(CSIZE|PARENB);\
(ptr)->c_cflag |= CS8
int
main(int argc, char *argv[])
{
int fd,
i;
char *buf[1024];
struct termios tcn;
if ((fd = open("/dev/tty", O_RDWR | O_NONBLOCK)) == -1) {
return -1; /* errno already set */
}
/* Set the tty to raw and to the correct speed */
tcgetattr(fd, &tcn);
tcn.c_oflag = 0;
tcn.c_iflag = IGNBRK | IGNPAR;
tcn.c_cflag = CREAD | CLOCAL | CS8;
tcn.c_lflag = NOFLSH;
cfmakeraw(&tcn);
for (i = 0; i < 16; i++)
tcn.c_cc[i] = 0;
tcn.c_cc[VMIN] = 1;
tcn.c_cc[VTIME] = 0;
tcsetattr(fd, TCSANOW, &tcn);
if ((i = fcntl(fd, F_GETFL, 0)) != -1) {
i &= ~O_NONBLOCK;
fcntl(fd, F_SETFL, i);
}
read(fd, buf, 0);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list