You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Sylwester Lachiewicz (Jira)" <ji...@apache.org> on 2026/10/12 17:34:00 UTC

[jira] [Created] (THRIFT-6404) Report every exception thrown during parsing and auditing as a compiler error

Sylwester Lachiewicz created THRIFT-6404:
--------------------------------------------

             Summary: Report every exception thrown during parsing and auditing as a compiler error
                 Key: THRIFT-6404
                 URL: https://issues.apache.org/jira/browse/THRIFT-6404
             Project: Thrift
          Issue Type: Improvement
          Components: Compiler (General)
            Reporter: Sylwester Lachiewicz


h2. Situation

[THRIFT-6403|https://issues.apache.org/jira/browse/THRIFT-6403] widens the handler in {{generate()}} to {{std::exception}}, so that an exception a generator throws is reported through {{failure()}} instead of aborting the compiler. The other two entry points in [compiler/cpp/src/thrift/main.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/main.cc] are still narrower:

* {{parse()}} catches only {{std::string}}, around both {{yyparse()}} passes.
* {{audit()}} has no handler. Its {{compare_*}} calls run outside any try block.

Two parser paths throw a {{const char*}}, which {{parse()}} does not catch:

* {{throw "Constants cannot be of type VOID"}} in {{t_scope.h}}
* {{throw "unknown value type"}} in the comparison operator of {{t_const_value.h}}

No input is known to reach either. The grammar rejects a {{void}} constant first, and the comparison only throws for a value whose type was never set. All 251 {{.thrift}} files in the repository through {{--gen json -r}}, and all 35 pairs in {{test/audit}} through {{--audit}}, end without an abort on master.

h2. Change

Catch {{const char*}} and {{std::exception}} in {{parse()}} as {{generate()}} does, and wrap the comparisons in {{audit()}} the same way, so that a throw added to the parser or audit later is reported as a compiler error rather than ending the process with an abort.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)