Good day,
I have a pretty simple module that is crashing my server as soon as I
dereference a pointer that comes from the request_rec pool.
This is on CentOS 6.7, with Apache 2.4 compiled. It's a fresh VM on AWS.
The module was compiled with apxs. The code is listed below. The output I
get in the log files is:
[Date...] [:error] [client ....] [pid ...] ***--- not nulll
[Date...] [core:notice] [pid ...] AH00052: child pid 1365 exit signal
Segmentation fault (11)
//////////// CODE ////////////////
#include <stdio.h>
#include <http_request.h>
#include <httpd.h>
#include <http_core.h>
#include <http_log.h>
#include <http_config.h>
#include <http_protocol.h>
#include <apr_hooks.h>
#include <ap_config.h>
#define EXAMPLE_NAME "mod_example"
static int example_handler(request_rec *r)
{
const char *url;
url = apr_psprintf(r->pool, "%s", "test");
if(url == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "***--- null");
} else {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "***--- not nulll");
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "***--- url is: %s", url);
}
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "***--- done ");
return DECLINED;
}
static void example_register_hooks(apr_pool_t *pool)
{
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
module AP_MODULE_DECLARE_DATA example_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
example_register_hooks
};
Any help is appreciated.
-Justin