summaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-07-16 11:05:01 -0400
committerMark Stapp <mjs@voltanet.io>2020-07-20 07:31:49 -0400
commit3211b92b8fb7387d6c52e30ae2bbd4fda628a3e2 (patch)
tree335e2e8b9bbe89a39bc1c1bd226f0746b5fa5d30 /lib/stream.c
parent67ce4ba19b00eaa542d12c17c5da0652238a8049 (diff)
lib: add a backtrace when stream bounds check fails
Add a backtrace call when the stream code detects a bounds error, to help with debugging. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/stream.c b/lib/stream.c
index 17520f978e..d3afebbf13 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -55,15 +55,19 @@ DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")
* using stream_put..._at() functions.
*/
#define STREAM_WARN_OFFSETS(S) \
- flog_warn(EC_LIB_STREAM, \
- "&(struct stream): %p, size: %lu, getp: %lu, endp: %lu\n", \
- (void *)(S), (unsigned long)(S)->size, \
- (unsigned long)(S)->getp, (unsigned long)(S)->endp)
+ do { \
+ flog_warn(EC_LIB_STREAM, \
+ "&(struct stream): %p, size: %lu, getp: %lu, endp: %lu\n", \
+ (void *)(S), (unsigned long)(S)->size, \
+ (unsigned long)(S)->getp, (unsigned long)(S)->endp); \
+ zlog_backtrace(LOG_WARNING); \
+ } while (0)
#define STREAM_VERIFY_SANE(S) \
do { \
- if (!(GETP_VALID(S, (S)->getp) && ENDP_VALID(S, (S)->endp))) \
+ if (!(GETP_VALID(S, (S)->getp) && ENDP_VALID(S, (S)->endp))) { \
STREAM_WARN_OFFSETS(S); \
+ } \
assert(GETP_VALID(S, (S)->getp)); \
assert(ENDP_VALID(S, (S)->endp)); \
} while (0)