Hi,

On Sun, Apr 07, 2013 at 05:17:25PM +0200, pechspilz wrote:
> Hi,
> 
> Since upgrading from dev17 to dev18 I'm getting a segfault:
> (gdb) run -f /etc/haproxy/haproxy.conf -p /var/run/haproxy.pid -db
> Starting program: /usr/local/bin/haproxy -f /etc/haproxy/haproxy.conf -p
> /var/run/haproxy.pid -db
> 
> Program received signal SIGSEGV, Segmentation fault.
> smp_fetch_get_gpc0 (ts=0xccf2ad8a, smp=0xbffff334, table=<optimized out>)
> at src/session.c:2590
>
> It's caused by this configuration (which was OK in dev17). If I remove it,
> haproxy runs fine.

Thanks I found the cause, it happens because of the implicit argument below
in src_get_gpc0 which is marked for resolving but is not resolved due to not
being added to the resolving list.

> frontend ...
>  stick-table type ip size 1m expire 20s store gpc0,http_req_rate(20s)
>  tcp-request connection track-sc1 src
>  tcp-request connection reject if { src_get_gpc0 gt 0 }
                                          ^^^^^^^^
The attached patch fixes it, I've merged it. If you don't want to patch
right now, you can easily fix it by replacing the keyword above with :

     src_get_gpc0(f_web)

(assuming f_web was the name of the frontend)

Best regards,
Willy

>From f75d008c45c6e0e989825d381222cd3d978b01c8 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <[email protected]>
Date: Sun, 7 Apr 2013 21:20:44 +0200
Subject: BUG/MAJOR: acl: add implicit arguments to the resolve list

When an ACL keyword needs a mandatory argument and this argument is of
type proxy or table, it is allowed not to specify it so that current
proxy is used by default.

In order to achieve this, the ACL expression parser builds a dummy
argument from scratch and marks it unresolved.

However, since recent changes on the ACL and samples, an unresolved
argument needs to be added to the unresolved list. This specific code
did not do it, resulting in random data being used as a proxy pointer
if no argument was passed for a proxy name, possibly even causing a
crash.

A quick workaround consists explicitly naming proxies in ACLs.
---
 src/acl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/acl.c b/src/acl.c
index efd1ee6..6a23bae 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -1135,6 +1135,8 @@ struct acl_expr *parse_acl_expr(const char **args, char 
**err, struct arg_list *
                        expr->args[0].data.str.str = strdup("");
                        expr->args[0].data.str.len = 1;
                        expr->args[0].data.str.len = 0;
+                       arg_list_add(al, &expr->args[0], 0);
+
                        expr->args[1].type = ARGT_STOP;
                }
                else if (ARGM(expr->smp->arg_mask)) {
-- 
1.7.12.2.21.g234cd45.dirty

Reply via email to