From b58d97e33912a946005fd53e87508de9ebec9ad0 Mon Sep 17 00:00:00 2001 From: Mark Lumsden Date: Fri, 14 Jun 2019 14:27:43 +0000 Subject: Note a segv with fprintf if a file with long lines is loaded with debug code running. --- usr.bin/mg/log.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'usr.bin/mg/log.c') diff --git a/usr.bin/mg/log.c b/usr.bin/mg/log.c index dd9a6568a52..f69b9aae543 100644 --- a/usr.bin/mg/log.c +++ b/usr.bin/mg/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.5 2019/06/12 18:21:07 lum Exp $ */ +/* $OpenBSD: log.c,v 1.6 2019/06/14 14:27:42 lum Exp $ */ /* * This file is in the public domain. @@ -21,6 +21,20 @@ * written in the spirit of debugging (quickly and perhaps not ideal, * but it does what is required well enough). Should debugging become * more formalised within mg, then I would expect that to change. + * + * If you open a file with long lines to run through this debugging + * code, you may run into problems with the 1st fprintf statement in + * in the mglog_lines() function. mg sometimes segvs at a strlen call + * in fprintf - possibly something to do with the format string? + * "%s%p b^%p f.%p %d %d\t%c|%s\n" + * When I get time I will look into it. But since my debugging + * generally revolves around a file like: + * + * abc + * def + * ghk + * + * I don't experience this bug. Just note it for future investigation. */ #include @@ -156,6 +170,7 @@ mglog_lines(PF funct) else tmp = lp->l_text; + /* segv on fprintf below with long lines */ if (fprintf(fd, "%s%p b^%p f.%p %d %d\t%c|%s\n", curline, lp, lp->l_bp, lp->l_fp, lp->l_size, lp->l_used, o, tmp) == -1) { -- cgit v1.2.3