On Thursday, October 3, 2002, at 10:28 AM, Costin Manolache wrote: >> Command: httpd >> PID: 853 >> >> Exception: EXC_BAD_ACCESS (0x0001) >> Codes: KERN_INVALID_ADDRESS (0x0001) at 0x736f0028 >> >> Thread 0 Crashed: >> #0 0x90001600 in strlen >> #1 0x900023e0 in vfprintf >> #2 0x90015ee0 in __sbprintf >> #3 0x900018a8 in vfprintf >> #4 0x900017ec in fprintf >> #5 0x0060fdbc in jk2_map_default_get (jk_map.c:97) <-- it's '97' >> because I added printf >> #6 0x0060df50 in jk2_env_createBean2 (jk_env.c:218) >> #7 0x0061ee0c in jk2_create_config (mod_jk2.c:351) >> >> >> Anyone has a clue on what could be wrong? Just pointers would help. I >> tried following the stack trace but am temporarily thrown off by how >> jk2_env_createBean2() gets to jk2_map_default_get(), especially the >> second parameter's type. It seems to be casted from (char *) to >> (jk_map_t *), which is kind of weird. > > Not sure what you mean. The second parameter of env->getBean2( ) is > string. jk2_env_getBean2 will call jk2_map_default_get ( actually, > env->_objects->get ) with env->_objects as second param, which is > a jk_map. > I understand now why the stack trace looks weird. The default configuration adds a '-O2' flag during compilation and Mac OS X GCC 3.1 optimized certain functions out.
Here's the correct stack trace: Thread 0 Crashed: #0 0x90001600 in strlen #1 0x900023e0 in vfprintf #2 0x900017ec in fprintf #3 0x0061dd18 in jk2_map_default_get (jk_map.c:104) <- see codes below for the statement #4 0x0061bbb4 in jk2_env_getBean2 (jk_env.c:423) <- this was missing originally #5 0x0061af40 in jk2_env_createBean2 (jk_env.c:218) #6 0x00636754 in jk2_create_config (mod_jk2.c:344) #7 0x0002214c in ap_single_module_configure (config.c:1845) > Are you using the commented-out printf ? It is possible that > one of name or value is null - printf is not checking for null on > many OS. Try using apr printf, or check for null. > I'm adding my own printf's. For completeness, here's the function static void *jk2_map_default_get(jk_env_t *env, jk_map_t *m, const char *name) { int i; jk_map_private_t *mPriv; void *result=NULL; if(name==NULL ) return NULL; fprintf(stdout, "\nentering for %s ", name); mPriv=(jk_map_private_t *)m->_private; fprintf(stdout, " (no. maps: %d)\n", mPriv->size); for(i = 0 ; i < mPriv->size ; i++) { fprintf(stdout, "\t%d: ", i); if ((mPriv->names[i]) == NULL) { fprintf(stdout, "null mPriv->names[]"); return NULL; } fprintf(stdout, " %p ", &(mPriv->names[i])); fflush(stdout); fprintf(stdout, " %s ", mPriv->names[i]); /* this is line 104 */ fprintf(stdout, " (%p) \n", mPriv->values[i]); if(0 == strcmp(mPriv->names[i], name)) { result = mPriv->values[i]; break; } } fprintf(stdout, "done for %s\n", name); return result; } And as per requested by Costin, I added the printf in the put function: ... if(mPriv->size < mPriv->capacity) { mPriv->values[mPriv->size] = value; /* XXX this is wrong - either we take ownership and copy both name and value, or none. The caller should do that if he needs ! Sure, but we should have our copy... mPriv->names[mPriv->size] = (char *)name; */ mPriv->names[mPriv->size] = m->pool->pstrdup(env,m->pool, name); printf("put '%s' (addr: %p) with value: %p \n", mPriv->names[mPriv->size], &(mPriv->names[mPriv->size]), value); mPriv->size ++; rc = JK_OK; } ... And finally, here's the output: put 'logger.file' (addr: 0x19b948) with value: 0x61d984 put 'logger.win32' (addr: 0x19b94c) with value: 0x61dac8 put 'workerEnv' (addr: 0x19b950) with value: 0x62c698 put 'uriMap' (addr: 0x19b954) with value: 0x62a3d4 put 'uriEnv' (addr: 0x19b958) with value: 0x627fa4 put 'endpoint' (addr: 0x19b95c) with value: 0x61a65c put 'uri' (addr: 0x19b960) with value: 0x627fa4 put 'config' (addr: 0x19b964) with value: 0x61a028 put 'ajp13' (addr: 0x19b968) with value: 0x62f168 put 'lb' (addr: 0x19b96c) with value: 0x6308dc put 'status' (addr: 0x19b970) with value: 0x632c2c put 'run' (addr: 0x19b974) with value: 0x630d60 put 'channel.un' (addr: 0x19b978) with value: 0x617dc8 put 'channel.apr' (addr: 0x19b97c) with value: 0x615644 put 'shm' (addr: 0x19b980) with value: 0x626ee8 put 'channel.socket' (addr: 0x19b984) with value: 0x616c64 put 'handler.response' (addr: 0x19b988) with value: 0x61cff0 put 'handler.logon' (addr: 0x19b98c) with value: 0x61c578 put 'threadMutex' (addr: 0x19b990) with value: 0x620da8 put 'procMutex' (addr: 0x19b994) with value: 0x6209fc put 'channel.jni' (addr: 0x19b998) with value: 0x6157b0 put 'worker.jni' (addr: 0x19b99c) with value: 0x62f3f4 put 'vm' (addr: 0x19b9a0) with value: 0x62a864 put 'signal' (addr: 0x19b9a4) with value: 0x627038 put 'user' (addr: 0x19b9a8) with value: 0x62a7a8 entering for threadMutex (no. maps: 25) 0: 0x19b948 logger.file (0x61d984) 1: 0x19b94c logger.win32 (0x61dac8) 2: 0x19b950 workerEnv (0x62c698) 3: 0x19b954 uriMap (0x62a3d4) 4: 0x19b958 uriEnv (0x627fa4) 5: 0x19b95c endpoint (0x61a65c) 6: 0x19b960 uri (0x627fa4) 7: 0x19b964 config (0x61a028) 8: 0x19b968 ajp13 (0x62f168) 9: 0x19b96c lb (0x6308dc) 10: 0x19b970 status (0x632c2c) 11: 0x19b974 run (0x630d60) 12: 0x19b978 channel.un (0x617dc8) 13: 0x19b97c channel.apr (0x615644) 14: 0x19b980 shm (0x626ee8) 15: 0x19b984 channel.socket (0x616c64) 16: 0x19b988 handler.response (0x61cff0) 17: 0x19b98c handler.logon (0x61c578) 18: 0x19b990 threadMutex (0x620da8) done for threadMutex put 'threadMutex:0' (addr: 0x19eea8) with value: 0x52e080 put 'logger.apache2' (addr: 0x19b9ac) with value: 0x63447c ... ... entering for workerEnv (no. maps: 19) 0: 0x19eea8 threadMutex:0 (0x52e080) 1: 0x19eeac logger.apache2: (0x532090) 2: 0x19eeb0 logger.apache2 (0x532090) 3: 0x19eeb4 logger (0x532090) 4: 0x19eeb8 uriMap: (0x5360a8) 5: 0x19eebc uriMap (0x5360a8) 6: 0x19eec0 config: (0x5380b8) 7: 0x19eec4 config (0x5380b8) 8: 0x19eec8 shm: (0x53a0c8) 9: 0x19eecc shm (0x53a0c8) 10: 0x19eed0 workerEnv: (0x5340a0) 11: 0x19eed4 workerEnv (0x5340a0) done for workerEnv put '/examples/*' (addr: 0x5361cc) with value: 0x55a520 put 'uri:/examples/*' (addr: 0x19eef4) with value: 0x558520 entering for ver (no. maps: 1) 0: 0x19c618 worker (0x19c600) done for ver put 'worker' (addr: 0x538b20) with value: 0x538ac8 put 'uri:/examples/*.worker' (addr: 0x53423c) with value: 0x538ac8 entering for uri: (no. maps: 20) 0: 0x19eea8 bin/apachectl: line 87: 3243 Segmentation fault $HTTPD -k $ARGV It seems like some mem reallocation might be screwing up, no? Thanks much! Han Ming