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
CALL /OUTPUT throws exception "Bus error: 10" and dies #537
Comments
and if you use x: copy {} ? |
@gchiu - Still dies with Bus error: 10 :( Does that mean you don't get this crash on Windows (with or without |
I found two problems which were introduced in switching the ALLOC_N macros to malloc(). I fixed those, and also made the operation fail out early if you try to pass it locked series to use for the stdout or stderr capture: But with that addressed, it still seems to have problems with outputs that need to be larger than the buffer "chunk" size used to read from the pipe. It seems that long output is clipped, because even when it hasn't processed all the output it's ending the gathering loop because WIFEXITED(status) thinks that the process is done. And it seems there's a sort of process-race-condition, so you don't get the same behavior stepping in the debugger as you do when you don't. Basically, it seems the child process is not waiting just because the parent isn't done reading the data yet. |
The good news is that this fixes the However bad news is I'm still getting Here's couple of other interesting examples...
So always get first 4609 characters regardless since your fix (was 5387 before). And always get So at the moment CALL is struggling with something like |
Well, I knew it wouldn't make it work. I just got rid of a couple crashing mistakes I'd introduced. But it helps to have tests. One problem with these tests though is that they'd be platform dependent in terms of what commands you run, and perhaps hard to predict what output you got. I guess we could remedy this perhaps by running Rebol itself... based on the executable path... with arguments that ran a script with predictable generative output? If you have interest in helping with that, it would be great. In any case, @zsx and I talked about changing how the memory buffering is done anyway, so you don't use twice as much memory as you need to for the operation. So maybe he can take a crack at stepping over what's happening with an eye toward that change. |
@hostilefork - I've created some tests which hopefully will cover this problem - #541 Test 1 - Passes Test 2 - Fails. This is where we get partial data (usually first 4609 bytes but it does sometime vary). Test 3 - Crashes. Somewhere over 50,000 bytes received will this causes the following error:
|
@hostilefork - Update I've run the CALL tests on Linux (Ubuntu 12.04.5 32-bit) and now test 2 crashes rather than failing returning incomplete data:
I have found with little tinkering of test that anything over 5000 bytes received causes the crash. |
@draegtun The test cases should be fixed, but the git log is still failing, and I'm not sure how we can fix that: git was failing because it couldn't write to the output (the pipe is full because the rebol process is not reading as fast as git is writing). A larger buffer could mitigate the issue, it could still be filled up anyway. |
@zsx - Thanks for fix. I can confirm that all tests do now PASS on Mac OSX. I'll test on Linux later. And I added a new test for big NB. This new test does require |
@zsx Is that something specific about git log? :-/ I'd assume that it does standard I/O, which should block as long as the pipe isn't ready, shouldn't it? |
@hostilefork - For me the @zsx - I can now confirm that ALL tests (including new |
@draegtun For me, git log failed on Linux due to it can't write to standard output: The strace looks like:
Here process 32061 is git, and 32060 is rebol. So git exited right after the writing failure (where write returns EAGAIN) However, if I increase BUF_SIZE_CHUNK to 40960, it passes. |
git log also passes if I redirect the output to a file instead of a string. |
@zsx - Hmmmm, so we're getting different results at the moment :( For me all tests, including the
All the above were built today using latest source. |
@draegtun I think it's a race condition between rebol and git, if git runs slower, it works fine, or it fails. |
I think this one should now be fixed. |
Well done @zsx And I can confirm that the 4 call tests do still pass for me on all my platforms. |
Example:
Without the
/output
refinement it works fine:The
/output
issue is same without/shell
refinement:Now
netstat
was deliberately chosen because it does work fine on smaller stuff:So i'm assuming some buffering issue so anything big crashes with this bus error :(
BTW - This is a newish issue because it works fine on
r3-0f831cb
(22-Mar-2017).Test built from latest source (default
make
) on Mac OS/X 10.9.5UPDATE - Along with the crash I also get a fatal error with this example:
Interesting I get same fatal error when using
r3-0f831cb
but no crash?So it has copied over partial data to
x
before throwing that fatal error.The text was updated successfully, but these errors were encountered: