Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-23 Thread Xiaoran Wang
Hi, I would like to update something about this idea. I attached a new patch 0003-Imporve-pg_re_throw-check-if-sigjmp_buf-is-valid-and.patch. Not too many updates in it: - replace the 'ereport' with Assert - besides checking the PG_exception_stack->magic, also check the address of PG_exception_sta

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-20 Thread Xing Guo
Hi On Mon, Aug 19, 2024 at 10:12 PM Tom Lane wrote: > > We have had multiple instances of code "return"ing out of a PG_TRY, > so I fully agree that some better way to detect that would be good. > But maybe we ought to think about static analysis for that. I have some static analysis scripts for

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-19 Thread Xiaoran Wang
Tom Lane 于2024年8月20日周二 11:44写道: > Xiaoran Wang writes: > >> Yeah, that's the big problem. I don't have any confidence at all > >> that this would detect misuse. It'd require that the old stack > >> frame gets overwritten, which might not happen for a long time, > >> and it'd require that someb

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-19 Thread Tom Lane
Xiaoran Wang writes: >> Yeah, that's the big problem. I don't have any confidence at all >> that this would detect misuse. It'd require that the old stack >> frame gets overwritten, which might not happen for a long time, >> and it'd require that somebody eventually do a longjmp, which again >>

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-19 Thread Xiaoran Wang
Xiaoran Wang 于2024年8月20日周二 11:32写道: > > > Tom Lane 于2024年8月19日周一 22:12写道: > >> Robert Haas writes: >> > On Mon, Aug 19, 2024 at 2:17 AM Xiaoran Wang >> wrote: >> >> If the code in PG_TRY contains any non local control flow other than >> >> ereport(ERROR) like goto, break etc., the PG_CATCH or

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-19 Thread Xiaoran Wang
Tom Lane 于2024年8月19日周一 22:12写道: > Robert Haas writes: > > On Mon, Aug 19, 2024 at 2:17 AM Xiaoran Wang > wrote: > >> If the code in PG_TRY contains any non local control flow other than > >> ereport(ERROR) like goto, break etc., the PG_CATCH or PG_END_TRY cannot > >> be called, then the PG_exce

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-19 Thread Tom Lane
Robert Haas writes: > On Mon, Aug 19, 2024 at 2:17 AM Xiaoran Wang wrote: >> If the code in PG_TRY contains any non local control flow other than >> ereport(ERROR) like goto, break etc., the PG_CATCH or PG_END_TRY cannot >> be called, then the PG_exception_stack will point to the memory whose >>

Re: Improve pg_re_throw: check if sigjmp_buf is valid and report error

2024-08-19 Thread Robert Haas
On Mon, Aug 19, 2024 at 2:17 AM Xiaoran Wang wrote: > If the code in PG_TRY contains any non local control flow other than > ereport(ERROR) like goto, break etc., the PG_CATCH or PG_END_TRY cannot > be called, then the PG_exception_stack will point to the memory whose > stack frame has been releas