inputstream.ffmpegdirect icon indicating copy to clipboard operation
inputstream.ffmpegdirect copied to clipboard

Nexus: %20N header crashes Kodi

Open matthuisman opened this issue 2 years ago • 21 comments

Crash https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=Mozilla/5.0%20%28Windows%20NT%2010.0%3B%20Win64%3B%20x64%29%20AppleWebKit/537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome/98.0.4758.102%20Safari/537.36

Removed characters until I got something that worked https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=Mozilla/5.0%20%28Windows%20

Then trying below breaks: https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=Mozilla/5.0%20%28Windows%20N

However, below works: https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=Mozilla/5.0%20%28Windows%20A

not a length issue as below works fine https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=Mozilla/5.0%20%28Windowsabcdefgsdfdsfsdtersfddsfsdte

and also non-encoded works fine: https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

finally I tried https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master.m3u8|user-agent=%20N and that causes CRASH. and so does %20n but all other letters seem ok. Weird!

matthuisman avatar Mar 05 '23 02:03 matthuisman

Note that this crash occurs on Nexus only. It works ok on Matrix.

@matthuisman do you know if this is kodi issue or an add-on issue?

@basilgello FYI

phunkyfish avatar Mar 05 '23 10:03 phunkyfish

i use the same pipe headers fine with IA and built-in ffmpeg. Just crashes with ffmpeg direct only

matthuisman avatar Mar 05 '23 10:03 matthuisman

Interesting. But where's the stacktrace?

basilgello avatar Mar 05 '23 13:03 basilgello

@basilgello do the URLS cause a crash for you on non-windows?

phunkyfish avatar Mar 05 '23 22:03 phunkyfish

@basilgello how can i get stacktrace without a debug build?

matthuisman avatar Mar 06 '23 06:03 matthuisman

You will need a debug build.

phunkyfish avatar Mar 06 '23 08:03 phunkyfish

i dont really want to setup the build environment on this pc so might just leave it for now.

Most of the time stacktrace isn't required for bug issues I hope? Most end-users wouldn't know where to start with that

matthuisman avatar Mar 06 '23 19:03 matthuisman

We should be able to build you a debug build in Jenkins.

phunkyfish avatar Mar 06 '23 19:03 phunkyfish

Here is a debug build and a PDB. The add-on should be included in the build. I don’t know if the add-on is also built with debug. I guess we’ll find out.

https://mirrors.kodi.tv/test-builds/windows/win64/KodiSetup-20230306-038f4e73-Nexus-x64.exe

https://mirrors.kodi.tv/test-builds/windows/win64/KodiSetup-20230306-038f4e73-Nexus-x64.pdb

If add-on is not debug I’ll find someone in the team to build it for us. I assume you would only need the PDB for the add-on.

phunkyfish avatar Mar 07 '23 10:03 phunkyfish

couldnt get any crash log out of kodi. maybe I need visual studio?

Anyway - here is test strm that can be used to reproduce that should work any where in the world Windows x64. crashes on Kodi 20 and 21 (v.20.5.0) Fine on 19 (v19.0.3) test.strm.txt

below works on all (no %20N in user-agent) test2.strm.txt

matthuisman avatar Mar 07 '23 12:03 matthuisman

I can not reproduce the crash on Debian. However, this closely reminds me the parsing error in urldecode.

basilgello avatar Mar 07 '23 15:03 basilgello

Yes, likely here:

https://github.com/xbmc/inputstream.ffmpegdirect/blob/278312774bb9d7f8936c7463a1d363e9b88a3221/src/stream/url/URL.cpp#L791

But that same code is in Kodi:

https://github.com/xbmc/xbmc/blob/eac2e81c62aec2099404d2eb66ccb64a67e9bcfd/xbmc/URL.cpp#L647

phunkyfish avatar Mar 07 '23 15:03 phunkyfish

couldnt get any crash log out of kodi. maybe I need visual studio?

Anyway - here is test strm that can be used to reproduce that should work any where in the world Windows x64. crashes on Kodi 20 and 21 (v.20.5.0) Fine on 19 (v19.0.3) test.strm.txt

below works on all (no %20N in user-agent) test2.strm.txt

Yes, you would need VS and load the PDB file while running the binary. VS Code should also be able to do this.

phunkyfish avatar Mar 07 '23 22:03 phunkyfish

Why whole VS? WinDbg / cdb no??? I can try setting VM to reproduce the issue

basilgello avatar Mar 08 '23 09:03 basilgello

I’m not familiar with Windows debug tools at all. If you can do that @basilgello then great.

phunkyfish avatar Mar 08 '23 09:03 phunkyfish

any updates on this? really wanting to try using ffmpeg direct for timeshift :)

matthuisman avatar Aug 18 '23 09:08 matthuisman

googled %20n crash and found https://www.reddit.com/r/networking/comments/28o8xi/comment/cicwz2m/?utm_source=share&utm_medium=web2x&context=3

Looks like a printf / sprintf issue

matthuisman avatar Aug 18 '23 10:08 matthuisman

Bonus points if you can tell me which is the offending statement!

phunkyfish avatar Aug 18 '23 10:08 phunkyfish

my guess is https://github.com/xbmc/inputstream.ffmpegdirect/blob/38aeb2f145897c06e36bd2fa057bcdf7a4a428bf/src/stream/FFmpegStream.cpp#L762C1-L762C80

matthuisman avatar Aug 18 '23 10:08 matthuisman

purely because the last line in log is ffmpegdirect::FFmpegStream::Open - av_find_stream_info finished

matthuisman avatar Aug 18 '23 10:08 matthuisman

changed the N to a M i get

2023-08-18 22:27:39.045 T:8796    debug <general>: AddOnLog: inputstream.ffmpegdirect: ffmpegdirect::FFmpegStream::Open - avformat_find_stream_info starting
2023-08-18 22:27:39.228 T:8796    debug <general>: AddOnLog: inputstream.ffmpegdirect: ffmpegdirect::FFmpegStream::Open - av_find_stream_info finished
2023-08-18 22:27:39.228 T:8796     info <general>: AddOnLog: inputstream.ffmpegdirect: ffmpeg[7A9FCB93]: Input #0, hls, from 'https://i.mjh.nz/tvnz-1.m3u8|user-agent=TESTM':

When its N, it doesnt get that last line. Also interesting TEST%20M comes out as TESTM (should be TEST M (with a space))

matthuisman avatar Aug 18 '23 10:08 matthuisman