You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2012/01/25 19:52:44 UTC

DO NOT REPLY [Bug 52528] New: apr_dbd_get_driver doesn't clean up nice when failing to load a module

https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

             Bug #: 52528
           Summary: apr_dbd_get_driver doesn't clean up nice when failing
                    to load a module
           Product: APR
           Version: HEAD
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR-util
        AssignedTo: bugs@apr.apache.org
        ReportedBy: daniel@gruno.dk
    Classification: Unclassified


Whenever I use apr_dbd_get_driver to get a driver, it will clean up nicely if
the driver exists, but leak a few kb every time it fails, potentially resulting
in MB upon MB of trash piling up in the memory banks.

I've tested with the following snippet that would simulate an apache httpd
module starting up:

//--------------------------------------------
static void register_hooks(apr_pool_t *pool) {
    int x;
    int rc;
    apr_pool_t *POOL;
    apr_dbd_driver_t* driver;

    module_init(pool);
    ap_hook_handler(plua_handler, NULL, NULL, APR_HOOK_LAST);

    for (x=0;x<3000;x++) {
        POOL = 0;
        driver = 0;
        apr_pool_create(&POOL, pool);
        apr_dbd_init(POOL);
        rc = apr_dbd_get_driver(POOL, "nonexistentdriver", &driver);
        apr_pool_clear(POOL);
        apr_pool_destroy(POOL);
    }

}
//--------------------------------------------

If I replace the "nonexistentdriver" element with, per se, "odbc" or "sqlite3",
it will load the driver and clean up nicely with not a drop to spare, but when
I use a driver name that it cannot load, it will continue to use new memory, in
this case upwards of 30-40MB for those 3,000 attempts in the above snippet.

Is this a bug, and if not, how do I resolve it, so it won't gobble up all my
memory?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 52528] apr_dbd_get_driver doesn't clean up nice when failing to load a module

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

Bojan Smojver <bo...@rexursive.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #28256|0                           |1
        is obsolete|                            |

--- Comment #3 from Bojan Smojver <bo...@rexursive.com> 2012-02-03 05:29:13 UTC ---
Comment on attachment 28256
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28256
Patch to close the memory leak

Doesn't help.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


[Bug 52528] apr_dbd_get_driver doesn't clean up nice when failing to load a module

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

--- Comment #5 from Stefan Fritsch <sf...@sfritsch.de> ---
I think apr_dbd_get_driver() should not ignore the passed in pool but pass it
to apu_dso_load(). The latter will only use it for temporary data, anyway, and
load the dso with the global pool.

apr_dso_load() (apr_, not apu_) will still allocate the size of a
apr_dso_handle_t on failure, but that's much less than what apu_dso_load() will
allocate for pathnames, etc.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 52528] apr_dbd_get_driver doesn't clean up nice when failing to load a module

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

--- Comment #2 from Bojan Smojver <bo...@rexursive.com> 2012-02-03 03:04:54 UTC ---
Created attachment 28256
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28256
Patch to close the memory leak

Does this patch make any difference?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 52528] apr_dbd_get_driver doesn't clean up nice when failing to load a module

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

Bojan Smojver <bo...@rexursive.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bojan@rexursive.com

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 52528] apr_dbd_get_driver doesn't clean up nice when failing to load a module

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

Bojan Smojver <bo...@rexursive.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|                            |All

--- Comment #1 from Bojan Smojver <bo...@rexursive.com> 2012-01-29 07:44:38 UTC ---
It's not surprising, to be honest. We use a global pool for DSOs and there is
some memory allocation from that pool that is done every time a DSO is being
loaded. After DSO has been picked up once successfully, it will be picked up
again from a hash (ergo, no allocation), but if it was not loaded successfully,
the next attempt may allocate more bytes from global dso pool and so on.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 52528] apr_dbd_get_driver doesn't clean up nice when failing to load a module

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52528

--- Comment #4 from Bojan Smojver <bo...@rexursive.com> 2012-02-05 07:30:09 UTC ---
Can I ask here, why do you need to pass strings that are definitely not DB
driver names into this function?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org