codex-minecraft icon indicating copy to clipboard operation
codex-minecraft copied to clipboard

Codex Minecraft does not detect Forge 1.16.5 log as client log, because it is too long and the Regexes are inefficient

Open pavog opened this issue 1 year ago • 1 comments

I have a quite long client log of Forge 1.16.5 with many mods. Unfortunately, this log is not recognized as a client log, but as a server log instead.

I found out that the problem is that the regular expression used to identify it as a Forge client log is inefficient.

From ForgeClientLog.php#L22:

/^\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: ModLauncher running: .*--fml.forgeVersion.*(\n.*)*\n\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: Launching target \'(fml|forge)client\' with arguments.*$/m

The problematic part here is *(\n.*)*. When you run the regex over the linked log, it does not work because the result of preg_match($this->pattern, $this->getLogContent()) in SinglePatternDetector->detect() is false.

When you run this minimal code example:

$content = file_get_contents("test.log");
$pattern = '/^\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: ModLauncher running: .*--fml.forgeVersion.*(\n.*)*\n\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: Launching target \'(fml|forge)client\' with arguments.*$/m';

$result = preg_match($pattern, $content);
var_dump($result);

echo "Error: " . preg_last_error() . "\n";
echo "Message: " . preg_last_error_msg() . "\n";

You will get this output:

bool(false)
Error: 6
Message: JIT stack limit exhausted

pavog avatar Sep 11 '24 13:09 pavog

Ja fix halt

matthi4s avatar Sep 11 '24 13:09 matthi4s