-
Notifications
You must be signed in to change notification settings - Fork 9
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
Problem with full support of FE_GET_PROPERTY #18
Comments
Hi, I had the same issue. I fixed it by editing file "dvbchannel.cpp" of mythbackend. I deactivated the related section using a comment and the error is gone:
The root of the problem is that a pointer is passed via ioctl() but that pointer is just copied by the "intermediate" software, delivered to the mythbackend, which then tries to dereference it. However, mythbackend lacks permissions to dereference this pointer, as only the "intermediate" software has permissions to do so. IIRC, this behavior is also documented somewhere, not 100% sure where, but I can find it again. It is a bug caused by not implementing all features up to a level of 100%, but as far as it was required some time ago to get things working. Regards, |
Now I read your post a second time and realized that you already found that comment regarding that missing copying of pointed-to memory in the code :-) |
As you probably know, I don't use this software anymore. However, I'm willing to update it accordinng to your needs. |
Hi @bas-t, Thanks, fully understand! I’ll let you know if there is something to commit. Hi Florian, It is not only a MythTv problem, even the dvbv5-tools are failing. So it is related how dvbloopback returns the dvt_properties. There is an incorrect pointer returned, but the dtv_property is set correctly. (See my example program and Gdb output). |
I want to help, but I did not invest enough time yet to understand all the mechanics involved here to carry data back and forth from kernel and user space. My guess is that at some point logic has to be added that is specific to well-known service primitives that involve pointers, and add specific handlers to that. Such a handler would not copy the pointer, but the data pointed to, and deliver a new pointer (just an assumption!). No idea how many handlers would be required. Alone to answer that one may need to have a deeper look into the kernel code at DVBv5 and check all the returned data structures for pointers. |
Hi, Please find attached a small debug program. A few questions to understand dvbloopback and descramber a bit more:
Thanks for providing some info. ](url) |
Hi, great that you are having a deeper look into this! I know not much about that stuff yet, but I want to share my thoughts:
An user-space application such as mythbackend or your test application communicates with the kernel using calls to ioctl(). Thus, there must be an interface in dvblookback that lurks at the other side of the call to ioctl() in kernel space. This MAY be one of the copy_to/copy_from things. However, there is also the data flow from kernel to descrambler and vice-versa, via frontend0 and frontend1. Makes three "flows" with maybe two directions each. And, there is the communication with the "real" DVB interface. Does frontend0/1 provide kind of an "ioctl tunneling protocol"? And what about the validity of pointers? If you copy the address contained in a pointer from kernel space (DVB driver) to user space (descrambler), then back to kernel space (dvbloopback) and then back to user space (mythbackend) then this pointer may be the same "number", but it may not be valid to dereference it due to isolation of processes / address spaces. Thus, I have the assumption that a pure copying of addresses is not sufficient, maybe one needs to create a duplicate of the pointed-to memory as well. On the other hand, you got this working somehow, and only an address value was altered somewhere. Just my thoughts, though. Lots of MAYs. Regards, |
Hi, "lsof" helped, on an active live-TV session:
Thus, the chain of components is as follows here: [Kernel DVB device] <--> ffdescawrapper <--> [Loopback subID 1] <--> dvbloopback <-->[Loopback subID 0] <--> Mythbackend Regards, |
What helps is increasing the verbosity level in dvb_loopback.c. There, set dvblb_debug to 2. Afterwards you may also add subsequent dprintk, dprintk2, or dprintk3 statements to examine the flow of data. |
Thanks Florian for confirming my thoughts. |
hi Florian, and others, Can you please try the following by adding the following line on line 160 in dvb_loopback.c (just before 'return err'): tvps->props = oldprops; (Sorry, no clean patch yet). |
I've created a patch to fix the return of the proper tvps-props address. I've also included some changes to dnames as to my opinion, the wrong order is in there, which I found out during debugging. Please verify and test properly before running on production systems. Next action is to fix some other things which are going wrong:
[47016.988066] dvblb_fake_ioctl (2) : 42 |
Hi, your results sound great! However, I wonder that nobody ever noticed the wrong order of names, I hope you are sure what you are doing. I only have a production system here, that I can abuse for testing if I'm careful. If you give me some info how I should perform tests with your patch in order to maximize the benefit for you, please tell me. Otherwise I would revert my patches applied to mythbackend and check whether it still crashes together with your patched dvbloop device. I'm hoping that no other negative side-effects appear. Regarding side-effects: now you always overwrite tvps->props. May there be situations in which the previous behavior was correct? Thank you very much, |
Hi Florian, It looks trivial. Why not many other programs have failed, is because some programs directly call the dtv_property object and not through dtv_properties (like mythtv is doing). Also my test-dvb program does it via two different ways. For querying the DVB api version, I’m calling dtv_property directly, which is not a problem for dvbloopback, as this is filled properly with return values. If you look at call_func, there is some creation, copying and submitting into the real dvb adapter/descrambler. Why there is a copy created, has probably to do with kernel privileges (copy_from_user and copy_to_user), but then the original pointer is not set back to the dtv_property (which is correctly filled by copying tvp back to oldprops). This bug is only affecting FE_GET_PROPERTY calls where the user program acces dtv_property through the dtv_properties object. I haven’t tested with mythtv yet as I’m abroad but my test-dvb shows good results (no segfault anymore). |
Applied the patch to my test system and Live TV is working, great! EIT scanning is also working. |
Does channel scanning with mythtv-setup also work? |
Someone else hast to test channel scanning with MythTV. I stopped using that years ago because it messed up my channels. Since then, I scan with an external program and import the results into the database. The external "scan-dvb" works fine with this patch (although I did not test without the patch). |
I'm going to conduct a MythTV channel scan today, so "stay tuned" scnr |
First feedback with mythbackend 31.0-r1 and patched dvblookback:
This is my log:
The warnings indicate an open issue with invoking FE_GET_PROPERTY. |
I always had these 2 warnings with MythTV and dvbloopback. They are not new for MythTV 31 or the patched dvbloopback. |
Performing a channel scan with mythtv-setup works here! At first, I got one strange database error multiple times about a missing column "service_type" in table "channelscan_channel", but that seems to be an unrelated bug as the schema specification does not even mention this field. Now I have to reorder my channel list again or revert my backup do get it back online, but scanning works. During scanning, the mythtv-setup GUI shows bars for "Signal/Noise" and "Signal Strength". So I assume that at some point the software is able to get some quality-related readings from the driver :-) Thank you very much, |
Thanks for testing! Do you have some FTA channels to test this without dvbloopback?
|
I agree that these warnings "were always there" in the past, but I hope that will go away now as these issues are fixed in the dvbloopback driver. |
Thanks both! I like the cooperation with you to have this fixed! |
@bas-t are you able to commit the patch in this comment ? |
Many thanks again for providing this solution and for merging it. If you plan more changes and need someone to discuss or to test, I want to help. For that, I keep an eye on this bug report and this repository in general. |
Hi Florian, NP. There are some other not that urgent improvements to do. For example: dvbv5-scan gives a crc error while scanning virtual adapter. Descrambler is probably rewriting the PAT and not updating crc correctly. Not a problem for mythtv, but a good one to improve descrambler with dvbloopback. For doing that I need to understand the function of descrambler a bit better (than just decrypting the encrypted TS packets). I’ll raise an issue for that soon. |
@masjerang please open a new ticket for any future improvements. Do not continue to communicate in a already closed ticket, unless you discovered an anomaly with this one, inthat case the ticked should be reope d. |
@masjerang I mean, even if it is a draft, or just some thoughts about how to improve the lot, please open a new ticket. We can alwas change the title of the ticket in case that is appropriate. |
Hi @masjerang, did you test your patch with a recent kernel? On 5.7.15 I get lots of crash dumps in dmesg, but the driver still works.
Per loopback device I get two such crash blocks. They differ in their "topic":
Is this related to your changed / extended Regards, |
I just noticed there is already a bug open for this. |
Tested the current "master" on Linux kernel 5.8.8 without problems. However, no changes to descambler were applied, so there might be a mismatch between the names now. I do not see any warnings regarding that, but I feel not good about it either. However, it works, thanks! |
Hi,
I would like to address an issue I'm experiencing since I upgraded Mythtv to 0.31.
Mythtv is crashing on DVBv5 API calls because dvbloopback/descrambler is not returning the correct dtv_properties.
Disabling the DVBv5 calls in Mythtv will prevent it from crashing but dvbloopback needs some fixing.
The investigation I did already so far, in a test-bed (using DTV_STAT_SIGNAL_STRENGTH):
Example code:
Results in GDB with physical adapter:
Results in GDB with loopback adapter:
It seems that dtv_propa.props is corrupt and not properly copied.
However propa is set correctly, but is not being referred to by dtv_propa.props
There are some comments in dvb_loopback.c (in function call_func) about copying pointers.
Anyone experiencing similar issues?
The text was updated successfully, but these errors were encountered: