diff --git a/core/lib/Drupal/Core/Routing/CurrentRouteMatch.php b/core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
index b188930..2f4c0dd 100644
--- a/core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
+++ b/core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
@@ -13,7 +13,7 @@
 /**
  * Default object for current_route_match service.
  */
-class CurrentRouteMatch implements RouteMatchInterface {
+class CurrentRouteMatch implements RouteMatchInterface, StackedRouteMatchInterface {
 
   /**
    * The related request stack.
@@ -88,7 +88,7 @@ public function getRawParameters() {
    * @return \Drupal\Core\Routing\RouteMatchInterface
    *   The current route match object.
    */
-  protected function getCurrentRouteMatch() {
+  public function getCurrentRouteMatch() {
     return $this->getRouteMatch($this->requestStack->getCurrentRequest());
   }
 
@@ -118,4 +118,18 @@ protected function getRouteMatch(Request $request) {
     return $route_match;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getMasterRouteMatch() {
+    return $this->getRouteMatch($this->requestStack->getMasterRequest());
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getParentRequest() {
+    return $this->getRouteMatch($this->requestStack->getParentRequest());
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Routing/StackedRouteMatchInterface.php b/core/lib/Drupal/Core/Routing/StackedRouteMatchInterface.php
new file mode 100644
index 0000000..6ef2724
--- /dev/null
+++ b/core/lib/Drupal/Core/Routing/StackedRouteMatchInterface.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Routing\StackedRouteMatchInterface.
+ */
+
+namespace Drupal\Core\Routing;
+
+/**
+ * Defines an interface for a stack of route matches.
+ *
+ * This could be for example used on exception pages.
+ */
+interface StackedRouteMatchInterface extends RouteMatchInterface {
+
+  /**
+   * Gets the current route match.
+   *
+   * @return \Drupal\Core\Routing\RouteMatchInterface
+   */
+  public function getCurrentRouteMatch();
+
+  /**
+   * Gets the master route match..
+   *
+   * @return \Drupal\Core\Routing\RouteMatchInterface
+   */
+  public function getMasterRouteMatch();
+
+  /**
+   * Returns the parent route match of the current.
+   *
+   * @return \Drupal\Core\Routing\RouteMatchInterface\NULL
+   *   The parent route match or NULL, if it the master route match.
+   */
+  public function getParentRequest();
+
+}
+
diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php
index 4e41f6d..5ca3b23 100644
--- a/core/lib/Drupal/Core/Theme/ThemeManager.php
+++ b/core/lib/Drupal/Core/Theme/ThemeManager.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Extension\ThemeHandlerInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Routing\StackedRouteMatchInterface;
 use Symfony\Component\HttpFoundation\RequestStack;
 
 /**
@@ -124,6 +125,9 @@ protected function initTheme(RouteMatchInterface $route_match = NULL) {
     if (!$route_match) {
       $route_match = \Drupal::routeMatch();
     }
+    if ($route_match instanceof StackedRouteMatchInterface) {
+      $route_match = $route_match->getMasterRouteMatch();
+    }
     $theme = $this->themeNegotiator->determineActiveTheme($route_match);
     $this->activeTheme = $this->themeInitialization->initTheme($theme);
   }
