)]}'
{
  "commit": "e68870e4cdd55352cce29c4fcb51414734ad713e",
  "tree": "5860008ee8008601a8731731b8263592beba2e54",
  "parents": [
    "f6ed490b6781e55074a21b2e05047ea7f9db688a"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Mon Sep 15 14:20:52 2025 +0100"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Fri Oct 03 13:20:50 2025 +0100"
  },
  "message": "gdbserver: prevent assertion caused by passing empty program name\n\nWhile testing another patch I\u0027m working on I discovered that passing\nan empty program name to gdbserver would trigger an assertion, like\nthis:\n\n  $ gdbserver --multi :54321 \"\"\n  ../../gdb/gdbserver/../gdb/nat/fork-inferior.c:240: A problem internal to GDBserver has been detected.\n  fork_inferior: Assertion `exec_file !\u003d nullptr\u0027 failed.\n\nUser input, no matter how weird, shouldn\u0027t be triggering an assertion,\nso lets fix that.\n\nIn extended mode, it is valid to start gdbserver without an executable\nname, like this:\n\n  $ gdbserver --multi :54321\n\nHere gdbserver doesn\u0027t start an inferior, and it is up to GDB to\nconnect, and tell gdbserver what to run, and to then start it running.\n\nI did wonder if the empty string case should handled like the no\nexecutable name case, but then you get into the situation where the\nuser can specify command line arguments without an inferior, like:\n\n  $ gdbserver --multi :54321 \"\" a b c\n\nAnd while there\u0027s nothing really wrong with this, and I\u0027m sure someone\ncould come up with a use case for it.  I\u0027d like to propose that for\nnow at least, we take the simple approach of not allowing an empty\nexecutable name, instead we should give an error, like this:\n\n  $ gdbserver --multi :54321 \"\"\n  No program to debug\n  Exiting\n\nWe can always relax this requirement in the future, and allow the\nempty executable with or without inferior arguments, if we decide\nthere\u0027s a compelling reason for it.  It would be simple enough to add\nthis in the future, but once we add support for it, it\u0027s much harder\nto remove the feature in the future, so lets start simple.\n\nThe non-extended remote case works much the same.  It too triggers the\nassertion currently, and after this patch exits with the same error.\n\nOf course, the non-extended remote case never supported not having an\ninferior, if you did:\n\n  $ gdbserver :54321\n\nYou\u0027d be shown the usage text and gdbserver would exit.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a9cb9abb76ff9bedcf56a60aa30543991381c333",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.server/server-empty-exec-name.exp"
    },
    {
      "type": "modify",
      "old_id": "5b40600f457c6427b2e3b541f9d45e870069693d",
      "old_mode": 33188,
      "old_path": "gdbserver/server.cc",
      "new_id": "cb1a63e2c8faa3a71be00bb782ac3470317deb20",
      "new_mode": 33188,
      "new_path": "gdbserver/server.cc"
    }
  ]
}
