![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Problem Query: select * from table where md5password = crypt('password',salt) The first time this query is run, I see the postgres process bump up to 8MB of ram from where it initializes. On subsequent issues of the same query the postgres's process memory footprint grows each time. |
#3
| |||
| |||
|
|
Table Setup: employeeid integer salt text md5password text Problem Query: select * from table where md5password = crypt('password',salt) |
#4
| |||
| |||
|
|
I can reproduce this in 8.1.3 on FreeBSD 6.0 and Solaris 9. Here's a standalone test case: SELECT crypt(x::text, '$1$salt') FROM generate_series(1, 500) AS g(x); |
#5
| |||
| |||
|
|
Michael Fuhr <mike (AT) fuhr (DOT) org> writes: I can reproduce this in 8.1.3 on FreeBSD 6.0 and Solaris 9. Here's a standalone test case: SELECT crypt(x::text, '$1$salt') FROM generate_series(1, 500) AS g(x); Interesting, because I see no leak with this example on Fedora 4 or HPUX. Platform dependency is sounding more and more likely. |
#6
| |||
| |||
|
|
On Wed, Feb 15, 2006 at 01:43:18PM -0500, Tom Lane wrote: Interesting, because I see no leak with this example on Fedora 4 or HPUX. Platform dependency is sounding more and more likely. Did you test OpenSSL builds? |
#7
| |||
| |||
|
|
Michael Fuhr <mike (AT) fuhr (DOT) org> writes: Did you test OpenSSL builds? Nope, I did not, and that's a good point. Will try again with openssl. |
#8
| |||
| |||
|
|
My non-OpenSSL build shows no memory leak, so the leak and OpenSSL seem to be correlated. I'd be more inclined to suspect a bug in pgcrypto's OpenSSL-specific code than in OpenSSL itself. Will keep digging. |
#9
| |||
| |||
|
|
On Wed, Feb 15, 2006 at 01:43:18PM -0500, Tom Lane wrote: Michael Fuhr <mike (AT) fuhr (DOT) org> writes: I can reproduce this in 8.1.3 on FreeBSD 6.0 and Solaris 9. Here's a standalone test case: SELECT crypt(x::text, '$1$salt') FROM generate_series(1, 500) AS g(x)= ; Interesting, because I see no leak with this example on Fedora 4 or HPUX. Platform dependency is sounding more and more likely. Did you test OpenSSL builds? Both of my systems are built with OpenSSL and that causes pgcrypto to use different code in some places (e.g., px_find_digest() in internal.c and openssl.c). I'll build and test a non-OpenSSL version when I get a chance. -- Michael Fuhr |
|
wrote:</span><blockquote class=3D"gmail_quote" style=3D"border-left: 1= px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"= On Wed, Feb 15, 2006 at 01:43:18PM -0500, Tom Lane wrote:<br>> Michael F= |
|
places (e.g., px_find_digest() in internal.c and openssl.c). I'= ll<br>build and test a non-OpenSSL version when I get a chance. |
#10
| |||
| |||
|
|
Michael Fuhr <mike (AT) fuhr (DOT) org> writes: My non-OpenSSL build shows no memory leak, so the leak and OpenSSL seem to be correlated. I'd be more inclined to suspect a bug in pgcrypto's OpenSSL-specific code than in OpenSSL itself. Will keep digging. The problem appears to be here: static void digest_finish(PX_MD * h, uint8 *dst) { EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr; const EVP_MD *md = EVP_MD_CTX_md(ctx); EVP_DigestFinal(ctx, dst, NULL); /* * Some builds of 0.9.7x clear all of ctx in EVP_DigestFinal. Fix it by * reinitializing ctx. */ EVP_DigestInit(ctx, md); } It looks like this results in a leak of the entire OpenSSL context for each call to pg_crypt. Marko, I trust you've got a better solution for this ... |
![]() |
| Thread Tools | |
| Display Modes | |
| |