RFC grep: almost no more leaks, hopefully no crashes
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 RFC Latest3 patches 15 repliesIn review
- v4 RFC3 patches 1 replySuperseded
- v3 RFC3 patches 13 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 3 patches | 4 replies | Superseded |
Changes in v5 from the cover letter
* git log change reverted, still not sure where it will fit better and worst case will leak a few bytes when -P is used.
since the users of this API are doing it indirectly it might be problematic long term though, but luckily since it is most of the tine a NOOP and can be called multiple times might be ok to do it unconditionally
* slightly better looking code
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | grep: make PCRE1 aware of custom allocatorMakefile grep.c | +11 | 0 replies | |
| 2/3 | grep: make PCRE2 aware of custom allocatorbuiltin/ grep.c grep.h | +57 | 7 replies | |
| 3/3 | grep: avoid leak of chartables in PCRE2grep.c grep.h | +5 | 0 replies |
Reviews trailers per patch
None of the 3 patches has a Reviewed-by or Acked-by.
| Patch | René Scharfe |
|---|---|
| 1/3 | |
| 2/3 | Helped-by |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC PATCH v5 0/3] grep: almost no more leaks, hopefully no crashes
This series is a candidate reroll for cb/pcre2-chartables-leakfix, that hopefully addresses the root cause of the problem reported by Dscho in Windows, where the PCRE2 library wasn't aware of the custom allocator and was returning a pointer created with the system malloc but passing it to NED's free, resulting in a segfault.
The most likely reason why it was triggered by the original leak fix is the layering violation reported by René and that is likely exclusive to PCRE2 (hence why it hasn't been reported with PCRE1). Additional work might be available in a future release of PCRE2 to address that as detailed in an upstream bug[1] report.
Changes since v4 (only in patch 2):
* git log change reverted, still not sure where it will fit better and worst case will leak a few bytes when -P is used.
since the users of this API are doing it indirectly it might be problematic long term though, but luckily since it is most of the tine a NOOP and can be called multiple times might be ok to do it unconditionally
* slightly better looking code
Changes since v3 (mostly in patch 2):
* git log also calls the "destructor" for grep API
* no more "bug" being triggered by make test, sorry René
* hopefully no more crashes in windows (I was expecting at most a BUG)
Future work (other than the needed refactoring explained in the second patch) and adjacent bugs, includes:
* tracking more possible users of the grep API that might need to call grep_destroy()
* completely moving PCRE2 to use NED (as is done with PCRE1 and was proposed on the original patch[2] this is based on
* build on top of the new API so that other work could be shared (for example the chartables that started this whole mess)
or (hopefully not)
* ignore the original leak (maybe with an UNLEAK) as René suggested [3]
* discard this work and just use Dscho's fix (with some improvements, like using xmalloc)
[1] https://bugs.exim.org/show_bug.cgi?id=2429
[2] https://public-inbox.org/git/3397e6797f872aedd18c6d795f4976e1c579514b.1565005867.git.gitgitgadget@gmail.com/
[3] https://public-inbox.org/git/[email protected]/
Carlo Marcelo Arenas Belón (3):
grep: make PCRE1 aware of custom allocator
grep: make PCRE2 aware of custom allocator
grep: avoid leak of chartables in PCRE2
Makefile | 2 +- builtin/grep.c | 1 + grep.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++--- grep.h | 2 ++ 4 files changed, 72 insertions(+), 4 deletions(-)
base-commit: 51cf315870bbb7254ddf06c84fe03b41bc48eebd
Signature · 1 line
2.23.0.rc1