Hi, I want to use mod_dbd with MySQL on a system with CentOS 6.4 (x86_64). I can execute a select statement, but getting a row fails. Finally I get a segmentation fault. Attached is a simple test module which leads to the error. The log output until apr_dbd_get_row is as expected. Line 57 writes the last line into the log before I get the seg fault. If I disable random access in the call of apr_dbd_select the seg fault already happens in line 56 when calling apr_dbd_get_row. Do you have an idea whats wrong? Installed are the current packages of CentOS 6.4 httpd-2.2.15 apr-util-1.3.9 apr-util-mysql-1.3.9 mysql-5.1.69 Thanks in advance Dominic
#include <apr-1/apr_optional.h> #include <apr-1/apr_dbd.h> #include <apr-1/apr_hooks.h> #include <httpd/httpd.h> #include <httpd/http_config.h> #include <httpd/http_log.h> #include <httpd/mod_dbd.h> module AP_MODULE_DECLARE_DATA test_module; static ap_dbd_t *(*test_dbd_acquire_fn)(request_rec *) = NULL; static int test_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { if (test_dbd_acquire_fn == NULL) { test_dbd_acquire_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_acquire); if (test_dbd_acquire_fn == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "You must load mod_dbd to enable mod_test"); return HTTP_INTERNAL_SERVER_ERROR; } } return OK; } static apr_status_t test_handler(request_rec *r) { if (strcmp(r->handler, "test")) return DECLINED; ap_dbd_t *dbd = test_dbd_acquire_fn(r); if (dbd == NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Failed to acquire database connection"); return HTTP_INTERNAL_SERVER_ERROR; } char* sql = "select 1 from information_schema.tables limit 5"; apr_dbd_results_t *res; int errnum = apr_dbd_select(dbd->driver, r->pool, dbd->handle, &res, sql, 1); if (errnum) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Failed to select: %s", apr_dbd_error(dbd->driver, dbd->handle, errnum)); return HTTP_INTERNAL_SERVER_ERROR; } int rows = apr_dbd_num_tuples(dbd->driver, res); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "%d rows selected", rows); int cols = apr_dbd_num_cols(dbd->driver, res); ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "%d cols selected", cols); apr_dbd_row_t *row; if (apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Failed to get row"); return HTTP_INTERNAL_SERVER_ERROR; } ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "row fetched"); return OK; } static void register_hooks(apr_pool_t *p) { ap_hook_post_config(test_post_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(test_handler, NULL, NULL, APR_HOOK_FIRST); } module AP_MODULE_DECLARE_DATA test_module = { STANDARD20_MODULE_STUFF, NULL, NULL, NULL, NULL, NULL, register_hooks, };
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx