Haproxy 1.7.x 1.8.x 1.9.x tcp:receive crash


#1

if 200 ~ 500 requests,receive buff:80~90KB(Binary file).

now test version: 1.7.xx

HA-Proxy version 1.7.11-e0061e5 2018/05/18
Copyright 2000-2018 Willy Tarreau willy@haproxy.org

Build options :
TARGET = freebsd
CPU = generic
CC = cc
CFLAGS = -O2 -pipe -fstack-protector -fno-strict-aliasing -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -fno-strict-overflow -DFREEBSD_PORTS
OPTIONS = USE_GETADDRINFO=1 USE_ZLIB=1 USE_CPU_AFFINITY=1 USE_ACCEPT4=1 USE_REGPARM=1 USE_OPENSSL=1 USE_LUA=1 USE_STATIC_PCRE=1 USE_PCRE_JIT=1

Default settings :
maxconn = 2000, bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Encrypted password support via crypt(3): yes
Built with zlib version : 1.2.11
Running on zlib version : 1.2.11
Compression algorithms supported : identity(“identity”), deflate(“deflate”), raw-deflate(“deflate”), gzip(“gzip”)
Built with OpenSSL version : OpenSSL 1.0.2o-freebsd 27 Mar 2018
Running on OpenSSL version : OpenSSL 1.0.2o-freebsd 27 Mar 2018
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports prefer-server-ciphers : yes
Built with PCRE version : 8.42 2018-03-20
Running on PCRE version : 8.42 2018-03-20
PCRE library supports JIT : yes
Built with Lua version : Lua 5.3.4
Built with transparent proxy support using: IP_BINDANY IPV6_BINDANY

Available polling systems :
kqueue : pref=300, test result OK
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 3 (3 usable), will use kqueue.

Available filters :
[SPOE] spoe
[TRACE] trace
[COMP] compression

Loaded symbols for /libexec/ld-elf.so.1
#0 0x0000000000481cd4 in stream_int_update_applet ()
(gdb) bt
#0 0x0000000000481cd4 in stream_int_update_applet ()
#1 0x00000000004ce6a8 in hlua_init ()
#2 0x00000000004c7727 in hlua_init ()
#3 0x000000080167eba4 in lua_getinfo () from /usr/local/lib/liblua-5.3.so
#4 0x000000080168dd90 in lua_close () from /usr/local/lib/liblua-5.3.so
#5 0x000000080167f270 in lua_resume () from /usr/local/lib/liblua-5.3.so
#6 0x000000080167df26 in lua_getinfo () from /usr/local/lib/liblua-5.3.so
#7 0x000000080167eef7 in lua_resume () from /usr/local/lib/liblua-5.3.so
#8 0x00000000004c0919 in hlua_post_init ()
#9 0x00000000004c959b in hlua_init ()
#10 0x0000000000466963 in http_req_get_intercept_rule ()
#11 0x0000000000467843 in http_process_req_common ()
#12 0x00000000004910fc in process_stream ()
#13 0x0000000000429535 in process_runnable_tasks ()
#14 0x000000000041be12 in run_poll_loop ()
#15 0x000000000041c919 in main ()

lua code:

function api_connect(hash)
local tcp = core.tcp()
tcp:connect(api_auth_addr,api_auth_port)
local query_str = ‘GET ‘…api_auth_auth…hash…’ HTTP/1.0\r\nConnection: close\r\n\r\n’
tcp:send(query_str)
–dump(tcp:receive(’*a’))
local api_web_data = tcp:receive(’*l’);
if api_web_data:sub(10,12) == “200” then
local api_web_date = tcp:receive(’*l’);
local api_Content_Type = tcp:receive(’*l’);
local api_Content_Length = tcp:receive(’*l’);
local api_Content_Connection = tcp:receive(’*l’);
local api_Content_Server = tcp:receive(’*l’);
local api_web_sep = tcp:receive(’*l’);
dump(“hash:”…hash)
dump(“sep:”…#api_web_sep)
–crash in here -> tcp:receive(’*a’);
local api_tor_data = tcp:receive(’*a’);
dump(“tor_data:”…#api_tor_data)
tcp:close()
if api_tor_data then
return api_tor_data:sub(1,-1)
end
else
tcp:close()
end
return nil
end


#2

I moved this to the help section, as it is not a working LUA script you are presenting to the world.

I will CC @thierry here for his input