HI,

trying to test LUA on macosx I am getting segmentation fault


1. get 

~/repo/haproxy/haproxy (master)$ git pull
Already up-to-date.

2. compile 

make CFLAGS="-O0 -g"  TARGET=osx USE_LUA=yes  LUA_LIB=/opt/lua/lib 
LUA_INC=/opt/lua/include LUA_LIB_NAME=lua   
gcc -Iinclude -Iebtree -Wall -O0 -g       -DENABLE_POLL -DENABLE_KQUEUE 
-DUSE_LUA -I/opt/lua/include  -DCONFIG_HAPROXY_VERSION=\"1.6-dev1-601a4d-55\" 
-DCONFIG_HAPROXY_DATE=\"2015/04/01\" \
              -DBUILD_TARGET='"osx"' \
              -DBUILD_ARCH='""' \
              -DBUILD_CPU='"generic"' \
              -DBUILD_CC='"gcc"' \
              -DBUILD_CFLAGS='"-O0 -g"' \
              -DBUILD_OPTIONS='""' \
               -c -o src/haproxy.o src/haproxy.c
gcc -Iinclude -Iebtree -Wall -O0 -g       -DENABLE_POLL -DENABLE_KQUEUE 
-DUSE_LUA -I/opt/lua/include  -DCONFIG_HAPROXY_VERSION=\"1.6-dev1-601a4d-55\" 
-DCONFIG_HAPROXY_DATE=\"2015/04/01\" -c -o src/sessionhash.o src/sessionhash.c
….

3. copy to /usr/local/bin ( optional )

mv haproxy  haproxy-1.6-dev1-601a4d-55
mv haproxy-1.6-dev1-601a4d-55 /usr/local/bin

4. lua.conf

cat lua.conf 
global
 lua-load /opt/haproxy/conf/mylua.lua
 
defaults
 mode http
 timeout connect 1s
 timeout client 1s
 timeout server 1s
 
frontend fe
 bind 127.0.0.1:8001 
 #bind 127.0.0.1:8001 name fe
 acl debugme req.hdr_cnt(X-debug-me) ge 1
 # add your http manipulation rules here
  http-request lua mirror if debugme
 default_backend be
 
backend be
 server s 127.0.0.1:8002

5. mylua.lua

cat mylua.lua 
-- a simple mirror web server
-- it generates a response whose body contains the requests headers
function mirror(txn)
local buffer = ""
local response = ""
local mydate = txn.sc:http_date(txn.f:date())

buffer = buffer .. "You sent the following headers\r\n"
buffer = buffer .. "===============================================\r\n"
buffer = buffer .. txn.req:dup()
buffer = buffer .. "===============================================\r\n"

response = response .. "HTTP/1.0 200 OK\r\n"
response = response .. "Server: haproxy-lua/mirror\r\n"
response = response .. "Content-Type: text/html\r\n"
response = response .. "Date: " .. mydate .. "\r\n"
response = response .. "Content-Length: " .. buffer:len() .. "\r\n"
response = response .. "Connection: close\r\n"
response = response .. "\r\n"
response = response .. buffer

txn.res:send(response)
txn:close()
end


6. running haproxy :

 haproxy -f lua.conf 
Segmentation fault: 11



if  #   http-request lua mirror if debugme  is commented then haproxy runs 
without problem

 haproxy -f lua.conf 
[WARNING] 091/192658 (27210) : [haproxy.main()] Cannot raise FD limit to 4011.
[WARNING] 091/192658 (27210) : [haproxy.main()] FD limit (2048) too low for 
maxconn=2000/maxsock=4011. Please raise 'ulimit-n' to 4011 or more to avoid any 
trouble.
^C



haproxy :

haproxy -vv
HA-Proxy version 1.6-dev1-601a4d-55 2015/04/01
Copyright 2000-2015 Willy Tarreau <[email protected]>

Build options :
  TARGET  = osx
  CPU     = generic
  CC      = gcc
  CFLAGS  = -O0 -g
  OPTIONS = 

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

Encrypted password support via crypt(3): no
Built without zlib support (USE_ZLIB not set)
Compression algorithms supported : identity("identity")
Built without OpenSSL support (USE_OPENSSL not set)
Built without PCRE support (using libc's regex instead)
Built with Lua version : Lua 5.3.0

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.






Reply via email to