unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 691 forks source link

mongrel2 plugin fails to build with libyajl as JSON parser #2357

Open jonassmedegaard opened 3 years ago

jonassmedegaard commented 3 years ago

Attempting to build uWSGI linked with libyajl instead of libjansson causes failure in plugin mongrel2:

################# uWSGI configuration #################

kernel = Linux
execinfo = False
ifaddrs = True
locking = pthread_mutex
event = epoll
timer = timerfd
filemonitor = inotify
pcre = True
routing = True
capabilities = True
yaml = libyaml
json = yajl
ssl = True
xml = libxml2
debug = False
plugin_dir = /usr/lib/uwsgi/plugins
zlib = True
ucontext = True
malloc = libc

############## end of uWSGI configuration #############
total build time: 7 seconds
*** uWSGI is ready, launch it with ./uwsgi-core ***
set -e; \
for PLUGIN_NAME in cache carbon cgi cheaper_backlog2 cheaper_busyness clock_monotonic clock_realtime corerouter echo emperor_amqp emperor_zeromq fastrouter forkptyrouter http logcrypto logfile logpipe logsocket logzmq mongrel2 msgpack nagios notfound pam ping pty rawrouter redislog router_basicauth router_cache router_expires router_hash router_http router_memcached router_metrics router_radius router_redirect router_redis router_rewrite router_static router_uwsgi router_xmldir rpc rrdtool rsyslog signal spooler ssi sslrouter stats_pusher_file stats_pusher_socket stats_pusher_statsd symcall syslog systemd_logger transformation_chunked transformation_gzip transformation_offload transformation_template transformation_tofile transformation_toupper tuntap ugreen webdav xattr zabbix zergpool; do \
    CFLAGS="-g -O2 -ffile-prefix-map=/build/uwsgi-2.0.20=. -fstack-protector-strong -Wformat -Werror=format-security" CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2" LDFLAGS="-Wl,-z,relro" python3 uwsgiconfig.py -v \
    --plugin plugins/${PLUGIN_NAME} \
    debian/buildconf/uwsgi-plugin.ini \
    ${PLUGIN_NAME}; \
done
using profile: debian/buildconf/uwsgi-plugin.ini
detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/11/include', '/usr/local/include', '/usr/include/x86_64-linux-gnu', '/usr/include']

...

plugins/mongrel2/mongrel2.c:21:10: fatal error: jansson.h: No such file or directory
   21 | #include <jansson.h>
      |          ^~~~~~~~~~~
compilation terminated.

Reason I wanted to switch JSON parse was this report of symbol leaks aused problems with applications linking (transitively) against both libjansson and libjson.

xrmx commented 3 years ago

I'd just disable the mongrel plugin then, not sure there's many users out there.

jonassmedegaard commented 3 years ago

Turns out what fails is building in an environment where only libyajl headers are available. What works is to install both libyajl and libjansson headers and configure the build to explicitly use json = yajl (not json = yes). Then uWSGI generally links against libyajl and only mongrel2 plugin links against libjansson.

Seems to be that this issue is solved by changing mongrel2 plugin to not only check for UWSGI_JSON but also do a negated check for both UWSGI_JSON_YAJL and UWSGI_JSON_YAJL_OLD.

I recommend to also document that mongrel2 plugin requires libjansson and how it behaves (fails to build or silently disables certain communication) if switching to libuyajl.