RESOLVED: Running out of memory when long URLs are passed in

I have the following code:

use Slim\Factory\AppFactory;
$app = AppFactory::create();
$app->run();

I call it with this URL:
https://localhost:8443/api2/test/asdf/asdfasdfasdfasdf/asdfasdf/asdfasdf

My Apache server then crashes:
[crit] Memory allocation failed, aborting process.
[Tue Mar 31 15:34:05.903418 2020] [core:notice] [pid 1] AH00052: child pid 265 exit signal Aborted (6)

If I call it with this URL instead, it returns a 404 (as expected):
https://localhost:8443/api2/test/a/s/d/f

This is with Slim 4.4.0 running on PHP 7.3.16 and Apache 2.4.

I have a similar setup and it works without problems.

  • Add the composer autoloader
  • Make sure that you have created the correct .htaccess file(s) in the correct directories
  • Add at least one route
  • Make sure that the base path is set correctly
<?php
// public/index.php

require_once __DIR__ . '/../vendor/autoload.php';

use Slim\Factory\AppFactory;

$app = AppFactory::create();
//$app->setBasePath('/my-sub-directory');

$app->get('/api2/test/a/s/d/f', function ($request, $response) {
    return $response;
});

$app->run();

I took out all the routes as I was trimming it down to the minimum needed to cause the crash. I had routes before.

Did you try it with the longer path I had trouble with?

Yes, and it works like expected (error 404).

It turns out that when I remove ALL of the Slim code, it still happens, so it must be between Apache and PHP. Sorry to have bothered you!