Re: maximum number of backtrace frames logged by backtrace_functions

2022-02-07 Thread Peter Eisentraut

On 07.02.22 06:29, Fujii Masao wrote:


On 2022/02/03 23:48, Tom Lane wrote:

Peter Eisentraut  writes:

How about we issue a message when the backtrace is cut off.  Then it's
immediately visible to the user, instead of hidden away somewhere in 
the

documentation.  Something like this (untested):


+1 for idea (I didn't test it either).


+1. I made this change to the patch and confirmed that it worked fine.


Barring any objection, I will commit the patch.


This change looks good to me.  There is also backtrace code in assert.c 
that might want the same treatment.





Re: maximum number of backtrace frames logged by backtrace_functions

2022-02-07 Thread Fujii Masao



On 2022/02/08 1:12, Peter Eisentraut wrote:

This change looks good to me.  There is also backtrace code in assert.c that 
might want the same treatment.


Yeah, that's good idea! The attached patch also adds the same treatment into 
assert.c.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATIONdiff --git a/src/backend/utils/error/assert.c b/src/backend/utils/error/assert.c
index 2da512a2f1..889be8a2e5 100644
--- a/src/backend/utils/error/assert.c
+++ b/src/backend/utils/error/assert.c
@@ -54,6 +54,9 @@ ExceptionalCondition(const char *conditionName,
 
nframes = backtrace(buf, lengthof(buf));
backtrace_symbols_fd(buf, nframes, fileno(stderr));
+   if (nframes >= lengthof(buf))
+   write_stderr("(backtrace limited to %zu frames)\n",
+lengthof(buf));
}
 #endif
 
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986..9933386959 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -966,6 +966,9 @@ set_backtrace(ErrorData *edata, int num_skip)
 
for (int i = num_skip; i < nframes; i++)
appendStringInfo(&errtrace, "\n%s", strfrms[i]);
+   if (nframes >= lengthof(buf))
+   appendStringInfo(&errtrace, "\n(backtrace limited to 
%zu frames)",
+lengthof(buf));
free(strfrms);
}
 #else