GNU bug report logs -
#23717
[PATCH 6/6] grep: do pagesize initialization and buffer allocation earlier
Previous Next
Reported by: Zev Weiss <zev <at> bewilderbeest.net>
Date: Tue, 7 Jun 2016 06:39:06 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23717 in the body.
You can then email your comments to 23717 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#23717
; Package
grep
.
(Tue, 07 Jun 2016 06:39:06 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Zev Weiss <zev <at> bewilderbeest.net>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Tue, 07 Jun 2016 06:39:06 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* src/grep.c (reset, main): We're going to need pagesize and buffer
initialized anyway, so we might as well do so unconditionally early on
rather than checking on every call to reset().
---
src/grep.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/grep.c b/src/grep.c
index d01bc4f..302e4d7 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -769,16 +769,6 @@ all_zeros (char const *buf, size_t size)
static bool
reset (int fd, struct stat const *st)
{
- if (! pagesize)
- {
- pagesize = getpagesize ();
- if (pagesize == 0 || 2 * pagesize + 1 <= pagesize)
- abort ();
- bufalloc = (ALIGN_TO (INITIAL_BUFSIZE, pagesize)
- + pagesize + sizeof (uword));
- buffer = xmalloc (bufalloc);
- }
-
bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize);
bufbeg[-1] = eolbyte;
bufdesc = fd;
@@ -2252,6 +2242,12 @@ main (int argc, char **argv)
set_program_name (argv[0]);
program_name = argv[0];
+ pagesize = getpagesize ();
+ if (pagesize == 0 || 2 * pagesize + 1 <= pagesize)
+ abort ();
+ bufalloc = (ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + sizeof (uword));
+ buffer = xmalloc (bufalloc);
+
keys = NULL;
keycc = 0;
with_filenames = false;
--
2.8.0.rc3
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Mon, 22 Aug 2016 06:29:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Zev Weiss <zev <at> bewilderbeest.net>
:
bug acknowledged by developer.
(Mon, 22 Aug 2016 06:29:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 23717-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks, I see this one was also installed in June and so am closing the bug report.
I noticed that the old code and the new both have some glitches with respect to
large page sizes, so I installed the attached further patch to fix them. I've
never used grep on a machine with 2 GiB pages, but such beasts exist nowadays
and we might as well make grep safe for them.
[0001-grep-minor-tweaks-of-initial-buffer-alloc.patch (text/x-diff, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 19 Sep 2016 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 235 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.