On Fri, Apr 19, 2013 at 06:13:12PM -0700, Bryan Talbot wrote:
> I'm testing out nbproc for ssl offloading for the first time and ran into
> an issue with "stats bind-process" which seems to segfault on startup.
> 
> # cat x.cfg
> global
>   nbproc 2
>   stats bind-process 1
> 
> listen stats
>   bind :8000
>   mode http
>   stats enable
>   stats admin if TRUE
>   stats uri       /
> 
> 
> # /usr/sbin/haproxy -c -V -f /etc/haproxy/x.cfg
> Segmentation fault

Fix attached, thank you Bryan.

The reason for this is that you don't have a "stats socket" before
"stats bind-process" and this last one forgot to allocate the stats
frontend.

I now understand what you tried to do but this is wrong :-)
The global "stats bind-process" forces the process of the global stats
socket.

What you want to do above (it seems) is to bind your listener to a
specific process. This is done this way :

 global
   nbproc 2
 
 listen stats
   bind :8000
   bind-process 1
   mode http
   stats enable
   stats admin if TRUE
   stats uri       /

Anyway I'm attaching the fix for the bug you reported.

Cheers,
Willy

>From 913195715d83f15abf0247037dc9bfe9cff327f8 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <[email protected]>
Date: Sat, 20 Apr 2013 09:48:50 +0200
Subject: BUG/MEDIUM: stats: allocate the stats frontend also on "stats
 bind-process"

Bryan Talbot reported that a config with only "stats bind-process 1" in
the global section would crash during parsing. This bug was introduced
with this new statement in 1.5-dev13. The stats frontend must be allocated
if it was not yet.

No backport is needed. The workaround consists in having previously declared
any other stats keyword (generally stats socket).
---
 src/dumpstats.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/dumpstats.c b/src/dumpstats.c
index 17efeff..25f5441 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -337,6 +337,13 @@ static int stats_parse_global(char **args, int 
section_type, struct proxy *curpx
                int cur_arg = 2;
                unsigned int set = 0;
 
+               if (!global.stats_fe) {
+                       if ((global.stats_fe = alloc_stats_fe("GLOBAL", file, 
line)) == NULL) {
+                               memprintf(err, "'%s %s' : out of memory trying 
to allocate a frontend", args[0], args[1]);
+                               return -1;
+                       }
+               }
+
                while (*args[cur_arg]) {
                        unsigned int low, high;
 
-- 
1.7.12.2.21.g234cd45.dirty

Reply via email to