diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 08c7aff..622339e 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Template\Attribute;
@@ -13,6 +14,7 @@
 use Drupal\menu_link\MenuLinkStorageController;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Symfony\Component\Routing\Exception\ResourceNotFoundException;
 use Symfony\Component\Routing\Route;
 
 /**
@@ -975,6 +977,9 @@ function menu_item_route_access(Route $route, $href, &$map) {
   catch (NotFoundHttpException $e) {
     return FALSE;
   }
+  catch (ResourceNotFoundException $e) {
+    throw new ResourceNotFoundException(String::format("The route for '@href' could not be found", array('@href' => $href)));
+  }
 
   // Populate the map with any matching values from the request.
   $path_bits = explode('/', trim($route->getPath(), '/'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php
index 3059164..5541b9f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\system\Tests\Routing;
 
 use Drupal\simpletest\WebTestBase;
+use Symfony\Component\Routing\Exception\ResourceNotFoundException;
 
 /**
  * Basic tests for access permissions in routes.
@@ -33,8 +34,20 @@ public static function getInfo() {
    * Tests permission requirements on routes.
    */
   public function testPermissionAccess() {
-    $this->drupalGet('router_test/test7');
+    $path = 'router_test/test7';
+    $this->drupalGet($path);
     $this->assertResponse(403, "Access denied for a route where we don't have a permission");
+    // An invalid path should throw an exception.
+    $map = array();
+    $route = \Drupal::service('router.route_provider')->getRouteByName('router_test_7');
+    try {
+      menu_item_route_access($route, $path . 'invalid', $map);
+      $exception = FALSE;
+    }
+    catch (ResourceNotFoundException $e) {
+      $exception = TRUE;
+    }
+    $this->assertTrue($exception, 'A ResourceNotFoundException was thrown while checking access for an invalid route.');
 
     $this->drupalGet('router_test/test8');
     $this->assertResponse(403, 'Access denied by default if no access specified');
