![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||||
| |||||
|
|
I'm from the Stanford Metacompilation research group where we use static analysis to find bugs. |
|
[BUG] memory leak of vacrelstats at end of function laxy_vaccum_rel() File where bug occurred: postgresql-7.4.2/src/backend/commands/vacuumlazy.c |
|
[BUG] memory leak on error path (dtype != DTK_DELTA) File where bug occurred: postgresql-7.4.2/src/interfaces/ecpg/pgtypeslib/interval.c |
|
[BUG] difficult to analyze, but it appears that subquery is memory leaked File where bug occurred: postgresql-7.4.2/src/backend/optimizer/plan/subselect.c |
|
[BUG] memory leak, pformats is allocated but never freed or stored anywhere |
#3
| |||
| |||
|
|
On 2-May-04, at 2:05 PM, Ted Kremenek wrote: I'm from the Stanford Metacompilation research group where we use static analysis to find bugs. Neat. BTW, I saw a talk last summer from Madanlal Musuvathi on some model checking work which I believe is being done by a related group at Stanford; it was very interesting. The problem with applying this kind of static analysis to PostgreSQL is that palloc() is not like malloc(): if the return value goes out of scope before it is freed, it is NOT necessarily the case that a memory leak has occurred. Each palloc() allocation occurs within a "memory context" (a.k.a an arena, if you're familiar with the usage in tcc). Individual allocations can be released via pfree(), or the entire memory context and all memory allocated within it can be released via MemoryContextReset() or a similar function. Some areas of the code bother doing a pfree() for each palloc(); some do not. [BUG] memory leak of vacrelstats at end of function laxy_vaccum_rel() File where bug occurred: postgresql-7.4.2/src/backend/commands/vacuumlazy.c I believe the CommitTransactionCommand() at vacuum.c:894 (which calls CommitTransaction(), which calls AtCommit_Memory(), which performs a MemoryContextDelete()) deallocates this memory reasonably soon after it has been allocated, so this isn't a bug. [BUG] memory leak on error path (dtype != DTK_DELTA) File where bug occurred: postgresql-7.4.2/src/interfaces/ecpg/pgtypeslib/interval.c Looks suspicious to me, but ECPG is Michael Meskes' domain -- Michael? [BUG] difficult to analyze, but it appears that subquery is memory leaked File where bug occurred: postgresql-7.4.2/src/backend/optimizer/plan/subselect.c Not sure about this one -- I didn't bother tracking down exactly where the memory context manipulation happens, but I think it's likely that we release this memory fairly soon after it's allocated. [BUG] memory leak, pformats is allocated but never freed or stored anywhere Doesn't look like a bug to me: pformats is allocated in the MessageContext (e.g. tcop/postgres.c:1308), which is reset for every FE command that is processed (e.g. postgres.c:2849). -Neil |
#4
| |||
| |||
|
|
The problem with applying this kind of static analysis to PostgreSQL is that palloc() is not like malloc(): if the return value goes out of scope before it is freed, it is NOT necessarily the case that a memory leak has occurred. |
|
[BUG] memory leak on error path (dtype != DTK_DELTA) File where bug occurred: postgresql-7.4.2/src/interfaces/ecpg/pgtypeslib/interval.c Looks suspicious to me, but ECPG is Michael Meskes' domain -- Michael? |
#5
| |||
| |||
|
|
Neil Conway <neilc (AT) samurai (DOT) com> writes: The problem with applying this kind of static analysis to PostgreSQL is that palloc() is not like malloc(): if the return value goes out of scope before it is freed, it is NOT necessarily the case that a memory leak has occurred. I'm a bit surprised that a tool unaware of this fact would generate only four complaints ... I'd have expected hundreds. I concur with Neil's opinion that none of the backend cases represent bugs. However: [BUG] memory leak on error path (dtype != DTK_DELTA) File where bug occurred: postgresql-7.4.2/src/interfaces/ecpg/pgtypeslib/interval.c Looks suspicious to me, but ECPG is Michael Meskes' domain -- Michael? It's entirely likely that ecpg's derivative of the backend's datetime modules contains lots and lots of memory leaks, since AFAIK the palloc infrastructure is not there in the ecpg environment :-(. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html |
#6
| |||
| |||
|
|
[BUG] memory leak on error path (dtype != DTK_DELTA) File where bug occurred: postgresql-7.4.2/src/interfaces/ecpg/pgtypeslib/interval.c Looks suspicious to me, but ECPG is Michael Meskes' domain -- Michael? It's entirely likely that ecpg's derivative of the backend's datetime modules contains lots and lots of memory leaks, since AFAIK the palloc infrastructure is not there in the ecpg environment :-(. |
![]() |
| Thread Tools | |
| Display Modes | |
| |