Project

General

Profile

action #124934

Updated by mkittler over 1 year ago

## Observation 

 We sometimes see things like 
 ``` 
 Reason: isotovideo died: Can't locate auto/NetAddr/IP/InetBase/AF_INET6.al in @INC 
 ``` 
 in the info panel of an openQA test. 
 See #124913 for example. 

 This message is distracting because it is actually not a fatal message, but from an eval: 

 https://metacpan.org/dist/NetAddr-IP/source/Lite/Util/lib/NetAddr/IP/InetBase.pm#L81 
 ``` 
 require Socket; 
 
 *AF_INET = \&Socket::AF_INET; 
 
 if (eval { AF_INET6() } ) {         # line 81 
   *AF_INET6 = \&Socket::AF_INET6; 
   $emulateAF_INET6 = -1;                          # have it, remind below 
 } 
 ``` 
 https://github.com/os-autoinst/os-autoinst/blob/master/isotovideo#L115 
 ``` 
 $SIG{__DIE__} = sub ($e) { $fatal_error = $e }; 
 ``` 
 So when NetAddr::IP::InetBase calles the `eval { AF_INET6() }` (thanks to [AutoLoader/AutoSplit](https://metacpan.org/pod/AutoLoader) this actually tries to load the subroutine `AF_INET6` from a generated file `AF_INET6.al`) it is actually fine with it failing, but we still call our signal handler. We could check with `$^S` if we are in an eval and just discard the message if it's true - but see the notes section why that might not be nice. Then we will get rid of those distracting error messages in the Reason, which we have seen several times before. 

 ## Acceptance Criteria 
 **AC1**: We don't display non-fatal distracting error messages anymore 

 ## Notes 

 * [`$^S`](https://perldoc.perl.org/perlvar#$%5ES) 
 * [`%SIG`](https://perldoc.perl.org/perlvar#%25SIG) 

 > The `$SIG{__DIE__}` hook is called even inside an `eval()`. It was never intended to happen this way, but an implementation glitch made this possible. 
 > ... 
 > Having to even think about the `$^S` variable in your exception handlers is simply wrong. `$SIG{__DIE__}` as currently implemented invites grievous and difficult to track down errors. Avoid it and use an `END{}` or `CORE::GLOBAL::die` override instead. 

 ## Suggestions 
 * Put the whole `isotovideo` code (or at least all relevant parts) into an eval-block

Back