HI Cyril
my mistake, I forget to mention that before every build I am cleaning - make
clean
and here is the lldb output too
lldb /usr/local/bin/haproxy-1.6-dev1-601a4d-55
(lldb) target create "/usr/local/bin/haproxy-1.6-dev1-601a4d-55"
Current executable set to '/usr/local/bin/haproxy-1.6-dev1-601a4d-55' (x86_64).
(lldb) r -f lua.conf
Process 57497 launched: '/usr/local/bin/haproxy-1.6-dev1-601a4d-55' (x86_64)
Process 57497 stopped
* thread #1: tid = 0xddc786, 0x00007fff85a91b17
libsystem_platform.dylib`_platform_strcmp + 23, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x00007fff85a91b17 libsystem_platform.dylib`_platform_strcmp + 23
libsystem_platform.dylib`_platform_strcmp + 23:
-> 0x7fff85a91b17: movzbq (%rsi), %r8
0x7fff85a91b1b: incq %rdi
0x7fff85a91b1e: incq %rsi
0x7fff85a91b21: subq %r8, %rax
> On 03 Apr 2015, at 01:58, Cyril Bonté <[email protected]> wrote:
>
> Hi,
>
> Le 02/04/2015 18:28, gunay arslan a écrit :
>> 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
>
> Is it possible that you already compiled the sources before a "git pull" ?
> If so, did you make a "make clean" before compiling ?
>
>>
>> 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] <mailto:[email protected]>
>> <mailto:[email protected] <mailto:[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.
>>
>>
>>
>>
>>
>>
>
>
> --
> Cyril Bonté