• General Support
  • CRASH - tvh:tcp-start[X]: segfault at X ip X sp X error 4 in tvheadend

Hi,

I hope someone can help fix what I think is a bug in TVHeadend.

I have this crash several times per month. Sometimes when it crashes, it repeatedly crashes in a loop for maybe 30 minutes. Most times it recovers first time round.

I would sincerely appreciate any support fixing this.

It happens on any version, I am built using a very new version right now. This crash has been happening for 2 years.

I have completly rebuilt my TVHeadend setup numerous times and its presently running of a completely different server.

I see this in DMESG:

[Fri Sep  6 11:20:52 2024] tvh:tcp-start[2247021]: segfault at 3ed468e ip 00005613fc208cc9 sp 00007f7bab5f93b0 error 4 in tvheadend[5613fc16c000+f0a000]
[Fri Sep  6 11:20:52 2024] Code: f6 ff b8 ea ff ff ff e9 62 fe ff ff 0f 1f 44 00 00 48 85 d2 74 3b 55 48 89 e5 41 57 41 56 41 55 41 54 49 89 d4 53 48 83 ec 28 <80> 3a 00 74 0a 48 85 c9 74 05 80 39 00 75 20 48 8d 65 d8 5b 41 5c

Then this trace in the TVHeadend log file:

2024-09-06 11:20:58.540 [  DEBUG]:timeshift: remote ts status start 0 end 420 current 0
2024-09-06 11:20:58.943 [   INFO]:iptv: rtsp: set speed: 0
2024-09-06 11:20:58.946 [  ALERT]:CRASH: Signal: 11 in PRG: /applications/tvheadend.19082024.4.3-2354/build.linux/tvheadend (4.3-2354~gadef81b8d) [c115c7266aa7bbc1580679115c2de75d3d3a8c74] CWD: /tmp  
2024-09-06 11:20:58.946 [  ALERT]:CRASH: Fault address 0x3ed468e (Address not mapped)
2024-09-06 11:20:58.946 [  ALERT]:CRASH: Loaded libraries: linux-vdso.so.1 /lib/x86_64-linux-gnu/libdvbcsa.so.1 /lib/x86_64-linux-gnu/libssl.so.1.1 /lib/x86_64-linux-gnu/libcrypto.so.1.1 /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libpcre2-8.so.0 /lib/x86_64-linux-gnu/libdbus-1.so.3 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libmvec.so.1 /lib/x86_64-linux-gnu/libstdc++.so.6 /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libsystemd.so.0 /lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/librt.so.1 /lib/x86_64-linux-gnu/liblzma.so.5 /lib/x86_64-linux-gnu/libzstd.so.1 /lib/x86_64-linux-gnu/liblz4.so.1 /lib/x86_64-linux-gnu/libgcrypt.so.20 /lib/x86_64-linux-gnu/libgpg-error.so.0 /lib/x86_64-linux-gnu/libnss_files.so.2  
2024-09-06 11:20:58.946 [  ALERT]:CRASH: Register dump [23]: 00000000000000000000000000000000000000000000000000000000000002460000000003ed468e00005613ff4fe35000007f7bab5f941000007f7bab5f942000005613ff4fe350000000000000000000007f7bab5f940000005613ff575cd00000000003ed468e00007f7bab5f94b0000000000000000200007f7bab5f93b000005613fc208cc90000000000010202002b0000000000330000000000000004000000000000000efffffffe7ffbba130000000003ed468e
2024-09-06 11:20:58.946 [  ALERT]:CRASH: STACKTRACE
2024-09-06 11:20:59.198 [  ALERT]:CRASH: /applications/tvheadend/src/trap.c:176 0x5613fc1f493a 0x5613fbfb8000
2024-09-06 11:20:59.391 [  ALERT]:CRASH: ??:0 0x7f800ddad140 0x7f800dd9a000
2024-09-06 11:20:59.540 [  DEBUG]:timeshift: remote ts status start 0 end 421 current 0
2024-09-06 11:20:59.555 [  ALERT]:CRASH: /applications/tvheadend/src/httpc.c:1225 (discriminator 1) 0x5613fc208cc9 0x5613fbfb8000
2024-09-06 11:20:59.741 [  ALERT]:CRASH: /applications/tvheadend/src/rtsp.c:62 0x5613fc20b3c8 0x5613fbfb8000
2024-09-06 11:20:59.913 [  ALERT]:CRASH: /applications/tvheadend/src/http.h:492 0x5613fc2c2f48 0x5613fbfb8000
2024-09-06 11:21:00.098 [  ALERT]:CRASH: /applications/tvheadend/src/streaming.h:462 0x5613fc1db47d 0x5613fbfb8000
2024-09-06 11:21:00.285 [  ALERT]:CRASH: /applications/tvheadend/src/htsp_server.c:2836 (discriminator 3) 0x5613fc1e38b2 0x5613fbfb8000
2024-09-06 11:21:00.469 [  ALERT]:CRASH: /applications/tvheadend/src/htsp_server.c:3423 0x5613fc1e56cb 0x5613fbfb8000
2024-09-06 11:21:00.540 [  DEBUG]:timeshift: remote ts status start 0 end 422 current 0
2024-09-06 11:21:00.631 [  ALERT]:CRASH: /applications/tvheadend/src/tcp.c:724 0x5613fc1b77df 0x5613fbfb8000
2024-09-06 11:21:00.818 [  ALERT]:CRASH: /applications/tvheadend/src/tvh_thread.c:91 (discriminator 3) 0x5613fc1b2b5a 0x5613fbfb8000
2024-09-06 11:21:01.002 [  ALERT]:CRASH: ??:0 0x7f800dda1ea7 0x7f800dd9a000
2024-09-06 11:21:01.002 [  ALERT]:CRASH: clone+0x3f  (/lib/x86_64-linux-gnu/libc.so.6)

From my limited knowledge it may be a null pointer reference relating to HTSP?

    It might be an idea to include a full list of hardware and version OS you are running TVH on.

      Are you always performing the same task when this occurs?
      Does it always happen on a certain channel or at a certain time of day or any other clue?

        Jonas Lang - Thanks for the further questions. Here is some more detail.

        This crash will happen on any x86 system I run it on. It happens 3-4 times per month, and 30% of the time TVH will repeatedly crash for 30 minutes, until suddenly it recovers. As in, it starts, crashes, restarts.

        I am certain it is not the hardware, as it is hardware agnostic.
        I am reasonably sure it is not Debian, as it happens across major release versions.

        The systems in question:

        System 1:
        CPU: 2 x Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz
        RAM: 256gb
        DISK: 5 x 2tb NVME in RAID 5
        OS: Debian GNU/Linux 10 (buster)
        TVHeadend version: HTS Tvheadend 4.3-2361~gdd82541c4

        System 2: Debian GNU/Linux 11 (bullseye)
        CPU: 2 x Intel(R) Xeon(R) CPU E5-2695 v4 @ 2.10GHz
        RAM: 512gb
        DISK: 3 x 4tb Samsung EVO SSD in RAID 1 on 12Gbps HBA
        OS: Debian GNU/Linux 11 (bullseye)
        TVHeadend version: HTS Tvheadend 4.3-2354~gadef81b8d

        I have extensively investigated resource usage during crash periods. Nothing is stressed. CPU's has 80% availability, RAM has lots to spare, as does swap. Disk IO is not intensive and has plenty of spare IO capacity.

          DeltaMikeCharlie

          Hey thanks for following this up. I appreciate it.

          I am doing nothing per-se. I am not in the GUI or doing any tasks at all. The only activity is TVHeadend use by connected streams, and AUTORECs taking place. I only discover the crash or crashes by reviewing the TVHeadend log or DMESG. Or by my current Live TV feed pausing for a minute or so!

          EPG is updated twice per day on a cron, but this is not the trigger of the crash, certainly not at that specific crash event anyway.

          What I find interesting is the repeated crashes, when it gets into a crash loop. That tells me there is some race condition, or null pointer, or bad data (epg maybe), as it always EVENTUALLY recovers.

          I am not competent enough to understand the stack trace I posted. What is TVH trying to do? What is tcp-start?

          Clients stream using HTSP.
          I have AUTORECs that may be recordings multiple items at any one time.
          Clients can timeshift upto 5 mins but only on demand.

          I am presently running both servers, with identical TVH configuration and AUTORECs. The only difference is one server is loaded with clients, the other server is not. I am trying to establish if the issue might be a user action such as starting a stream, or whether it might be an EPG/AUTOREC event.

          The most recent crash occurred on the server loaded with users, it did not happen in parrallel on the other identical server.

          P Proton are you using any physical tuners or is this pure IPTV from outside sources.

            Not entirely sure what version you're running there, but the current master does not contain any executable code in line 1225 of httpc.c

              Jonas Lang

              No tuners on this server. It is IPTV streaming for everything. I do have tuners on another server, but that's another physical server and simply exposes IPTV streams to this server.

              Here is line 1225 of httpc.c from the original source of /applications//tvheadend.19082024.4.3-2354/src/httpc.c

              This is a version I built from git on 19th August 2024.

              Line 1225 is the first open curly bracket:

              {
                if (user && user[0] && pass && pass[0]) {
              #define BASIC "Basic "
                  size_t plen = strlen(pass);
                  size_t ulen = strlen(user);
                  size_t len = BASE64_SIZE(plen + ulen + 1) + 1;
                  char *buf = alloca(ulen + 1 + plen + 1);
                  char *cbuf = alloca(len + sizeof(BASIC) + 1);
                  strcpy(buf, user);
                  strcat(buf, ":");
                  strcat(buf, pass);
                  strcpy(cbuf, BASIC);
                  base64_encode(cbuf + sizeof(BASIC) - 1, len,
                                (uint8_t *)buf, ulen + 1 + plen);
                  http_arg_set(h, "Authorization", cbuf);
              #undef BASIC
                }
              }

              I should add this is my configure line that I use. I need PCRE2 for AUTOREC for some regex queries.
              I compile from GIT source always.

              As this is purely IPTV and has no tuners, no homerun, no need to descramble etc I disable a lot of things that are not needed or related to my setup:

              ./configure --disable-pie --disable-cardclient --disable-cwc --disable-cccam --disable-capmt --disable-constcw --disable-linuxdvb --disable-satip_server --disable-satip_client --disable-hdhomerun_server --disable-hdhomerun_static --disable-dvbscan --disable-avahi --disable-tvhcsa --enable-pcre2

              Although I have historically compiled as default, just enabling pcre2 and still experienced these crashes over the past 2 years, so I am reasonably sure it's none of these.

              7 days later

              Hi All,

              I have captured another crash with DEBUG log.

              It looks very similar with some minor differences.

              2024-09-15 09:04:30.836 [  DEBUG]:timeshift: remote ts status start 0 end 29 current 0
              2024-09-15 09:04:31.836 [  DEBUG]:timeshift: remote ts status start 0 end 30 current 0
              2024-09-15 09:04:32.836 [  DEBUG]:timeshift: remote ts status start 0 end 31 current 0
              2024-09-15 09:04:33.527 [  ALERT]:CRASH: Signal: 11 in PRG: /applications/tvheadend.19082024.4.3-2354/build.linux/tvheadend (4.3-2354~gadef81b8d) [c115c7266aa7bbc1580679115c2de75d3d3a8c74] CWD: /tmp  
              2024-09-15 09:04:33.527 [  ALERT]:CRASH: Fault address 0x110cef5 (Address not mapped)
              2024-09-15 09:04:33.527 [  ALERT]:CRASH: Loaded libraries: linux-vdso.so.1 /lib/x86_64-linux-gnu/libdvbcsa.so.1 /lib/x86_64-linux-gnu/libssl.so.1.1 /lib/x86_64-linux-gnu/libcrypto.so.1.1 /lib/x86_64-linux-gnu/libz.so.1 /lib/x86_64-linux-gnu/libpcre2-8.so.0 /lib/x86_64-linux-gnu/libdbus-1.so.3 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libmvec.so.1 /lib/x86_64-linux-gnu/libstdc++.so.6 /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libsystemd.so.0 /lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/librt.so.1 /lib/x86_64-linux-gnu/liblzma.so.5 /lib/x86_64-linux-gnu/libzstd.so.1 /lib/x86_64-linux-gnu/liblz4.so.1 /lib/x86_64-linux-gnu/libgcrypt.so.20 /lib/x86_64-linux-gnu/libgpg-error.so.0 /lib/x86_64-linux-gnu/libnss_files.so.2  
              2024-09-15 09:04:33.527 [  ALERT]:CRASH: Register dump [23]: 0000000000000000000000000000000000000000000001000000000000000000000000000110cef500005628c8ccf6e000007fa65e5f13d000007fa65e5f13e000005628c8ccf6e0000000000000000000007fa65e5f13c000005628c8525d20000000000110cef500007fa65e5f1470000000020000000000007fa65e5f137000005628c56eccc90000000000010202002b0000000000330000000000000004000000000000000efffffffe7ffbba13000000000110cef5
              2024-09-15 09:04:33.527 [  ALERT]:CRASH: STACKTRACE
              2024-09-15 09:04:33.813 [  ALERT]:CRASH: /applications/tvheadend/src/trap.c:176 0x5628c56d893a 0x5628c549c000
              2024-09-15 09:04:33.925 [  DEBUG]:timeshift: remote ts status start 0 end 32 current 0
              2024-09-15 09:04:34.087 [  ALERT]:CRASH: ??:0 0x7faa4d74a140 0x7faa4d737000
              2024-09-15 09:04:34.311 [  ALERT]:CRASH: /applications/tvheadend/src/httpc.c:1225 (discriminator 1) 0x5628c56eccc9 0x5628c549c000
              2024-09-15 09:04:34.536 [  ALERT]:CRASH: /applications/tvheadend/src/rtsp.c:62 0x5628c56ef3c8 0x5628c549c000
              2024-09-15 09:04:34.818 [  ALERT]:CRASH: /applications/tvheadend/src/http.h:492 0x5628c57a6e25 0x5628c549c000
              2024-09-15 09:04:34.902 [  DEBUG]:timeshift: remote ts status start 0 end 33 current 0
              2024-09-15 09:04:35.041 [  ALERT]:CRASH: /applications/tvheadend/src/streaming.h:462 0x5628c56bf54a 0x5628c549c000
              2024-09-15 09:04:35.281 [  ALERT]:CRASH: /applications/tvheadend/src/htsp_server.c:2807 0x5628c56c8659 0x5628c549c000
              2024-09-15 09:04:35.513 [  ALERT]:CRASH: /applications/tvheadend/src/htsp_server.c:3423 0x5628c56c96cb 0x5628c549c000
              2024-09-15 09:04:35.799 [  ALERT]:CRASH: /applications/tvheadend/src/tcp.c:724 0x5628c569b7df 0x5628c549c000
              2024-09-15 09:04:35.887 [  DEBUG]:timeshift: remote ts status start 0 end 34 current 0
              2024-09-15 09:04:36.027 [  ALERT]:CRASH: /applications/tvheadend/src/tvh_thread.c:91 (discriminator 3) 0x5628c5696b5a 0x5628c549c000
              2024-09-15 09:04:36.258 [  ALERT]:CRASH: ??:0 0x7faa4d73eea7 0x7faa4d737000
              2024-09-15 09:04:36.258 [  ALERT]:CRASH: clone+0x3f  (/lib/x86_64-linux-gnu/libc.so.6)

              Is anyone able to help in any way?

              Have you tried compiling TVH with the default settings first before you start disabling everything and one by one disable what you don’t require until it crashes.

              I don’t use IPTV with TVH (DVBS only) but I assume your IPTV sources are solid and reliable. Maybe reduce your channel IPTV channel list and slowly add back the remaining channels until it crashes.

              Again just some very basic suggestions to assist your fault finding. You might also want to look at how Timeshift is implemented on your setup too.

                Jonas Lang

                I have previously built TVHeadend using no exclusions and the only inclusion I need of PCRE2. That did not yield any change in the manner of the crash unfortunately.

                The IPTV sources are very solid. Infact they are fed from another TVHeadend that does have DVBS cards in. The server is next to it, connected to the same switch. I never see any issues with TS Timeout or signal issues on that server. That server never crashes, but it does not host a userbase.

                I appreciate those suggestions.

                I have a theory that there is a bug whereby the connected HTSP client does not provide a username AND/OR password and this is causing some authentication bug or null pointer or something similar. However I am not competent enough to understand the C code referenced in the lines where TVHeadend is crashing. I really think I need a developer of TVHeadend to help understand that.

                It would also be useful if I could possibly build TVHeadend possibly trying to record the username/password that is coming into that authenication component to prove or disprove that. Again, I lack the coding skill to know how to implement that.

                If a TVHeadend developer wants to help me resolve this I will gladly donate $500 to the project if they can fix it.

                  P Proton as I suspected your setup is a little more involved than your OP would suggest.

                  Are both units operating on the same LAN I wonder. When you access your main server remotely on a separate client are you experiencing any difficulties. Is it possible to combine all services on one server or do you have a specific reason for having two units running TVH simultaneously.

                  Have you considered running TVH in Docker where you can isolate the two instances of TVH if that’s what you require.

                  It should be interesting to see this thread develop once a developer comes along. Have you reported your issue on the TVH GitHub.

                    Jonas Lang

                    Yes same lan, switch neighbours, there is absolutely no networking issue between them. Nor any reason to suspect the master userbase server is experiencing connectiviy issues with the DVBS feed server.

                    The reason for the segregation is the DVBS server is a TBS MOI PRO that is dedicated for receiving Satellite signals and acting as a mother to feed the problematic server, and another (Also problematic server - The same exact issue - Different hardware/TVH build though), both host users. As the MOI PRO is largely underpowered it is best to home the userbase on a beefy server with lots of RAM so that the userbase can benefit from things like TVHeadends Instant rewind. Also the MOI PRO would be utterly useless at multiple simultanous recordings. So for these two primary reasons, and many others, the feed-in server is seperate from the userbase server.

                    I have not logged a ticket on the GitHub as of yet, do you think that might be a sensible next step? I was hoping I might get more traction from some Devs here as this forum is more of a hive of activity than what it once was!

                      P Proton but the activity is generally one way. You’re more likely to get the attention of a developer on the GitHub.

                      I’ve just a simple setup with a Digibit Twin Sat/IP DVBS receiver and TVH and the client on the one machine and I must admit I’m not familiar with the TBS MOI so I can’t even run any parallel tests to help you.

                        Jonas Lang No problem thanks for the thought. For reference I have checked a few of the scenario's when it did crash and sometimes its not even receiving a feed from that server, so I am certain that is not a related factor anyway.

                        I live in hope a dev can help!

                          P Proton I live in hope a dev can help!

                          A dev did try to help.

                          Flole Not entirely sure what version you're running there, but the current master does not contain any executable code in line 1225 of httpc.c

                          Have you tried installing a pre-compiled package?
                          https://tvheadend.org/p/downloads

                          As @Flole has said, and you have confirmed, there is no executable code on line 1225, so it is a bit of a mystery.

                          tvheadend/tvheadendblob/9ac57a0c1a4551012260008cfca6bfc2386f6dcf/src/httpc.c#L1225

                          If I understand your setup correctly:

                          TVH+DVB-S (IPTV server) -> AutoRec in progress -> TVH (IPTV client) CRASHES.

                          P Proton I have a theory that there is a bug whereby the connected HTSP client does not provide a username AND/OR password and this is causing some authentication bug or null pointer or something similar.

                          You could test this by removing all authentication from the setup and see what happens. If the crash still occurs, then you can eliminate that hypothesis.

                          You could also enable detailed logging on the TVH server to see what request it received from the client just prior to its crash. This could potentially show any malformed authentication request or at least the last successful operation prior to the client crash.

                          Can you also please share the URL that you entered on the client TVH to access the server TVH?

                          Does the crash occur if you are watching a channel via IPTV rather than recording?

                          Does a crash happen on any IPTV channel being recorded or a specific channel or group of channels?