From 45917d495c14f3ce37bbf0848262ad8a470030f3 Mon Sep 17 00:00:00 2001 From: "Dylan T." Date: Sun, 8 Dec 2024 16:52:33 +0000 Subject: [PATCH] Fixed CrashDump incorrectly detecting phar core crashes as plugin crashes (#6564) fixes #6563 Since #6217 was merged, \pocketmine\PATH no longer includes the path of the original phar. This means that the frame originating from the phar stub would not get its path cleaned up, leading to it being incorrectly detected as a plugin frame. We should probably explore better methods of detecting plugin crashes in the future; however this fix should solve the immediate issue. --- build/server-phar-stub.php | 2 ++ src/PocketMine.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/build/server-phar-stub.php b/build/server-phar-stub.php index b4018e3a7..c713636c4 100644 --- a/build/server-phar-stub.php +++ b/build/server-phar-stub.php @@ -25,6 +25,7 @@ namespace pocketmine\server_phar_stub; use function clearstatcache; use function copy; +use function define; use function fclose; use function fflush; use function flock; @@ -165,4 +166,5 @@ $start = hrtime(true); $cacheName = preparePharCache($tmpDir, __FILE__); echo "Cache ready at $cacheName in " . number_format((hrtime(true) - $start) / 1e9, 2) . "s\n"; +define('pocketmine\ORIGINAL_PHAR_PATH', __FILE__); require 'phar://' . str_replace(DIRECTORY_SEPARATOR, '/', $cacheName) . '/src/PocketMine.php'; diff --git a/src/PocketMine.php b/src/PocketMine.php index b2e1cd046..ffcfd91db 100644 --- a/src/PocketMine.php +++ b/src/PocketMine.php @@ -282,6 +282,11 @@ JIT_WARNING exit(0); } + if(defined('pocketmine\ORIGINAL_PHAR_PATH')){ + //if we're inside a phar cache, \pocketmine\PATH will not include the original phar + Filesystem::addCleanedPath(ORIGINAL_PHAR_PATH, Filesystem::CLEAN_PATH_SRC_PREFIX); + } + $cwd = Utils::assumeNotFalse(realpath(Utils::assumeNotFalse(getcwd()))); $dataPath = getopt_string(BootstrapOptions::DATA) ?? $cwd; $pluginPath = getopt_string(BootstrapOptions::PLUGINS) ?? $cwd . DIRECTORY_SEPARATOR . "plugins";