[kernel] bug#32: pipe test program causes hang
None
X-PA-RISC Linux-PR-Message: report 32
X-PA-RISC Linux-PR-Package: kernel
X-Loop: daniel_frazier@hp.com
Received: via spool by bugs@bugs.parisc-linux.org id=B.98286399022799
(code B ref -1); Thu, 22 Feb 2001 17:48:01 GMT
To: submit@bugs.parisc-linux.org
Date: Thu, 22 Feb 2001 10:46:27 -0700
From: Paul Bame <bame@fc.hp.com>
Message-Id: <E14Vzox-0007aK-00@noam.fc.hp.com>
Version: 21Feb2001
Package: kernel
The appended test program causes the kernel to wedge (narrow and wide)
though I think 'ping' still works. I tried a TOC which caught the
kernel in __down_interruptible but that's not necessarily abnormal
or repeatable.
#include <stdio.h>
#include <unistd.h>
#define READ 0
#define WRITE 1
#define SIZE 4096
int
main(int argc, char *argv[])
{
int p[2];
char data[SIZE];
char rdbuf[SIZE];
int i;
int pid;
if (pipe(p) != 0)
{
perror("pipe");
return 3;
}
for (i = 0; i < SIZE; i++)
{
data[i] = rand() & 0xff;
}
if ((pid = fork()) < 0)
{
perror("fork");
return 3;
}
for(i = 0; i < 10000; i++)
{
int sendoffset = rand() % SIZE;
int sendsize = rand() % (SIZE - sendoffset);
int wr, rd;
/* Don't bother sending 0 bytes */
if (sendoffset == SIZE - 1)
continue;
if (pid > 0)
{
wr = write(p[WRITE], data + sendoffset, sendsize);
printf("%d: write(data + %d, %d) = %d\n",
i, sendoffset, sendsize, wr);
if (wr != sendsize)
{
fprintf(stderr, "write returns %d expected %d\n", wr, sendsize);
if (wr < 0)
perror("write");
}
}
else
{
rd = read(p[READ], rdbuf, sendsize);
printf("%d: read(%d) = %d\n", i, sendsize, rd);
if (rd != sendsize)
{
fprintf(stderr, "read returns %d expected %d\n", rd, sendsize);
if (rd < 0)
perror("read");
}
if (memcmp(data + sendoffset, rdbuf, rd) != 0)
{
fprintf(stderr, "readback compare failed\n");
}
}
}
}