Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Invalid configuration options -> Segv #356

Closed
Borkason opened this Issue · 12 comments

2 participants

@Borkason
Collaborator

Original author: ste...@konink.de (January 23, 2009 01:58:43)

What steps will reproduce the problem?
1. edit balancer to something invalid/not present
2. segmentation fault on startup

Original issue: http://code.google.com/p/cherokee/issues/detail?id=333

@Borkason
Collaborator

From alobbs on January 23, 2009 09:15:33
It doesn't crash for me:

$ ./cherokee-worker -C ~/tmp/broken_balancer.conf
balancer.c:146: Could not find source '5'

Couldn't read the config file: /Users/alo/tmp/broken_balancer.conf

@Borkason
Collaborator

From ste...@konink.de on January 23, 2009 09:18:32
change round_robin to my_crashing_balancer. Observe ;)

@Borkason
Collaborator

From alobbs on January 23, 2009 09:31:02
It cannot open the module, and therefore it aborts the server initialization:

$ ./cherokee-worker -C ~/tmp/broken_balancer.conf
plugin_loader.c:194: ERROR: dlopen(/usr/lib/cherokee/libplugin_my_crashing_balancer.so):
dlopen(/usr/lib/cherokee/libplugin_my_crashing_balancer.so, 10): image not found
plugin_loader.c:363: ERROR: Can't open "my_crashing_balancer" module

Couldn't read the config file: /Users/alo/tmp/broken_balancer.conf

@Borkason
Collaborator

From ste...@konink.de on January 23, 2009 18:04:03
plugin_loader.c:194: ERROR: dlopen(/opt/cherokee/lib/cherokee/libplugin_hash_ip.so):
/opt/cherokee/lib/cherokee/libplugin_hash_ip.so: cannot open shared object file: No
such file or directory
plugin_loader.c:363: ERROR: Can't open "hash_ip" module

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fb3758f56f0 (LWP 20173)]
0x00007fb37351d2d1 in cherokee_handler_cgi_base_props_free (props=0x12cf4c0)
at handler_cgi_base.c:133
133 list_for_each_safe (i, tmp, &props->system_env) {

@Borkason
Collaborator

From alobbs on January 23, 2009 18:28:25
Could you please paste the complete backtrace? (bt)

@Borkason
Collaborator

From ste...@konink.de on January 23, 2009 18:30:46
(gdb) bt
#​0 0x00007fb37351d2d1 in cherokee_handler_cgi_base_props_free (
props=0x12cf4c0) at handler_cgi_base.c:133
#​1 0x00007fb3754f3318 in cherokee_module_props_free (prop=0x0) at module.c:86
#​2 0x00007fb3752c76f2 in cherokee_config_entry_mrproper (entry=0x12cece8)
at config_entry.c:79
#​3 0x00007fb3752c6da2 in cherokee_rule_free (rule=0x12cecb0) at rule.c:57
#​4 0x00007fb3752cb645 in configure_rules (config=,
vserver=0x12cbaf0, rule_list=0x12cbb30) at virtual_server.c:537
#​5 0x00007fb3752cb90f in configure_virtual_server_property (conf=0x128c490,
data=) at virtual_server.c:673
#​6 0x00007fb3754fd61b in cherokee_config_node_while (
conf=,
func=0x7fb3752cb6d0 , data=0x12cbaf0)
at config_node.c:226
#​7 0x00007fb3752cacd8 in cherokee_virtual_server_configure (
vserver=0x12cbaf0, prio=10, config=0x0) at virtual_server.c:733
#​8 0x00007fb3752c8527 in add_vserver (conf=0x128c190, data=0x1287010)
at server.c:1121
#​9 0x00007fb3754fd61b in cherokee_config_node_while (
conf=, func=0x7fb3752c8480 ,
data=0x1287010) at config_node.c:226
#​10 0x00007fb3752c8299 in configure_server (srv=0x1287010) at server.c:1451
#​11 0x00007fb3752c843c in cherokee_server_read_config_file (srv=0x1287010,
---Type to continue, or q to quit---
fullpath=) at server.c:1516
#​12 0x000000000040189e in main (argc=1, argv=)
at main_worker.c:233

@Borkason
Collaborator

From ste...@konink.de on February 01, 2009 02:57:41
Handler proxy had a corner case too.

Index: handler_proxy.c

--- handler_proxy.c (revision 2793)
+++ handler_proxy.c (working copy)
@@ -122,6 +122,12 @@
}

    props = PROP_PROXY(*_props);

+

  • /* Init properties
  • * SDK (01/02/2009) for some reason the _mrproper function on proxy_hosts
  • * gets also executed if the actual init was not done. Yeah that is bad mkay.
  • */
  •   cherokee_handler_proxy_hosts_init (&props->hosts);
    
    /* Parse the configuration tree
     */
    

    @@ -163,10 +169,6 @@
    }
    }

  •   /* Init properties
    
  • */

- cherokee_handler_proxy_hosts_init (&props->hosts);

    /* Final checks
     */
    if (props->balancer == NULL) {
@Borkason
Collaborator

From ste...@konink.de on February 01, 2009 03:07:54
And you will understand it right that this probably should be done for every thing
that can bork in _configure, requires a base class, and is most likely instructed to
mrproper on static variables that have never been initialised.

Index: handler_fcgi.c

--- handler_fcgi.c (revision 2793)
+++ handler_fcgi.c (working copy)
@@ -241,6 +241,11 @@

    props = PROP_FCGI(*_props);
  • /* Init base class
  • */
  • ret = cherokee_handler_cgi_base_configure (conf, srv, _props);
  • if (ret != ret_ok) return ret; + /* Parse the configuration tree */ cherokee_config_node_foreach (i, conf) { @@ -250,12 +255,7 @@ ret = cherokee_balancer_instance (&subconf->val, subconf, srv, &props->balancer); if (ret != ret_ok) return ret; }

- }

  • /* Init base class
  • */
  • ret = cherokee_handler_cgi_base_configure (conf, srv, _props);
  • if (ret != ret_ok) return ret;
  •   }
    
    /* Final checks
     */
    
@Borkason
Collaborator

From ste...@konink.de on February 01, 2009 03:10:40
Don't know if this is used by anyone, but added the same 'final' check to it as fcgi.

Index: handler_fastcgi.c

--- handler_fastcgi.c (revision 2793)
+++ handler_fastcgi.c (working copy)
@@ -84,6 +84,9 @@

    props = PROP_FASTCGI(*_props);
  • ret = cherokee_handler_cgi_base_configure (conf, srv, _props);
  • if (ret != ret_ok) return ret; + /* Parse the configuration tree */ cherokee_config_node_foreach (i, conf) { @@ -112,7 +115,15 @@ props->nsockets = atoi(subconf->val.buf); } }
  • return cherokee_handler_cgi_base_configure (conf, srv, _props); +
  • /* Final checks
  • */
  • if (props->balancer == NULL) {
  • PRINT_ERROR_S ("ERROR: fastcgi handler needs a balancer\n");
  • return ret_error;
  • } +
  • return ret_ok; }
@Borkason
Collaborator

From ste...@konink.de on February 01, 2009 03:12:35
And I guess the final one.

Index: handler_scgi.c

--- handler_scgi.c (revision 2793)
+++ handler_scgi.c (working copy)
@@ -77,6 +77,11 @@
}

    props = PROP_SCGI(*_props);

+

  • /* Init base class
  • */
  • ret = cherokee_handler_cgi_base_configure (conf, srv, _props);
  •   if (ret != ret_ok) return ret;
    
    /* Parse the configuration tree
     */
    

    @@ -89,11 +94,6 @@
    }
    }

  •   /* Init base class
    
  • */
  • ret = cherokee_handler_cgi_base_configure (conf, srv, _props);

- if (ret != ret_ok) return ret;

    /* Final checks
     */
    if (props->balancer == NULL) {
@Borkason
Collaborator

From alobbs on February 01, 2009 16:08:50
Stefan, I don't think that's the right way to fix the problem. The patches are workarounds that let the problem in
place and prevent the consequences.

I'll try another approach and I'll let you know how it goes.. :-)

@Borkason
Collaborator

From ste...@konink.de on February 01, 2009 17:21:57
If you take another approach you probably have to maintain a state machine or convert
the stack -> heap stuff; and do a NULL check. The problem is that a ret_error at the
init routines always require the free... and the free 'subparts' fail without a
proper check due to the lack of initialisation :) Chicken/Egg.

@skinkie skinkie closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.