--- parser3/src/include/pa_request.h 2026/04/24 13:45:12 1.271 +++ parser3/src/include/pa_request.h 2026/10/05 17:50:18 1.282 @@ -1,39 +1,31 @@ /** @file Parser: request class decl. - Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_REQUEST_H #define PA_REQUEST_H -#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.271 2026/04/24 13:45:12 moko Exp $" +#define IDENT_PA_REQUEST_H "$Id: pa_request.h,v 1.282 2026/10/05 17:50:18 moko Exp $" #include "pa_pool.h" #include "pa_hash.h" +#include "pa_file.h" #include "pa_wcontext.h" #include "pa_value.h" +#include "pa_vhash.h" #include "pa_stack.h" #include "pa_request_info.h" #include "pa_request_charsets.h" #include "pa_sapi.h" -// defines for externs - -#define EXCEPTION_HANDLED_PART_NAME "handled" - - // externs extern const String main_method_name; extern const String auto_method_name; -extern const String::Body exception_type_part_name; -extern const String::Body exception_source_part_name; -extern const String::Body exception_comment_part_name; -extern const String::Body exception_handled_part_name; - // defines for statics #define MAIN_CLASS_NAME "MAIN" @@ -54,6 +46,7 @@ class VResponse; class VCookie; class VStateless_class; class VConsole; +class VException; extern int pa_loop_limit; extern int pa_array_limit; @@ -61,6 +54,8 @@ extern int pa_execute_recursion_limit; extern int pa_httpd_timeout; extern size_t pa_file_size_limit; +class Code_cache; + /// Main workhorse. class Request: public PA_Object { friend class Temp_lang; @@ -70,6 +65,8 @@ class Request: public PA_Object { friend class Temp_recursion; friend class Request_context_saver; friend class Exception_trace; + friend class VException; + friend class Code_cache_manager; public: class Trace { @@ -125,6 +122,7 @@ private: size_t bottom_index() { return fbottom; } void set_bottom_index(size_t abottom) { fbottom=abottom; } element_type bottom_value() { return get(bottom_index()); } + void set_range(size_t bottom, size_t top) { fbottom=bottom; fsize=top; } void clear() { fsize=fbottom=0; @@ -134,7 +132,10 @@ private: return fsize==fbottom; } - Table &table(Request &r); + Table &table(Request &r, const String* problem_source) { + return table(r, problem_source, bottom_index(), top_index()); + } + Table &table(Request &r, const String* problem_source, size_t bottom, size_t top); }; ///@{ core data @@ -150,15 +151,17 @@ private: /// endless execute(execute(... preventing counter int anti_endless_execute_recursion; + int execute_recursion_limit; + void recursion_limit_reached(); ///@} /// execution stack Stack stack; +public: /// exception stack trace Exception_trace exception_trace; -public: bool allow_class_replace; @@ -182,14 +185,7 @@ private: public: uint register_file(String::Body file_spec); - struct Exception_details { - const Operation::Origin origin; - const String* problem_source; - VHash& vhash; - Exception_details(const Operation::Origin aorigin, const String* aproblem_source, VHash& avhash): origin(aorigin), problem_source(aproblem_source), vhash(avhash) {} - }; - Exception_details get_details(const Exception& e); - const char* get_exception_cstr(const Exception& e, Exception_details& details); + const char* get_exception_cstr(const Exception& e, VException& details); /// @see Stack::wipe_unused void wipe_unused_execution_stack() { @@ -253,14 +249,18 @@ public: /// execute ops with anti-recursion check void recursion_checked_execute(ArrayOperation& ops) { - if(++anti_endless_execute_recursion>=pa_execute_recursion_limit) { - anti_endless_execute_recursion=0; // give @exception a chance - throw Exception(PARSER_RUNTIME, 0, "call canceled - endless recursion detected"); - } + if(++anti_endless_execute_recursion>=execute_recursion_limit) + recursion_limit_reached(); execute(ops); // execute it anti_endless_execute_recursion--; } + /// take the recovery reserve back if recursion limit is far enough + void recursion_limit_try_restore() { + if(execute_recursion_limit>pa_execute_recursion_limit && anti_endless_execute_recursion