Closed maxruby closed 10 years ago
Commenting out 523-525 in VideoIO/avio.jl removes the segmentation fault:
for i in avin.listening
_close(avin.stream_contexts[i+1])
end
The following is a simple fix that avoids the segmentation fault:
if length(avin.listening) > 1
for i in avin.listening
_close(avin.stream_contexts[i+1])
end
end
I wonder if the wrong streams are being closed. Maybe it's an off-by-1 bug?
Changing the index in avin.stream_contexts[i+1]
did not fix it.
Also, I could not think of which other stream_contexts
was opened except for the one in avin::AVInput.
In the REPL, avin.listening is IntSet[0]
julia> f = VideoIO.opencamera("Built-in iSight", VideoIO.DEFAULT_CAMERA_FORMAT)
julia> f.avin.listening
IntSet([0])
julia> length(f.avin.listening)
1
So here's what I think is happening: when you call close
, it's closing the connection, but the list of connections being listened to isn't reset. Later, when Julia exits (or even the next time the garbage collector runs), close
is called again (because it's a finalizer for the AVInput
object, and it attempts to close the input again, which causes the segfault.
The solution would be to clear the list of inputs being listened to.
Agreed. Actually, the following is a fix for segmentation fault issue #44:
avin.listening = IntSet()
for i in avin.listening
_close(avin.stream_contexts[i+1])
end
Should I close this issue and submit this fix along with the pull request?
Just fyi, if there's the string Fixes #44
in a commit of your PR, this issue will be automatically closed when the PR is accepted.
avin.listening = IntSet() for i in avin.listening _close(avin.stream_contexts[i+1]) end
It needs to be the other way around: you want to close all of the streams, and then call empty!(avin.listening)
.
I tried placing avin.listening = IntSet() after closing - that seemed to work too. Thank you for the clarification.
Either way would work. Using avin.listening = IntSet()
is probably slightly more expensive, but this isn't in a critical path, so either way should work.
Please do create a seperate pull request/fix for just this issue.
ok. will do!
I observed consistently the following crash error after using quit() - only following use of f = VideoIO.opencamera("Built-in iSight", VideoIO.DEFAULT_CAMERA_FORMAT) Before using quit() to exit, the camera opened properly which I then close with close(f) System is OSX 10.9, Julia v0.3.
julia> quit()