diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 5fc4b7d..82e6ebb 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -347,12 +347,18 @@ function format_backtrace(array $backtrace) {
     else {
       $call['function'] = 'main';
     }
-    foreach ($trace['args'] as $arg) {
-      if (is_scalar($arg)) {
-        $call['args'][] = is_string($arg) ? '\'' . filter_xss($arg) . '\'' : $arg;
-      }
-      else {
-        $call['args'][] = ucfirst(gettype($arg));
+    // Args should never be empty, but it might be if a class method had a
+    // typed parameter, but the use part was not added. Thus, the type of the
+    // parameter would be "unknown" and the class autoloader would have empty
+    // args.
+    if (!empty($trace['args'])) {
+      foreach ($trace['args'] as $arg) {
+        if (is_scalar($arg)) {
+          $call['args'][] = is_string($arg) ? '\'' . filter_xss($arg) . '\'' : $arg;
+        }
+        else {
+          $call['args'][] = ucfirst(gettype($arg));
+        }
       }
     }
     $return .= $call['function'] . '(' . implode(', ', $call['args']) . ")\n";
diff --git a/core/modules/system/lib/Drupal/system/Tests/Error/FormatBacktraceUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Error/FormatBacktraceUnitTest.php
new file mode 100644
index 0000000..9b05909
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Tests/Error/FormatBacktraceUnitTest.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\system\Tests\Common\ValidNumberStepUnitTest.
+ */
+
+namespace Drupal\system\Tests\Error;
+
+use Drupal\simpletest\UnitTestBase;
+
+/**
+ * Tests backtrace formatting by format_backtrace().
+ */
+class FormatBacktraceUnitTest extends UnitTestBase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Format Backtrace validation',
+      'description' => 'Tests backtrace formatting by format_backtrace()',
+      'group' => 'Error',
+    );
+  }
+
+  /**
+   * Tests format_backtrace() with test arrays.
+   */
+  public function testFormatBacktrace() {
+    // Test array.
+    $backtrace = array(
+      array(
+        'class' => 'class',
+        'type' => 'type',
+        'function' => 'function',
+        'args' => array(1, 1., NULL, new \stdClass, 'foo'),
+      ),
+      array(
+        'class' => 'class',
+        'type' => 'type',
+        'function' => 'function',
+      ),
+      array(
+        'function' => 'function',
+        'args' => array(1, 1., NULL, new \stdClass, 'foo'),
+      ),
+
+      array(
+        'function' => 'function',
+      ),
+      array(
+        'args' => array(1, 1., NULL, new \stdClass, 'foo'),
+      ),
+      array(
+      ),
+    );
+
+    $result = 'classtypefunction(1, 1, NULL, Object, \'foo\')
+classtypefunction()
+function(1, 1, NULL, Object, \'foo\')
+function()
+main(1, 1, NULL, Object, \'foo\')
+main()
+';
+
+    // Compare to the given format.
+    $this->assertEqual(format_backtrace($backtrace), $result);
+  }
+
+}
