apptime crasht FHEM: argument is not a reference at ./FHEM/98_apptime.pm line 12

Begonnen von vbs, 12 April 2019, 13:27:41

Vorheriges Thema - Nächstes Thema

vbs

Ich hab ein aktuelles FHEM und bei jedem Aufruf von "apptime" crasht mein FHEM mit folgender Meldung:
argument is not a reference at ./FHEM/98_apptime.pm line 127.


War für mich im Code nicht spontan ersichtlich, woran es liegt. Hat jemand eine Idee bzw. könnte das fixen? Danke!

vbs

Niemand eine Idee? Ich schließe daraus mal, dass das nur bei mir auftritt? Hm... seltsam...

vbs

@martinp876
Ich glaube, ich hab jetzt eine Idee, woran es liegt:

Es sind zwei Stellen im Code meiner Meinung nach problematisch. Die großen Fragen, die sich mir stellen sind: "Warum ging das jemals? (konnte nicht herausfinden, dass sich das kürzlich geändert hat)" und "Warum ist das offenbar nur bei mir ein Problem?".

Stelle 1 - Zeile 122:
  if(%prioQueues) {
-->my $nice = minNum(keys %prioQueues); <--
    my $entry = shift(@{$prioQueues{$nice}});
    delete $prioQueues{$nice} if(!@{$prioQueues{$nice}});


Die Funktion "minNum" erwartet eigentlich ein Skalar und ein Array. Hier wird nur ein Array übergeben. In der Funktion kommt dann als erster Parameter nur die Länge des Arrays an (meine Vermutung).

Habe die Zeile bei mir in das geändert:
    my $nice = minNum(19, keys %prioQueues); # 19 is highest nice factor

Stelle 2 - Zeile 132:
    ($shortarg,undef) = split(/:|;/,$shortarg,2);

"split" liefert undef zurück, falls man als Parameter einen leeren String zurück gibt. Der Code erwartet aber als Rückgabewert immer einen String. Wenn undef kommt, dann gehen spätere Konkatenationen schief.

Hab bei mir an die Zeile ein if angehängt:
    ($shortarg,undef) = split(/:|;/,$shortarg,2) if length $shortarg > 0;

Gibt bestimmt noch elegantere Wege... oder ich bin auf dem Holzweg und es gibt eine Erklärung, warum das jetzt (nur) bei mir überhaupt ein Thema ist...

martinp876

hört sich gut an. Allerdings ist die nice ermittlung aus fhem.pl. Apptime sollte/wollte/darf diesen Code nicht ändern. Es soll ja - bis auf die Timing-Berechnung - identisch sein.

Ich baue es ein...


vbs

Hm ich bekomme jetzt ständig das hier:
2019.07.12 11:41:47.707 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2019.07.12 11:41:47.708 1 : stacktrace:
2019.07.12 11:41:47.708 1 : main::__ANON__ called by ./FHEM/98_apptime.pm (106)
2019.07.12 11:41:47.708 1 : main::HandleTimeout called by fhem.pl (671)
2019.07.12 11:41:48.463 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2019.07.12 11:41:48.463 1 : stacktrace:
2019.07.12 11:41:48.464 1 : main::__ANON__ called by ./FHEM/98_apptime.pm (106)
2019.07.12 11:41:48.464 1 : main::HandleTimeout called by fhem.pl (671)
2019.07.12 11:41:48.507 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2019.07.12 11:41:48.507 1 : stacktrace:
2019.07.12 11:41:48.507 1 : main::__ANON__ called by ./FHEM/98_apptime.pm (106)
2019.07.12 11:41:48.507 1 : main::HandleTimeout called by fhem.pl (671)
2019.07.12 11:41:52.041 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2019.07.12 11:41:52.042 1 : stacktrace:
2019.07.12 11:41:52.042 1 : main::__ANON__ called by ./FHEM/98_apptime.pm (106)
2019.07.12 11:41:52.042 1 : main::HandleTimeout called by fhem.pl (671)
2019.07.12 11:41:52.083 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2019.07.12 11:41:52.083 1 : stacktrace:
2019.07.12 11:41:52.084 1 : main::__ANON__ called by ./FHEM/98_apptime.pm (106)
2019.07.12 11:41:52.084 1 : main::HandleTimeout called by fhem.pl (671)


Hängt vermtl. damit zusammen?

vbs

@martinp876
Die Warnings aus dem letzten Post kommen weiterhin alle paar Sekunden bei mir.


killah78

@martinp876
Ich bin derzeit am "aufräumen" und finde diesen Fehler auch bei mir im Log:
2020.11.26 15:24:09.761 1: PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2020.11.26 15:24:09.761 1: stacktrace:
2020.11.26 15:24:09.762 1:     main::__ANON__                      called by ./FHEM/98_apptime.pm (106)
2020.11.26 15:24:09.762 1:     main::HandleTimeout                 called by fhem.pl (677)


Zitat von: martinp876 am 26 Mai 2019, 09:12:43
Ich baue es ein...

vbs

Ich kriege diese warnings immer noch permanent:
2021.10.05 16:31:56.608 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2021.10.05 16:31:56.609 1 : stacktrace:
2021.10.05 16:31:56.609 1 :     main::__ANON__                      called by ./FHEM/98_apptime.pm (106)
2021.10.05 16:31:56.609 1 :     main::HandleTimeout                 called by fhem.pl (695)
2021.10.05 16:31:56.623 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2021.10.05 16:31:56.623 1 : stacktrace:
2021.10.05 16:31:56.623 1 :     main::__ANON__                      called by ./FHEM/98_apptime.pm (106)
2021.10.05 16:31:56.623 1 :     main::HandleTimeout                 called by fhem.pl (695)
2021.10.05 16:31:56.624 1 : PERL WARNING: Use of uninitialized value $shortarg in concatenation (.) or string at ./FHEM/98_apptime.pm line 106.
2021.10.05 16:31:56.624 1 : stacktrace:
2021.10.05 16:31:56.624 1 :     main::__ANON__                      called by ./FHEM/98_apptime.pm (106)
2021.10.05 16:31:56.624 1 :     main::HandleTimeout                 called by fhem.pl (695)