<div dir="ltr"><div dir="ltr">On Thu, Sep 17, 2020 at 1:16 AM Romain Vimont <<a href="mailto:rom1v@videolabs.io">rom1v@videolabs.io</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, Sep 15, 2020 at 08:04:09PM +0530, Kartik Ohri wrote:<br>
> On Tue, Sep 15, 2020 at 1:54 PM Alexandre Janniaux <<a href="mailto:ajanni@videolabs.io" target="_blank">ajanni@videolabs.io</a>><br>
> wrote:<br>
> > > + pub fn vlc_stream_vaControl(s: *mut stream_t, query: c_int, ...) -><br>
> > c_int;<br>
> ><br>
> > After checking [1], you probably need the following code instead:<br>
> ><br>
> > extern "C" {<br>
> > pub unsafe fn vlc_stream_vaControl(s: *mut stream_t, query: c_int,<br>
> > ap: VaList) -> c_int;<br>
> > }<br>
> > pub unsafe fn vlc_stream_Control(s: *mut stream_t, query: c_int, mut<br>
> > args: ...) -> c_int {<br>
> > vlc_stream_vaControl(s, query, args)<br>
> > }<br>
> ><br>
> > Otherwise, as far as I understand this document, va_start/va_end might not<br>
> > be called correctly.<br>
<br>
I confirm (by calling stream.len() for example):<br>
<br>
==1868204==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x7f6b314acd28 bp 0x7f6b1e058710 sp 0x7f6b1e0585a0 T18)<br>
==1868204==The signal is caused by a READ memory access.<br>
==1868204==Hint: this fault was caused by a dereference of a high value address (see register values below). Dissassemble the provided pc to learn which register was used.<br>
#0 0x7f6b314acd28 in FileControl ../../modules/access/file.c:328<br>
#1 0x7f6b4c5a4c3a in vlc_stream_vaControl ../../src/input/stream.c:703<br>
#2 0x7f6b4c4fc775 in AStreamControl ../../src/input/access.c:281<br>
#3 0x7f6b4c5a4c3a in vlc_stream_vaControl ../../src/input/stream.c:703<br>
#4 0x7f6b314703a9 in AStreamControl ../../modules/stream_filter/cache_read.c:470<br>
#5 0x7f6b4c5a4c3a in vlc_stream_vaControl ../../src/input/stream.c:703<br>
#6 0x7f6b3078b635 in vlccore_rs::stream::Stream::len::h283ec41cb769dee5 (/home/rom/projects/vlc-rust/buildasan/modules/.libs/libcuesheet_plugin.so+0x10635)<br>
#7 ...<br>
<br>
> > I haven't checked in details though, and it needs the<br>
> > #![feature(c_variadic)] attribute.<br>
> ><br>
> > [1]<br>
> > <a href="https://github.com/rust-lang/rfcs/blob/26197104b7bb9a5a35db243d639aee6e46d35d75/text/2137-variadic.md" rel="noreferrer" target="_blank">https://github.com/rust-lang/rfcs/blob/26197104b7bb9a5a35db243d639aee6e46d35d75/text/2137-variadic.md</a><br>
> ><br>
> ><br>
> You are probably right. In that case, the RFC is not yet stabilized so<br>
> should we drop this part till then from the patch ?<br>
<br>
With this patch to expose the variadic vlc_stream_Control():<br>
<a href="https://mailman.videolan.org/pipermail/vlc-devel/2020-September/137598.html" rel="noreferrer" target="_blank">https://mailman.videolan.org/pipermail/vlc-devel/2020-September/137598.html</a><br>
<br>
And calling it from Rust instead of the va_list version, it works:<br>
<br>
--------8<-------------------------------------------------------------<br>
diff --git a/src/vlccore-rs/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a> b/src/vlccore-rs/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a><br>
index 0725a8fe6e..8d1b8c297e 100644<br>
--- a/src/vlccore-rs/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a><br>
+++ b/src/vlccore-rs/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a><br>
@@ -71,7 +71,7 @@ impl Stream {<br>
pub fn len(&self) -> std::result::Result<u64, Error> {<br>
let size: u64 = 0;<br>
const STREAM_GET_SIZE: i32 = 6;<br>
- let result = unsafe { ffi::vlc_stream_vaControl(self.stream, STREAM_GET_SIZE, &size) };<br>
+ let result = unsafe { ffi::vlc_stream_Control(self.stream, STREAM_GET_SIZE, &size) };<br>
if result != 0 {<br>
return Err(Error::new(<br>
ErrorKind::Other,<br>
@@ -102,7 +102,7 @@ impl Stream {<br>
const STREAM_GET_CONTENT_TYPE: i32 = 0;<br>
let result: *mut c_char = null_mut();<br>
unsafe {<br>
- if ffi::vlc_stream_vaControl(self.stream, STREAM_GET_CONTENT_TYPE, result) != 0 {<br>
+ if ffi::vlc_stream_Control(self.stream, STREAM_GET_CONTENT_TYPE, result) != 0 {<br>
return None;<br>
} else if result.is_null() {<br>
return None;<br>
diff --git a/src/vlccore-sys/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a> b/src/vlccore-sys/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a><br>
index c9e8d5f0b3..331b6c81b6 100644<br>
--- a/src/vlccore-sys/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a><br>
+++ b/src/vlccore-sys/src/<a href="http://stream.rs" rel="noreferrer" target="_blank">stream.rs</a><br>
@@ -16,7 +16,7 @@ extern "C" {<br>
<br>
pub fn vlc_stream_Seek(s: *mut stream_t, offset: u64) -> c_int;<br>
<br>
- pub fn vlc_stream_vaControl(s: *mut stream_t, query: c_int, ...) -> c_int;<br>
+ pub fn vlc_stream_Control(s: *mut stream_t, query: c_int, ...) -> c_int;<br>
<br>
pub fn vlc_stream_Delete(s: *mut stream_t);<br>
<br>
--------8<-------------------------------------------------------------<br>
<br>
I noticed a problem during testing: src/vlccore-rs and src/vlccore-sys<br>
are not rebuilt when sources are modified. Cargo should probably be<br>
called everytime to check if it must rebuild things.<br>
<br></blockquote><div>Yes, this can be done. I can add a Rust Sources variable in the <a href="http://common.am">common.am</a> makefile. It might also be fixed using a cargo workspace. I have been exploring how to run rustfmt on all rust crates and execute all rust tests. The best solution seems to be a cargo workspace. I'll try it out and report my findings.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards<br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a></blockquote></div></div>