[Modules] [apr_memcache] Crash when calling apr_memcache_create

Jérôme Renard jr at ez.no
Wed Jul 30 01:29:15 EDT 2008


Good morning.

I have been learning apr_memcache for 2 days now and I get a crash whenever
I try to call the apr_memcache_create function [1].

Here is the code I use for the structures :

typedef struct {
   const char *host;
   apr_port_t port;
   apr_memcache_server_t *server;
} memcached_include_server_t;

[...]

typedef struct {
     const char *default_start_tag;
     const char *default_end_tag;

     apr_memcache_t     *memcached;
     apr_array_header_t *servers;

     apr_uint32_t conn_min;
     apr_uint32_t conn_smax;
     apr_uint32_t conn_max;
     apr_uint32_t conn_ttl;
     apr_uint16_t max_servers;
     apr_off_t    min_size;
     apr_off_t    max_size;
} include_server_config;

[...]

The "server_config" function :

static void *create_includes_server_config(apr_pool_t *p, server_rec *server)
{
     include_server_config *result;

     result = apr_palloc(p, sizeof(include_server_config));
     result->default_end_tag    = DEFAULT_END_SEQUENCE;
     result->default_start_tag  = DEFAULT_START_SEQUENCE;

     result->servers = apr_array_make(p, 10, sizeof(memcached_include_server_t));

     result->max_servers = DEFAULT_MAX_SERVERS;
     result->min_size    = DEFAULT_MIN_SIZE;
     result->max_size    = DEFAULT_MAX_SIZE;
     result->conn_min    = DEFAULT_MIN;
     result->conn_smax   = DEFAULT_SMAX;
     result->conn_max    = DEFAULT_MAX;
     result->conn_ttl    = DEFAULT_TTL;

     return result;
}

And the post_configuration hook :

static int include_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
     include_handlers = apr_hash_make(p);

     ssi_pfn_register = APR_RETRIEVE_OPTIONAL_FN(ap_register_memcached_include_handler);

     [...]

     include_server_config      *conf;
     memcached_include_server_t *svr;
     apr_status_t               rv;
     int                        i;

     conf = (include_server_config *)ap_get_module_config(s->module_config, &memcached_include_module);

     rv = apr_memcache_create(p, conf->max_servers, 0, &(conf->memcached));

     [...commented code here...]

     return OK;
}

The backtrace, not really helpful to me so far :'( :

Starting program: /usr/local/apache-2.2.9/bin/httpd -k restart
httpd not running, trying to start

Program received signal SIGTRAP, Trace/breakpoint trap.
0x8fe053f6 in __dyld__ZN4dyld14bindLazySymbolEPK11mach_headerPm ()
(gdb) bt
#0  0x8fe053f6 in __dyld__ZN4dyld14bindLazySymbolEPK11mach_headerPm ()
#1  0x8fe131af in __dyld_stub_binding_helper_interface ()
#2  0x00000000 in ?? ()

I am able to compile the module, but whenever I run Apache, I get a crash. If I comment the following line :

   rv = apr_memcache_create(p, conf->max_servers, 0, &(conf->memcached));

No more crashes.

After several hours I am still not able to find where my mistake is this is why I am sending the email for help.

Thanks in advance for any help and have a nice day.

Best Regards.

1. http://www.outoforder.cc/projects/libs/apr_memcache/doxygen/group__APR__Util__MC.html#ga9



More information about the Modules mailing list