I've been trying to get rabbitmq-server-2.4.0 up and running on Centos
5.5 on an Amazon AWS instance.
My instance uses the following kernel: 2.6.18-xenU-ec2-v1.2
I've tried installation of erlang and rabbitmq-server using:
1) yum repos
2) direct rpm installation
3) compiling from source.
In every case, I get the following message when attempting to start the
RabbitMQ-Server process:
pthread/ethr_event.c:98: Fatal error in wait__(): Function not
implemented (38)
Any help would be appreciated.
The problem
When starting erlang, the message pthread/ethr_event.c:98: Fatal error in wait__(): Function not implemented (38) is, on modern distros, most likely the result of a precompiled Erlang binary interacting with a kernel that doesn't implement FUTEX_WAIT_PRIVATE and FUTEX_WAKE_PRIVATE. The kernels Amazon provides for EC2 do not implement these FUTEX_PRIVATE_ macros.
Attempting to build Erlang from source on an ec2 box may fail in the same way if the distro installs kernel headers into /usr/include/linux as a requirement of other packages. (E.g., Centos requires the kernel-headers package as a prerequisite for gcc, gcc-c++, glibc-devel and glibc-headers, among others). Since the headers installed by the package do not match the kernel installed by the EC2 image creation scripts, Erlang incorrectly assumes FUTEX_WAIT_PRIVATE and FUTEX_WAKE_PRIVATE are available.
The fix
To fix it, the fastest is to manually patch erts/include/internal/pthread/ethr_event.h to use the non-_PRIVATE futex implementation:
#if defined(FUTEX_WAIT_PRIVATE) && defined(FUTEX_WAKE_PRIVATE)
# define ETHR_FUTEX_WAIT__ FUTEX_WAIT_PRIVATE
# define ETHR_FUTEX_WAKE__ FUTEX_WAKE_PRIVATE
#else
# define ETHR_FUTEX_WAIT__ FUTEX_WAIT
# define ETHR_FUTEX_WAKE__ FUTEX_WAKE
#endif
should become
//#if defined(FUTEX_WAIT_PRIVATE) && defined(FUTEX_WAKE_PRIVATE)
//# define ETHR_FUTEX_WAIT__ FUTEX_WAIT_PRIVATE
//# define ETHR_FUTEX_WAKE__ FUTEX_WAKE_PRIVATE
//#else
# define ETHR_FUTEX_WAIT__ FUTEX_WAIT
# define ETHR_FUTEX_WAKE__ FUTEX_WAKE
//#endif
Quick test
If you suspect the private futex issue is your problem, but want to verify it before you recompile all of Erlang, the following program can pin it down:
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
typedef uint32_t u32; /* required on older kernel headers to fix a bug in futex.h Delete this line if it causes problems. */
#include <linux/futex.h>
int main(int argc, char *argv[])
{
#if defined(FUTEX_WAIT) && defined(FUTEX_WAKE)
uint32_t i = 1;
int res = 0;
res = syscall(__NR_futex, (void *) &i, FUTEX_WAKE, 1,
(void*)0,(void*)0, 0);
if (res != 0)
{
printf("FUTEX_WAKE HAD ERR %i: %s\n", errno, strerror(errno));
} else {
printf("FUTEX_WAKE SUCCESS\n");
}
res = syscall(__NR_futex, (void *) &i, FUTEX_WAIT, 0,
(void*)0,(void*)0, 0);
if (res != 0)
{
printf("FUTEX_WAIT HAD ERR %i: %s\n", errno, strerror(errno));
} else {
printf("FUTEX_WAIT SUCCESS\n");
}
#else
printf("FUTEX_WAKE and FUTEX_WAIT are not defined.\n");
#endif
#if defined(FUTEX_WAIT_PRIVATE) && defined(FUTEX_WAKE_PRIVATE)
uint32_t j = 1;
int res_priv = 0;
res_priv = syscall(__NR_futex, (void *) &j, FUTEX_WAKE_PRIVATE, 1,
(void*)0,(void*)0, 0);
if (res_priv != 0)
{
printf("FUTEX_WAKE_PRIVATE HAD ERR %i: %s\n", errno, strerror(errno));
} else {
printf("FUTEX_WAKE_PRIVATE SUCCESS\n");
}
res_priv = syscall(__NR_futex, (void *) &j, FUTEX_WAIT_PRIVATE, 0,
(void*)0,(void*)0, 0);
if (res_priv != 0)
{
printf("FUTEX_WAIT_PRIVATE HAD ERR %i: %s\n", errno, strerror(errno));
} else {
printf("FUTEX_WAIT_PRIVATE SUCCESS\n");
}
#else
printf("FUTEX_WAKE_PRIVATE and FUTEX_WAIT_PRIVATE are not defined.\n");
#endif
return 0;
}
Paste it into futextest.c, then gcc futextest.c and ./a.out.
If your kernel implements private futexes, you'll see
FUTEX_WAKE SUCCESS
FUTEX_WAIT SUCCESS
FUTEX_WAKE_PRIVATE SUCCESS
FUTEX_WAIT_PRIVATE SUCCESS
If you have a kernel without the _PRIVATE futex functions, you'll see
FUTEX_WAKE SUCCESS
FUTEX WAIT SUCCESS
FUTEX_WAKE_PRIVATE HAD ERR 38: Function not implemented
FUTEX_WAIT_PRIVATE HAD ERR 38: Function not implemented
This fix should allow Erlang to compile, and will yield an environment you can install rabbitmq against using the --nodeps method discussed here.
I installed it by first installing erlang by source:
sudo yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
wget http://www.erlang.org/download/otp_src_R13B04.tar.gz
tar xfvz otp_src_R13B04.tar.gz
cd otp_src_R13B04/
./configure
sudo make install
After that create a symbolic link to also make erl available for root user:
sudo ln -s /usr/local/bin/erl /bin/erl
Install rabbitmq rpm (Maybe outdated check latest release yourself):
wget http://www.rabbitmq.com/releases/rabbitmq-server/v2.4.1/rabbitmq-server-2.4.1-1.noarch.rpm
rpm -Uvh rabbitmq-server-2.4.1-1.noarch.rpm
If erlang is installed from source, rpm install of rabbitmq fails to recognize erlang stating that erlang R12B-3 is required.
Use:
rpm --nodeps -Uvh rabbitmq-server-2.6.1-1.noarch.rpm
I was able to install and use RabbitMQ 2.6.1 successfully on CentOS 5.6 with Erlang R14B04
Seems that this kernel is not compatible with Erlang 14B, 14B01, or 14B02
Compiling Erlang 13B04 led to a successful install of rabbitmq-server
For people in the future finding this answer, the RabbitMQ site itself has a potential answer for you:
Installing on RPM-based Linux (CentOS, Fedora, OpenSuse, RedHat)
Erlang on RHEL 5 (and CentOS 5)
Due to the EPEL package update policy, EPEL 5 contains Erlang version
R12B-5, which is relatively old. rabbitmq-server supports R12B-5, but
performance may be lower than for more recent Erlang versions, and
certain non-core features are not supported (SSL support, HTTP-based
plugins including the management plugin). Therefore, we recommend that
you install the most recent stable version of Erlang. The easiest way
to do this is to use a package repository provided for this purpose by
the owner of the EPEL Erlang package. Enable it by invoking (as root):
wget -O /etc/yum.repos.d/epel-erlang.repo
http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo
and then install or update erlang with yum install erlang.
If you go down the route of building Erlang manually on a minimal OS install, you may also find that you need to install wxGTK & wxGTK-devel in order for all of the tests to build and run correctly.
Related
Running Pktgen with Lua scripts generates a failure User State for CLI not set for Lua.
The command I'm running is:
sudo -E ./usr/local/bin/pktgen --no-telemetry -l 4,6,8,10 -n 4 -a 0000:03:02.0 -m 1024 -- -T -P -m [6:8].0 -f test/hello-world.lua
Which gives the following result:
I have set the environment variables RTE_SDK=/root/Program/dpdk and
RTE_TARGET=x86_64-native-linux-gcc.
The failure comes from cli.c (link to code):
/**
* Load and execute a command file or Lua script file.
*
*/
int
cli_execute_cmdfile(const char *filename)
{
if (filename == NULL)
return 0;
gb_reset_buf(this_cli->gb);
if (strstr(filename, ".lua") || strstr(filename, ".LUA") ) {
if (!this_cli->user_state) {
cli_printf(">>> User State for CLI not set for Lua\n");
return -1;
}
if (lua_dofile) {
/* Execute the Lua script file. */
if (lua_dofile(this_cli->user_state, filename) != 0)
return -1;
} else
cli_printf(">>> Lua is not enabled in configuration!\n");
} else {
FILE *fd;
char buff[256];
fd = fopen(filename, "r");
if (fd == NULL)
return -1;
/* Read and feed the lines to the cmdline parser. */
while (fgets(buff, sizeof(buff), fd))
cli_input(buff, strlen(buff));
fclose(fd);
}
return 0;
}
So it would seem this_cli->user_state is not set, but how do you set it?
I have looked through the documentation for CLI, but it doesn't mention setting any user state from what I can see.
Update:
After having installed Lua and cmake, I ran meson -Denable_lua=true build which worked fine. But when I run ninja -C build I receive this error:
user_state is set in pktgen-main.c, but within a #ifdef LUA_ENABLED section.
Looking at meson_options.txt, which is at the base directory of a pktgen extraction, it contains:
option('enable_lua', type: 'boolean', value: false, description: 'Enable Lua support')
That means that you must enable Lua support when building (after installing dependencies, as shown below):
meson -Denable_lua=true build
This is going to require a few more dependencies, so you may have to install them, e.g. in Ubuntu:
sudo apt-get install cmake
And then installing Lua - I had to install it from source as per the instructions, because installing it with Ubuntu's package manager apt didn't give me the library that was needed:
curl -R -O http://www.lua.org/ftp/lua-5.4.4.tar.gz
tar zxf lua-5.4.4.tar.gz
cd lua-5.4.4
make all test
sudo make install
My environment is Lua-5.4.2 Luasocket-3.0-rc1.
When I run lua script directly, it work success.
When i run it through c language, it tell me error.
Error Msg is :
PANIC: unprotected error in call to Lua API (error running script: error loading module 'socket.core' from file '/usr/local/lib/lua/5.4/socket/core.so': undefined symbol: lua_gettop)
Aborted(core dumped)
Does anyone know why?
lua script code is:(test.lua)
#!/usr/local/bin/lua
local socket = require("socket")
print(socket._VERSION)
c code is:(main.c)
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
int main(void)
{
lua_State *L;
L = luaL_newstate();
luaopen_base(L);
luaL_openlibs(L);
printf("lua enter\n");
if (luaL_dofile(L, "test.lua"))
{
luaL_error(L, "error running script: %s", lua_tostring(L, -1));
}
printf("lua exit\n");
while(1) pause();
lua_close(L);
return 0;
}
tl;dr: Pass -Wl,-E to GCC.
I was able to reproduce your problem with this Dockerfile:
FROM gcc:11.1.0
RUN wget https://www.lua.org/ftp/lua-5.4.2.tar.gz \
&& git clone https://github.com/diegonehab/luasocket.git
RUN tar zxf lua-5.4.2.tar.gz \
&& cd lua-5.4.2 \
&& make linux \
&& make install \
&& cd ../luasocket \
&& git checkout 5b18e475f38fcf28429b1cc4b17baee3b9793a62 \
&& make linux LUAV=5.4 \
&& make install LUAV=5.4
COPY test.lua main.c ./
When I run lua test.lua in the resulting Docker container, it works fine. When I run gcc -o test main.c /usr/local/lib/liblua.a -ldl -lm -Wl,-rpath='/usr/local/lib/lua/5.4/socket' && ./test, I get the same panic that you get.
The reason that the standalone Lua binary works and yours doesn't is that the former is linked with -E:
MYLDFLAGS= $(LOCAL) -Wl,-E
ld's documentation for -E says this about it:
If you use dlopen to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself.
Lua uses dlopen to load C modules that you require, and said modules need to call Lua functions, which are linked into your binary, so it makes sense that you need this option. And indeed, when I add -Wl,-E to the GCC command line, then it works fine for me:
root#077bbb831441:/# gcc -o test main.c /usr/local/lib/liblua.a -ldl -lm -Wl,-rpath='/usr/local/lib/lua/5.4/socket' -Wl,-E && ./test
lua enter
LuaSocket 3.0-rc1
lua exit
I am trying to experiment with libFuzzer library and going through the toy-example[1].
keep-learnings-MacBook-Pro:Ccodeanalysis keep_learning$ cat Fuzzme.cpp
#include <stdint.h>
#include <stddef.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 0 && data[0] == 'H')
if (size > 1 && data[1] == 'I')
if (size > 2 && data[2] == '!')
__builtin_trap();
return 0;
}
keep-learnings-MacBook-Pro:Ccodeanalysis keep_learning$ clang++ -fsanitize=address,fuzzer Fuzzme.cpp
ld: file not found: /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclang_rt.fuzzer_osx.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
keep-learnings-MacBook-Pro:Ccodeanalysis keep_learning$ clang++ --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
A quick Google search showed me this [2], but other than that I could not find any meaningful information to resolve it, hence posting here. Could some one please tell me how to solve this ? Thanks in advance.
[1] http://llvm.org/docs/LibFuzzer.html#toy-example
[2] https://bugs.llvm.org/show_bug.cgi?id=39794
As you have noticed, there is no fuzzer runtime shipped with Apple developer tools. So you'd either report this issue to Apple folks, or build the runtime library by yourself from the sources (or both).
As Anton stated, Apple Developer Tools do not include the fuzzer library, leaving you to compile from source, or asking Apple.
It turns out LLVM also hosts pre-compiled binaries for some releases on their downloads page:
https://releases.llvm.org/download.html.
On that page, find your LLVM version (eg "Download LLVM 10.0.0"), and go a bit further until you see Pre-Built Binaries. Don't see binaries for your LLVM version? Pick the nearest lower version. The OP and I both have clang++ 10.0.1, so we'd pick 10.0.0.
Click the macOS link to download, pop into the Terminal to untar and copy the libraries, and you're done. I did it with a few environment variables (those paths are killer!), and a cp -n to preserve existing files.
export CLANG_ROOT=clang+llvm-10.0.0-x86_64-apple-darwin/lib/clang/10.0.0
export XCODE_ROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1
tar xvf clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz $CLANG_ROOT/include/fuzzer $CLANG_ROOT/lib/darwin
sudo cp -rn $CLANG_ROOT/include/fuzzer $XCODE_ROOT/include
sudo cp -n $CLANG_ROOT/lib/darwin/* $XCODE_ROOT/lib/darwin
I did exactly the above, and my code compiled and linked right away.
I installed drake binary in my ubuntu 16.04 xenial by
curl -o drake.tar.gz https://drake-packages.csail.mit.edu/drake/continuous/drake-latest-xenial.tar.gz
sudo tar -xvzf drake.tar.gz -C /opt
And I find_package(drake) in my cmake and try to do optimization.
But I got the following error
/opt/drake/include/drake/common/autodiff.h:15:1: error: static assertion failed: Drake requires Eigen >= v3.3.3.
static_assert(EIGEN_VERSION_AT_LEAST(3, 3, 3)
and
/opt/drake/include/drake/common/autodiffxd.h:232:69: error: ‘MakeAutoDiffScalar’ was not declared in this scope
return MakeAutoDiffScalar(m_value * other, m_derivatives * other);
I think I am including right Eigen which is located in
/opt/drake/include/eigen3.
How could I fix it?
By the way in the Mac, it works well with the same code.
It may be that you've (either directly or indirectly) called find_package(Eigen) before you did so on Drake, in which case CMake may be finding your system Eigen rather than the Drake-provided version; this is noted here (sorry that it's not yet in a more obvious location):
https://github.com/RobotLocomotion/drake-shambhala/tree/b3d7804/drake_cmake_installed/src/pcl#eigen
If you do find_package(drake) first, then it should allow find_package(Eigen) to work later on.
If that doesn't work, could you post a link to your code in a GitHub repository, or can you make a minimal reproduction issue?
How can I compile the VM and run Erlang programs on the Intel Xeon Phi coprocessor?
Intel Xeon Phi is not a typical x86_64 architecture, therefore it's not possible to run the official Erlang VM on it. The only way to do it is to use cross-compilation and build the VM yourself on a different (host) machine where Erlang is supported, so that it runs on a target system (Phi in this case).
Xeon Phi also supports slightly different instruction set than a typical x86_64 architecture, so you also need to edit the code. If you just cross-compile the VM without touching the code, you will probably get an error:
/tmp/iccvaLP3vas_.s: Assembler messages:
/tmp/iccvaLP3vas_.s:25794: Error: `mfence' is not supported on `k1om'
So first of all you need to add #ifndef clauses around memory fence instructions, which are not supported on Phi (mfence, lfence and sfence). This boils down to opening the erts/include/internal/i386/ethr_membar.h file and adding following preprocessor directives:
#ifndef __MIC__
...
#endif
around __asm__ statements in funtions ethr_mfence__, ethr_sfence__ and ethr_lfence__ e.g.
static __inline__ void
ethr_mfence__(void)
{
#if ETHR_SIZEOF_PTR == 4
if (ETHR_X86_RUNTIME_CONF_HAVE_NO_SSE2__)
ETHR_NO_SSE2_MEMORY_BARRIER__;
else
#endif
#ifndef __MIC__
__asm__ __volatile__ ("mfence\n\t" : : : "memory");
#endif
}
Now you can try to cross-compile it. First download the sources (in my case Erlang VM 17.5), then run:
$ cd otp_src_17.5
$ export ERL_TOP=`pwd`;
$ ./configure \
--host=k1om-unknown-linux-gnu \
--build=x86_64-pc-linux-gnu \
--without-termcap \
--without-javac \
--without-ssl \
--prefix=/path/to/my/new_installation \
CC=icc \
CFLAGS=-mmic \
LDFLAGS=-mmic \
DED_LD=icc \
DED_LDFLAGS="-mmic -shared -Wl,-Bsymbolic" \
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="-Wl,-R"
$ make
$ make install
icc is the official Intel Compiler and -mmic flag is required for compiling for Xeon Phi. The host and build flags are the systems/architectures of respectively the machine where you compile and the machine which you compile for (Phi). In my case they had following values, but if it's different for you, you might want to use the config.guess script which automatically detects your OS/CPU architecture.
$ ./config.guess
$ x86_64-pc-linux-gnu
And that's it! Now you should be able to ssh on your Phi and run Erlang.
$ ssh my-phi-coprocessor
$ cd /path/to/my/new_installation/
$ export PATH=`pwd`/bin:$PATH;
$ erl -version
Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 6.4