#4017 closed defect (fixed)
lwgeom lexer memory corruption
Reported by: | petere | Owned by: | strk |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 2.5.0 |
Component: | liblwgeom | Version: | master |
Keywords: | Cc: |
Description
We have experienced frequent crashes in PostGIS, with backtraces pointing to memory corruption in the lwgeom lexer. I believe the attached patch fixes the problem. We have had it running for about a week without crashes, where before, they were quite frequent.
The problem is that if a query is aborted while the lexer is running (e.g., statement timeout), the memory belonging to the internal lexer state is cleaned up by PostgreSQL, but the flex code thinks it's still there, so it will crash the next time the lexer runs. The fix is to reinitialize the flex globals before each run. (The same problem once existed in the core PostgreSQL code.)
The problem was observed in version 2.2, but the same code exists in trunk as well. I suggest the fix could be backpatched.
(You should regenerated the .c files using your preferred flex version.)
Attachments (1)
Change History (13)
by , 7 years ago
Attachment: | 0001-Initialize-lwgeom-lexer-on-each-run.patch added |
---|
In 16422: