public inbox for [email protected]  
help / color / mirror / Atom feed
From: Fujii Masao <[email protected]>
To: Peter Eisentraut <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: maximum number of backtrace frames logged by backtrace_functions
Date: Tue, 8 Feb 2022 01:42:49 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>



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 CORPORATION
diff --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


Attachments:

  [text/plain] backtrace_limit_report_v2.patch (999B, 2-backtrace_limit_report_v2.patch)
  download | inline diff:
diff --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


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: maximum number of backtrace frames logged by backtrace_functions
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox