Re: SEGV in request.c!apache_request_new in Request#lookup_uri

Shugo Maeda <[email protected]> Sat, 04 Mar 2006 12:23:59 +0900
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
--------------020402060506050800090302
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi,

At 02/23/06 18:10:11 (JST),
Tietew <[email protected]> wrote:
> When I use Request#lookup_uri, httpd dies with SEGV.

Can you try the attached patch?

> P.S.
> I tried to report this incident via http://dev.modruby.net/tickets/new,
> but it failed with following error!

Sorry, I fixed that.

Shugo

--------------020402060506050800090302
Content-Type: text/plain;
 name="check_request_config.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="check_request_config.diff"

Index: mod_ruby.c
===================================================================
--- mod_ruby.c	(revision 119)
+++ mod_ruby.c	(working copy)
@@ -526,7 +526,7 @@
     errmsg = ruby_get_error_info(state);
     if (r->request_config) {
 	rconf = get_request_config(r);
-	if (!NIL_P(rconf->request_object))
+	if (rconf && !NIL_P(rconf->request_object))
 	    rb_apache_request_set_error(rconf->request_object,
 					errmsg, ruby_errinfo);
     }
@@ -1173,7 +1173,8 @@
     rb_set_kcode(default_kcode);
     if (r->request_config) {
 	ruby_request_config *rconf = get_request_config(r);
-	restore_env(r->pool, rconf->saved_env);
+	if (rconf)
+	    restore_env(r->pool, rconf->saved_env);
     }
     rb_progname = Qnil;
     if (dconf->gc_per_request)
Index: request.c
===================================================================
--- request.c	(revision 119)
+++ request.c	(working copy)
@@ -205,7 +205,8 @@
     rb_apache_register_object(obj);
     if (r->request_config) {
 	ruby_request_config *rconf = get_request_config(r);
-	rconf->request_object = obj;
+	if (rconf)
+	    rconf->request_object = obj;
     }
     apr_pool_cleanup_register(r->pool, (void *) r,
 			cleanup_request_object, apr_pool_cleanup_null);
@@ -231,7 +232,7 @@
     if (r == NULL) return Qnil;
     if (r->request_config) {
 	ruby_request_config *rconf = get_request_config(r);
-	if (!NIL_P(rconf->request_object))
+	if (rconf && !NIL_P(rconf->request_object))
 	    return rconf->request_object;
     }
     return apache_request_new(r);

--------------020402060506050800090302--