ShephedProject / shepherd

Shepherd delivers reliable, high-quality Australian TV guide data (EPG).
Other
20 stars 14 forks source link

Infinite loop with IO::Socket::SSL >= 2.076 #31

Closed willat8 closed 1 year ago

willat8 commented 1 year ago

The die override here has some undesirable interaction with a change in IO::Socket::SSL 2.076

https://github.com/ShephedProject/shepherd/blob/4c75eeef85641d0ec145b43576efb11e6d25c56b/applications/shepherd#L3110-L3130

Specifically the change at https://github.com/noxxi/p5-io-socket-ssl/commit/748ad390c70c38ec9d92aafb5a4a23534c655f44#diff-d1cdb9f512f51b16007345ca2037a640735689038dd631b9c79cd8d953334309R3479

This can be reproduced minimally with the following:

#!/usr/bin/env perl

BEGIN { *CORE::GLOBAL::die = \&my_die; }

use Net::SSLeay;

my %trace_constants = map { $_ => eval { Net::SSLeay->$_ } || -1 } qw(
    DTLS1_VERSION
);

print %trace_constants;

# ugly hack. please don't try this at home kids!
sub my_die {
    my ($arg,@rest) = @_;
    my ($pack,$file,$line,$sub) = caller(0);

    # check if we are in an eval()
    if ($^S) {
        printf STDERR "* Caught a die() within eval{} from file $file line $line\n";
            if ($arg){
                    print STDERR $arg;
            } else {
                    print STDERR join("",@rest)
            }
    } else {
                printf STDERR "\nDIE: line %d in file %s\n",$line,$file;
            if ($arg) {
                        CORE::die($arg,@rest);
            } else {
                        CORE::die(join("",@rest));
            }
    }
}

The my %trace_constants = map { $_ => eval { Net::SSLeay->$_ } || -1 } qw(DTLS1_VERSION); will infinite loop since Net::SSLeay->DTLS1_VERSION will try to die. I don't really understand why...

A temporary workaround is to add a CORE::die above (not sure what bad effects that could have).

diff --git a/applications/shepherd b/applications/shepherd
index 33d0144..df36775 100755
--- a/applications/shepherd
+++ b/applications/shepherd
@@ -3119,6 +3119,7 @@ sub my_die {
            } else {
                    print STDERR join("",@rest)
            }
+        CORE::die;
     } else {
                printf STDERR "\nDIE: line %d in file %s\n",$line,$file;
            if ($arg) {
smkranz0506 commented 1 year ago

Hello,

I encountered this issue too recently when i updated from Debian 11 to Debian 12. I was trying to write a message to the google group "shepherd-list" but my messages were not getting through. I made the change you suggested and my shepherd is in the middle of running for the first time in 4 days. Will reply back once it finishes.

Thanks, you're a lifesaver! Simon

smkranz0506 commented 1 year ago

Just following up from last night. It ran fine but hadn't entered the data into mythtv database - i think due to me invoking shepherd directly via command line and not from "mythfilldatabase". I ran mythfilldatabase tonight and now it's finished the job. I'll monitor over the next week or so to see if there were any ill effects.

thiakil commented 1 year ago

Sorry for not noticing this for so long.

While I don't know why Shep overrides die like that, it seems odd that Net::SSLeay->DTLS1_VERSION would die - it's a constant as far as I can find. Sounds more like a problem outside Shepherd

What version of Net::SSLeay is installed?

smkranz0506 commented 1 year ago

Hello,

using cpan -D Net::SSLeay on my debian 12 machine shows the following:

CPAN: Module::CoreList loaded ok (v5.20220520) (no description) C/CH/CHRISN/Net-SSLeay-1.92.tar.gz /usr/lib/x86_64-linux-gnu/perl5/5.36/Net/SSLeay.pm Installed: 1.92 CPAN: 1.92 up to date Chris Novakovic (CHRISN) chrisn@cpan.org

I believe the search for DTLS1_VERSION looks for a particular file but this file doesn't exist on the debian system nor did it exist in the previous debian (11) where shepherd worked fine.

thiakil commented 1 year ago

removed the global override, so should be fixed