SIGSEGV during interruptible_sleep_on

SIGSEGV during interruptible_sleep_on

Post by Wolfram Fau » Fri, 28 Jul 2000 04:00:00

I am programming a character device for kernel 2.4.0-test1 and have the
following problem.
This is not the real function but enough to describe the problem.
If I open this device and want read from it with fread() the program
sleeps perhaps for two or three seconds an then gets a segmentation
fault in fread(). If I make

Quote:>cat /dev/mydevice

it's the same behaviour. cat terminates after two or three seconds with
a segmentation fault.

ssize_t dev_read(struct file *filp,char *buf, size_t count,loff_t *pos)
        static int i=0,k;

        printk("waitdev: I will sleep now ... szzzzhhh\n");
        interruptible_sleep_on((void *)&readQ);
        printk("waitdev: Good morning\n");

        ... __copy_to_user()

        return k;


Now my questions:
 Do I use the interruptible_sleep_on correct ???
 Is it possible that someone else than me wakes up the task
 (I call wake_up_interruptible((void *)&readQ) somewhere else)?

If you need more information please let me know.

Thank you



SIGSEGV during interruptible_sleep_on

Post by Linus Torval » Fri, 28 Jul 2000 04:00:00


>ssize_t dev_read(struct file *filp,char *buf, size_t count,loff_t *pos)
>    static int i=0,k;

>    printk("waitdev: I will sleep now ... szzzzhhh\n");
>    interruptible_sleep_on((void *)&readQ);
>    printk("waitdev: Good morning\n");

>    ... __copy_to_user()

>    return k;

>Now my questions:
> Do I use the interruptible_sleep_on correct ???

Almost certainly not. The fact that you needed to cast it to (void *)
probably means that you got the type wrong, and that cast is there to
shut the compiler up about a bad type.

A wait-queue should be set up with something like


and then it should not have any trouble when you pass in


and wake it up using "wake_up(&readQ)".



1. Loader gets SIGSEGV during RH 7.3 install

I will assume that that's a typo, and that your cube has 512M.



With shared memory systems, you will have to tell the
kernel about the amount of useable RAM, as it may not
be able to determine that at boot time. Try limiting
the amount of RAM with the corresponding LILO option.


          Lumber Cartel Unit #456 (TINLC) & Official Netscum
    Note: If you want me to send you email, don't munge your address.

2. ftp 'reget'

3. bash/shell user process limitation (threads)

4. SIGSEGV During malloc call?

5. master boot record problems

6. How I trace back SIGSEGV etc. (was: Re: SIGSEGV trace)

7. Return character in vi search string

8. interruptible_sleep_on, spin_lock_irqsave and interrupts

9. interruptible_sleep_on() problem...

10. How to use interruptible_sleep_on() without races ?

11. System Hang when sys_open & then interruptible_sleep_on()

12. poll_wait and interruptible_sleep_on