Panic in close_files in 2.0.3x

Philip Gladstone (
Tue, 19 May 1998 15:01:32 -0400

I've had a couple of panics in 2.0.32/3 with multithreaded
processes when I try and kill the process. The kernel
panics in close_fp as close_fp is passed a null file pointer.
This is because close_files uses the open_fds bitmap to work
out which elements of the fd array to close. However, it
appears that the system can get into a state where the open_fds
bitmap is out of step with the fd array.

I wrote a small loop (below) that I inserted into schedule
just before it switches to the new process. Suprisingly,
the printk is printed quite often -- which means that we are
switching into a process whose open_fds map includes bits which
do not correspond to open entries in the fd array.

There is a simple fix to close_files to make it check for
null fd[] entries, but I fear that that may mask some underlying

Any ideas?


struct files_struct *ff = next->files;
int fd;

if (next && ff && next->pid > 100) {
for (fd = 0; fd < 64; fd++) {
if (!ff->fd[fd] && FD_ISSET(fd, &ff->open_fds)) {
printk("problems with fd and files, pid=%d,
ff=%p, fd=%d, open_fds[0]=%08x\n",
next->pid, ff, fd, ff->open_fds.fds_bits[0]);

Philip Gladstone                           +1 781 530 2461
Raptor Systems / Axent Technologies 
Waltham, MA     

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to