MPEG-TS, Rust, and C strings – the ongoing saga

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

MPEG-TS, Rust, and C strings – the ongoing saga

Russel Winder
Hi,

Having got over the stupid stuff, I think I am now onto the more serious
stuff.

Using Freeview input (BBC News) to my Rust MPEG-TS wrapper, I am finding:

1. There are a lot of ContentIdentifier descriptors, but there seems no way of
processing them in the C API or the Rust sys level wrapper.

2. There are a lot of PrivateDataSpecifier descriptors, but there seems no way
of processing them in the C API or the Rust sys level wrapper.

3. I am getting a SIGSEGV when processing ShortEvent descriptors early on. In
each run I process some ShortEvent descriptors entirely fine. However very
quickly there is a ShortEvent descriptor that delivers back a string that is
seemingly not a C string.

1. and 2. maybe that I haven't studied enough, but the ETSI document says
nothing about a ContentIdentifier descriptor as far as I can tell, and there
is nothing in the MPEG-TS at C or Rust sys level. Whilst the ETSI document
talks of a PrivateDataSpecifier descriptor and gives a formatting, this
doesn't seem to be supported at the MPEG-TS library C and Rust sys level.

3. is about having called:

gst_mpegts_sys::gst_mpegts_descriptor_parse_dvb_short_event(descriptor, &mut language_code, &mut name, &mut text) != 0 {

and language_code being a pointer to a C string but name not being. In earlier
calls everything worked so I believe it is not my code (but as ever I am happy
to be proved wrong). It appears that Freeview is delivering a ShortEvent
descriptor such that this C code in MPEG-TS is not delivering back a C string
for name, but instead doing a SIGSEGV in the sys::strlen called at line 965 of
c_str.rs.

I shall extract the data of the descriptor to create a test case as soon as I
can.

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-TS, Rust, and C strings – the ongoing saga

Russel Winder
On Thu, 2019-07-18 at 11:41 +0100, Russel Winder wrote:
>
[…]
> 2. There are a lot of PrivateDataSpecifier descriptors, but there seems no
> way
> of processing them in the C API or the Rust sys level wrapper.
>
[…]

Update:

There is a function gst_mpegts_descriptor_parse_dvb_private_data_specifier in
MPEG-TS but its specification is inconsistent with ETSI EN 300 468 v1.15.1, or
at least as I understand the standard and given the instances of
PrivateDataSpecifier descriptors being sent on the BBC News channel on
Freeview.

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-TS, Rust, and C strings – the ongoing saga

Russel Winder
In reply to this post by Russel Winder
On Thu, 2019-07-18 at 11:41 +0100, Russel Winder wrote:
[…]
> 3. I am getting a SIGSEGV when processing ShortEvent descriptors early on.
> In
> each run I process some ShortEvent descriptors entirely fine. However very
> quickly there is a ShortEvent descriptor that delivers back a string that is
> seemingly not a C string.
>
[…]

> 3. is about having called:
>
> gst_mpegts_sys::gst_mpegts_descriptor_parse_dvb_short_event(descriptor, &mut
> language_code, &mut name, &mut text) != 0 {
>
> and language_code being a pointer to a C string but name not being. In
> earlier
> calls everything worked so I believe it is not my code (but as ever I am
> happy
> to be proved wrong). It appears that Freeview is delivering a ShortEvent
> descriptor such that this C code in MPEG-TS is not delivering back a C
> string
> for name, but instead doing a SIGSEGV in the sys::strlen called at line 965
> of
> c_str.rs.
>
> I shall extract the data of the descriptor to create a test case as soon as
> I
> can.
The following is the data field of a descriptor received from Freeview that
caused a SIGSEGV in sys::strlen.

[77, 100, 101, 110, 103, 9, 31, 1, 123, 147, 109, 184, 138, 157, 128, 86, 31,
2, 39, 255, 219, 169, 50, 72, 51, 1, 109, 75, 238, 110, 69, 145, 164, 245, 19,
128, 212, 72, 153, 84, 148, 31, 56, 239, 241, 207, 233, 187, 166, 186, 230,
17, 239, 113, 82, 223, 235, 101, 203, 251, 78, 234, 253, 139, 24, 215, 78,
182, 182, 214, 216, 210, 213, 122, 94, 165, 235, 66, 148, 248, 118, 146, 125,
54, 115, 57, 20, 190, 253, 84, 91, 105, 223, 105, 117, 50, 226, 223, 163, 224]

I guess this is now time to create an actual bug report.

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-TS, Rust, and C strings – the ongoing saga

Russel Winder
On Thu, 2019-07-18 at 17:07 +0100, Russel Winder wrote:
> […]
>
> I guess this is now time to create an actual bug report.

But the question is where, is this a gstreamer-rs-sys problem or a gstreamer
problem?

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-TS, Rust, and C strings – the ongoing saga

Sebastian Dröge-3
On Thu, 2019-07-18 at 17:59 +0100, Russel Winder wrote:
> On Thu, 2019-07-18 at 17:07 +0100, Russel Winder wrote:
> > […]
> >
> > I guess this is now time to create an actual bug report.
>
> But the question is where, is this a gstreamer-rs-sys problem or a
> gstreamer problem?

Reproduce it in C if you're unsure about that. It's most likely not a
bindings problem as the -sys bindings *are* basically C.

--
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-TS, Rust, and C strings – the ongoing saga

Russel Winder
On Fri, 2019-07-19 at 09:05 +0300, Sebastian Dröge wrote:
> […]
>
> Reproduce it in C if you're unsure about that. It's most likely not a
> bindings problem as the -sys bindings *are* basically C.

I relented and wrote a C program. It turns out that
gst_mpegts_descriptor_parse_dvb_short_event can return success and yet leave
the event_name and text out parameters null: if it cannot parse the strings
for some reason it leaves the out parameter null and yet returns success – I
think because the language_code was successfully parsed, even if parsing the
event_name and text failed.

Thus the SIGSEGV must be because CStr::from_ptr fails to check for a null
argument, so when it calls sys::strlen it cannot cope. Thus it seems the
actual error here is in the Rust code – though I think there are clearly
problems in the C code.
 
--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment