BUG #16814: Invalid memory access on regexp_match with .* and BRE
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2021-01-07T19:00:01Z
Lists: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 16814
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 13.1
Operating system: Ubuntu 20.04
Description:
When executing the following regexp call:
select regexp_match('abc', '.*', 'b');
valgrind detects an error:
==00:00:00:46.767 138746== Conditional jump or move depends on uninitialised
value(s)
==00:00:00:46.767 138746== at 0x4657A9: parseqatom (regcomp.c:990)
==00:00:00:46.767 138746== by 0x465CBD: parsebranch (regcomp.c:753)
==00:00:00:46.767 138746== by 0x465E84: parse (regcomp.c:683)
==00:00:00:46.767 138746== by 0x467F24: pg_regcomp (regcomp.c:404)
==00:00:00:46.767 138746== by 0x57D100: RE_compile_and_cache
(regexp.c:185)
==00:00:00:46.767 138746== by 0x57D3D9: setup_regexp_matches
(regexp.c:1114)
==00:00:00:46.767 138746== by 0x57DF86: regexp_match (regexp.c:985)
==00:00:00:46.767 138746== by 0x36839A: ExecInterpExpr
(execExprInterp.c:699)
==00:00:00:46.767 138746== by 0x3657C9: ExecInterpExprStillValid
(execExprInterp.c:1802)
==00:00:00:46.767 138746== by 0x42A172: ExecEvalExprSwitchContext
(executor.h:316)
==00:00:00:46.767 138746== by 0x42A172: evaluate_expr (clauses.c:4809)
==00:00:00:46.767 138746== by 0x42A34B: evaluate_function
(clauses.c:4339)
==00:00:00:46.767 138746== by 0x42C1ED: simplify_function
(clauses.c:3969)
(This was discovered on the back of the new test module test_regex with the
slightly modified 30.4:
select * from test_regex('.*b', 'aab', 'b');
)
Commits
-
Fix ancient bug in parsing of BRE-mode regular expressions.
- afcc8772edce 14.0 landed
- 8354371d0a53 12.6 landed
- 769908811b8b 11.11 landed
- 49c928c0c067 13.2 landed
- 2d540ac5f1f3 10.16 landed
- 0c23f30fad29 9.5.25 landed
- 085a1cfb3d5f 9.6.21 landed