Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seg fault upon interrupting disk io in progress #5399

Closed
amitmurthy opened this issue Jan 15, 2014 · 4 comments
Closed

Seg fault upon interrupting disk io in progress #5399

amitmurthy opened this issue Jan 15, 2014 · 4 comments
Labels
kind:bug Indicates an unexpected problem or unintended behavior

Comments

@amitmurthy
Copy link
Contributor

To simulate it, run the following code, interrupt once and run the function again.

julia> function file_io(secs)
           t1 = time()
           wstr = "Hello World"
           fn = tempname()
       #    fn = "/home/amitm/tmp/ec2/" * split(tempname(), "/")[3]
           while((time() - t1) < secs)
               fio = open(fn, "w+")
               write(fio, wstr)
               flush(fio)
               close(fio)
               rm(fn)
           end
       end
file_io (generic function with 1 method)

julia> file_io(60)
^CERROR: interrupt
 in unlink at fs.jl:93

julia> file_io(60)
Segmentation fault

NOTE: Came across this while I was simulating access to a slow filesystem (by using sshfs (via fuse) to mount an EC2 directory locally).

When I tried with the sshfs mountpoint - /home/amitm/tmp/ec2, julia segfaults the first time it is interrupted itself.

@amitmurthy
Copy link
Contributor Author

Though I don't see it while testing with the local file system now, I still see it on a 'slow' filesystem simulated by sshfs mounting a directory on an EC2 instance.

valgrind output is here - https://gist.github.com/amitmurthy/8431825

@amitmurthy amitmurthy reopened this Jan 15, 2014
@JeffBezanson
Copy link
Sponsor Member

Could you try putting JL_SIGATOMIC_BEGIN() / JL_SIGATOMIC_END() around jl_uv_writecb (in jl_uv.c)?

@amitmurthy
Copy link
Contributor Author

It improved the issue in the sense that it took me 4 counts of running file_io(60) and interrupting it before the seg fault happended, but it did nevertheless.

This was the change I tried with :

DLLEXPORT void jl_uv_writecb(uv_write_t* req, int status)
{
    JL_SIGATOMIC_BEGIN();
    JULIA_CB(writecb, req->handle->data, 2, CB_PTR, req, CB_INT32, status)
    free(req);
    JL_SIGATOMIC_END();
    (void)ret;
}

Any other function to wrap with SIGATOMIC and try ?

tknopp pushed a commit to tknopp/julia that referenced this issue Jan 15, 2014
tanmaykm pushed a commit to tanmaykm/julia that referenced this issue Jan 16, 2014
@JeffBezanson
Copy link
Sponsor Member

I would try adding sigatomic_begin(), sigatomic_end() around calls to ios_file, ios_write, and ios_close in io.jl.

But, this may be something of a lost cause as there is no general way to guarantee that everything is interrupt-safe. #2622 suggests wrapping all ccalls, but I'm kind of against this since it adds overhead and probably still won't make everything work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants