Hi List,

I've configured haproxy with htx and when i try to filter the stats webpage.
Sending this request: "GET /?;csv;scope=b1" to '2.0-dev0-762475e 2019/01/10' it will crash with the trace below.
1.9.0 and 1.9.1 are also affected.

Can someone take a look? Thanks in advance.

A regtest is attached that reproduces the behavior, and which i think could be included into the haproxy repository.

Regards,
PiBa-NL (Pieter)

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000564fe7 in strnistr (str1=0x802631048 "fe1", len_str1=3, str2=0x804e3bf4c <error: Cannot access memory at address 0x804e3bf4c>, len_str2=3)
    at src/standard.c:3657
3657                    while (toupper(*start) != toupper(*str2)) {
(gdb) bt full
#0  0x0000000000564fe7 in strnistr (str1=0x802631048 "fe1", len_str1=3, str2=0x804e3bf4c <error: Cannot access memory at address 0x804e3bf4c>, len_str2=3)
    at src/standard.c:3657
        pptr = 0x804e3bf4c <error: Cannot access memory at address 0x804e3bf4c>
        sptr = 0x80271df80 "\330?"
        start = 0x802631048 "fe1"
        slen = 3
        plen = 3
        tmp1 = 0
        tmp2 = 4294959392
#1  0x00000000004d01d3 in stats_dump_proxy_to_buffer (si=0x8026416d8, htx=0x8027c8e40, px=0x8026b3c00, uri=0x802638000) at src/stats.c:2079
        appctx = 0x802678380
        s = 0x802641400
        rep = 0x802641470
        sv = 0x8027c8e40
        svs = 0x33bffffe1e0
        l = 0x4d31df <htx_used_space+31>
        flags = 0
#2  0x00000000004d4139 in stats_dump_stat_to_buffer (si=0x8026416d8, htx=0x8027c8e40, uri=0x802638000) at src/stats.c:2652
        appctx = 0x802678380
        rep = 0x802641470
        px = 0x8026b3c00
#3  0x00000000004d56bb in htx_stats_io_handler (appctx=0x802678380) at src/stats.c:3299
        si = 0x8026416d8
        s = 0x802641400
        req = 0x802641410
        res = 0x802641470
        req_htx = 0x8027c8e40
        res_htx = 0x8027c8e40
#4  0x00000000004d2546 in http_stats_io_handler (appctx=0x802678380) at src/stats.c:3367
        si = 0x8026416d8
        s = 0x802641400
        req = 0x802641410
        res = 0x802641470
#5  0x00000000005f729f in task_run_applet (t=0x8026566e0, context=0x802678380, state=16385) at src/applet.c:85
        app = 0x802678380
        si = 0x8026416d8
#6  0x00000000005f2533 in process_runnable_tasks () at src/task.c:435
        t = 0x8026566e0
        state = 16385
        ctx = 0x802678380
        process = 0x5f7200 <task_run_applet>
        t = 0x8026566e0
        max_processed = 199
#7  0x00000000005163b2 in run_poll_loop () at src/haproxy.c:2619
        next = 0
        exp = 1137019023
#8  0x0000000000513008 in run_thread_poll_loop (data=0x8026310f0) at src/haproxy.c:2684
        start_lock = 0
        ptif = 0x935d40 <per_thread_init_list>
        ptdf = 0x0
#9  0x000000000050f636 in main (argc=4, argv=0x7fffffffeb08) at src/haproxy.c:3313
        tids = 0x8026310f0
        threads = 0x8026310f8
        i = 1
        old_sig = {__bits = {0, 0, 0, 0}}
        blocked_sig = {__bits = {4227856759, 4294967295, 4294967295, 4294967295}}
        err = 0
        retry = 200
        limit = {rlim_cur = 4052, rlim_max = 4052}
        errmsg = "\000\353\377\377\377\177\000\000\060\353\377\377\377\177\000\000\b\353\377\377\377\177\000\000\004\000\000\000\000\000\000\000t\240\220?\260|6\224`)\224\000\000\000\000\000\000\353\377\377\377\177\000\000\060\353\377\377\377\177\000\000\b\353\377\377\377\177\000\000\004\000\000\000\000\000\000\000\240\352\377\377\377\177\000\000R\201\000\002\b\000\000\000\001\000\000"
        pidfd = -1

From 838ecb4e153c1d859d0a49e0554ff050ff10033c Mon Sep 17 00:00:00 2001
From: PiBa-NL <piba.nl....@gmail.com>
Date: Sat, 12 Jan 2019 21:57:48 +0100
Subject: [PATCH] REGTEST: checks basic stats webpage functionality

This regtest verifies that the stats webpage can be used to change a
server state to maintenance or drain, and that filtering the page scope
will result in a filtered page.
---
 .../h_webstats-scope-and-post-change.vtc      | 83 +++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 reg-tests/webstats/h_webstats-scope-and-post-change.vtc

diff --git a/reg-tests/webstats/h_webstats-scope-and-post-change.vtc 
b/reg-tests/webstats/h_webstats-scope-and-post-change.vtc
new file mode 100644
index 00000000..a77483b5
--- /dev/null
+++ b/reg-tests/webstats/h_webstats-scope-and-post-change.vtc
@@ -0,0 +1,83 @@
+varnishtest "Webgui stats page check filtering with scope and changing server 
state"
+#REQUIRE_VERSION=1.6
+
+feature ignore_unknown_macro
+
+server s1 {
+} -start
+
+haproxy h1 -conf {
+  global
+    stats socket /tmp/haproxy.socket level admin
+
+  defaults
+    mode http
+    ${no-htx} option http-use-htx
+
+  frontend fe1
+    bind "fd@${fe1}"
+    stats enable
+    stats refresh 5s
+    stats uri /
+    stats admin if TRUE
+
+  backend b1
+    server srv1 ${s1_addr}:${s1_port}
+    server srv2 ${s1_addr}:${s1_port}
+    server srv3 ${s1_addr}:${s1_port}
+
+  backend b2
+    server srv1 ${s1_addr}:${s1_port}
+    server srv2 ${s1_addr}:${s1_port}
+
+} -start
+
+client c1 -connect ${h1_fe1_sock} {
+    txreq -url "/;csv;"
+    rxresp
+    expect resp.status == 200
+} -run
+
+client c2 -connect ${h1_fe1_sock} {
+    txreq -url "/?;csv;scope=b1"
+    rxresp
+    expect resp.status == 200
+} -run
+
+haproxy h1 -cli {
+    send "show stat"
+    expect ~ .*
+} 
+
+client c3 -connect ${h1_fe1_sock} {
+    txreq -url "/"
+    rxresp
+    expect resp.status == 200
+
+    txreq -url "/?;csv;scope=b1"
+    rxresp
+    expect resp.status == 200
+    expect resp.body ~ ".*\nb1,BACKEND.*"
+    expect resp.body !~ ".*\nb2,BACKEND.*"
+
+    txreq -req "POST" -url "/?scope=b2" -body 
"s=srv1&s=srv2&s=srv3&action=maint&b=%233"
+    rxresp
+    expect resp.status == 303
+
+    txreq -req "POST" -url "/" -body "s=srv2&action=drain&b=%233"
+    rxresp
+    expect resp.status == 303
+
+    txreq -req "POST" -url "/" -body "s=srv1&action=maint&b=%234"
+    rxresp
+    expect resp.status == 303
+
+    txreq -url "/?;csv;scope=fe1"
+    rxresp
+    expect resp.status == 200
+} -run
+
+haproxy h1 -cli {
+    send "show stat"
+    expect ~ 
"\nb1,srv1.*MAINT.*\nb1,srv2.*DRAIN.*\nb1,srv3.*MAINT.*\nb1,BACKEND.*DOWN.*\nb2,srv1.*MAINT.*\nb2,srv2.*no
 check.*\nb2,BACKEND.*UP"
+} -wait
-- 
2.18.0.windows.1

Reply via email to