Page MenuHomePhorge

PHP8 error running "ssh conduit"
Open, LowPublic


This task originates from Q89: Fresh batch of PHP 8 deprecated use of strlen with a NULL argument. You will find there the detailed description. Basically:

  • arcanist raises this error when testing SSH support (i.e. when running echo {} | ssh conduit
  • phorge raises this error when moving repositories without specifying --from or --to

Event Timeline

@jeanguyomarch: If you could provide stacktraces of these issues, that would be awesome.

Second issue got already fixed by rPa7fb04f96c92d4ff57ac8c01213e6dd73a03f5d6 which wasn't linked to this ticket

aklapper renamed this task from Fresh batch of PHP 8 deprecated use of strlen with a NULL argument to PHP8 error running "ssh conduit".Mar 1 2024, 12:35
valerio.bozzolan subscribed.

Looking at the mentioned question, it seems a NULL pointer arrives as first argument in phutil_encode_log(). Fortunately that function is used by only 3 places:

  • arcanist PhutilJSONProtocolChannel.php phutil_encode_log($len): no problem, the arg is a string
  • arcanist PhutilJSONProtocolChannel.php phutil_encode_log(substr(...)): as above
  • arcanist PhutilDeferredLog.php phutil_encode_log($map[$c]): 🔶 maybe here it arrives a null pointer instead of a string

But, without a stack trace, we will not find consensus to proceed. Also, I'm unsure if the solution is something like this:

diff --git a/src/filesystem/PhutilDeferredLog.php b/src/filesystem/PhutilDeferredLog.php
index 2193eb3c..fc758439 100644
--- a/src/filesystem/PhutilDeferredLog.php
+++ b/src/filesystem/PhutilDeferredLog.php
@@ -229,7 +229,7 @@ final class PhutilDeferredLog extends Phobject {
       if ($saw_percent) {
         $saw_percent = false;
         if (array_key_exists($c, $map)) {
-          $result .= phutil_encode_log($map[$c]);
+          $result .= phutil_encode_log(coalesce($map[$c], ''));
         } else {
           $result .= '-';

Since there is a possibility that the root problem is under one consumer like PhutilDeferredLog#setData( array( 'something' => NULL ) ) somewhere.

If you can, please share a stack trace. Thanks my friend.