mat813 / rb-kqueue

An FFI wrapper for kqueue
MIT License
22 stars 12 forks source link

Errno::EFAULT (Bad address - KQueue failed: There was an error reading or writing the kevent structure.) #16

Open hasandiwan opened 2 years ago

hasandiwan commented 2 years ago

Error occurs if I leave unicorn running too long on the system (uname output below). I didn't notice it with webrick. and haven't tried thin or any other rails appserver as yet:

$ uname -a
FreeBSD freebsd 12.2-STABLE FreeBSD 12.2-STABLE r368787 GENERIC  amd64
baukus commented 5 months ago

I have also see this error on 13.1-STABLE FreeBSD 13.1-STABLE with rb-kqueue-0.2.8 under ruby-version ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [amd64-freebsd13]

In this case the code is esentially:

    @kq = KQueue::Queue.new
    @kq.watch_file(XYZ_DIR, :write) { process_var_tmp_xyz }
    @kq.run

The error occurred at: @kq.watch_file(XYZ_DIR, :write) { process_var_tmp_xyz }

EFAULT may imply that keven(8) could not copy in/out the kevent(8) parameters, but of course this code works 99.99999% of the time.

I have not found a way to reproduce.

taq commented 4 months ago

I just updated to FreeBSD 14.1-RELEASE-p2 and started to get this error using guard. The tests run, but when it stops to wait for some chances to run tests again, it finishes and show the error message. But - the weird part - it suddenly worked again few minutes after I found this issue, nothing changed. I really didn't understand.