Status: New
Owner: ----

New issue 2486 by [email protected]: --print-ast and --print-source segfault with throw statements
http://code.google.com/p/v8/issues/detail?id=2486

With r13362 (today's HEAD):

  $ cat test.js
  throw 42

  $ out/x64.debug/d8 --print-ast test.js
  <snip>
  *** Generate code for user-defined function: KeyedLoadElementStub ***
  Segmentation fault (core dumped)

Ditto for --print-source. The patch below works around it but doesn't address the root cause, i.e. _why_ program == NULL.

diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc
index c0fdf48..7bcaccc 100644
--- a/src/prettyprinter.cc
+++ b/src/prettyprinter.cc
@@ -456,6 +456,7 @@ const char* PrettyPrinter::PrintExpression(FunctionLiteral* program) {


 const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) {
+  if (program == NULL) return "";
   Init();
   PrintStatements(program->body());
   Print("\n");
@@ -707,6 +708,7 @@ void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {


 const char* AstPrinter::PrintProgram(FunctionLiteral* program) {
+  if (program == NULL) return "";
   Init();
   { IndentedScope indent(this, "FUNC");
     PrintLiteralIndented("NAME", program->name(), true);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to