unbit / uwsgi

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

Segmentation fault on websockets_chat_2 test #1441

Closed alexpearce closed 3 years ago

alexpearce commented 7 years ago

I'm getting a segmentation fault when trying to run tests/websockets_chat_2.py. My OS is macOS 10.12.1, using Python 3.5.2.

Steps to reproduce

# Install dependencies
$ brew install openssl
$ pip install virtualenv

# Install uWSGI inside a virtual environment
$ git clone https://github.com/unbit/uwsgi
$ cd uwsgi
$ virtualenv -p python3 env
$ . env/bin/activate
$ env CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" UWSGI_PROFILE_OVERRIDE=ssl=true python setup.py install

# Run the test
$ pip install gevent
$ uwsgi --http-socket :9090  --http-raw-body --gevent 100 --module tests.websockets_chat_2 -H ./env

The test needs modifying to convert print <foo> to print(<foo>).

Output

Build log

/Users/apearce/Desktop/uwsgi/env/lib/python3.5/site-packages/setuptools/dist.py:342: UserWarning: The version specified ('2.1-dev-4d41e906') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
  "details." % self.metadata.version
running install
using profile: buildconf/default.ini
detected include path: ['/usr/local/include', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include', '/usr/include', '/System/Library/Frameworks', '/Library/Frameworks']
Patching "bin_name" to properly install_scripts dir
detected CPU cores: 4
configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/local/opt/openssl/include -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-format -Wno-format-security -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -mmacosx-version-min=10.5 -DUWSGI_LOCK_USE_OSX_SPINLOCK -DUWSGI_EVENT_USE_KQUEUE -DUWSGI_EVENT_TIMER_USE_KQUEUE -DUWSGI_EVENT_FILEMONITOR_USE_KQUEUE -I/usr/local/Cellar/pcre/8.39/include -DUWSGI_PCRE -DUWSGI_ROUTING -DUWSGI_UUID -DUWSGI_VERSION="\"2.1-dev-4d41e906\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="1" -DUWSGI_VERSION_MINOR="0" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"dev-4d41e906\"" -DUWSGI_YAML -DUWSGI_SSL -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 -DUWSGI_XML -DUWSGI_XML_LIBXML2 -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);UDEP(router_fcgi);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);ULEP(router_fcgi);"
*** uWSGI compiling server core ***
[thread 1][clang] core/utils.o
[thread 3][clang] core/protocol.o
[thread 2][clang] core/socket.o
[thread 0][clang] core/logging.o
[thread 1][clang] core/master.o
[thread 3][clang] core/master_utils.o
[thread 2][clang] core/emperor.o
[thread 0][clang] core/notify.o
[thread 1][clang] core/mule.o
[thread 3][clang] core/subscription.o
[thread 2][clang] core/stats.o
[thread 0][clang] core/sendfile.o
[thread 1][clang] core/async.o
[thread 3][clang] core/master_checks.o
[thread 2][clang] core/fifo.o
[thread 0][clang] core/offload.o
[thread 1][clang] core/io.o
[thread 3][clang] core/static.o
[thread 2][clang] core/websockets.o
[thread 0][clang] core/spooler.o
[thread 1][clang] core/snmp.o
[thread 3][clang] core/exceptions.o
[thread 2][clang] core/config.o
[thread 0][clang] core/setup_utils.o
[thread 1][clang] core/clock.o
[thread 3][clang] core/init.o
[thread 2][clang] core/buffer.o
[thread 0][clang] core/reader.o
[thread 1][clang] core/writer.o
[thread 3][clang] core/alarm.o
[thread 2][clang] core/cron.o
[thread 0][clang] core/hooks.o
[thread 1][clang] core/plugins.o
[thread 3][clang] core/lock.o
[thread 2][clang] core/cache.o
[thread 0][clang] core/daemons.o
[thread 1][clang] core/errors.o
[thread 3][clang] core/hash.o
[thread 2][clang] core/master_events.o
[thread 0][clang] core/chunked.o
[thread 1][clang] core/queue.o
[thread 3][clang] core/event.o
[thread 2][clang] core/signal.o
[thread 0][clang] core/strings.o
[thread 1][clang] core/progress.o
[thread 3][clang] core/timebomb.o
[thread 2][clang] core/ini.o
[thread 0][clang] core/fsmon.o
[thread 1][clang] core/mount.o
[thread 3][clang] core/metrics.o
[thread 2][clang] core/plugins_builder.o
[thread 0][clang] core/sharedarea.o
[thread 1][clang] core/fork_server.o
[thread 3][clang] core/webdav.o
[thread 2][clang] core/zeus.o
[thread 0][clang] core/rpc.o
[thread 1][clang] core/gateway.o
[thread 3][clang] core/loop.o
[thread 2][clang] core/cookie.o
[thread 0][clang] core/querystring.o
[thread 1][clang] core/rb_timers.o
[thread 3][clang] core/transformations.o
[thread 2][clang] core/uwsgi.o
[thread 0][clang] proto/base.o
[thread 1][clang] proto/uwsgi.o
[thread 3][clang] proto/http.o
[thread 2][clang] proto/fastcgi.o
[thread 0][clang] proto/scgi.o
[thread 1][clang] proto/puwsgi.o
[thread 3][clang] core/zlib.o
[thread 2][clang] core/regexp.o
[thread 0][clang] core/routing.o
[thread 1][clang] core/yaml.o
[thread 3][clang] core/ssl.o
[thread 2][clang] core/legion.o
[thread 0][clang] core/xmlconf.o
[thread 1][clang] core/dot_h.o
[thread 3][clang] core/config_py.o
*** uWSGI compiling embedded plugins ***
[thread 2][clang] plugins/python/python_plugin.o
[thread 0][clang] plugins/python/pyutils.o
[thread 1][clang] plugins/python/pyloader.o
[thread 3][clang] plugins/python/wsgi_handlers.o
[thread 2][clang] plugins/python/wsgi_headers.o
[thread 0][clang] plugins/python/wsgi_subhandler.o
[thread 1][clang] plugins/python/web3_subhandler.o
[thread 3][clang] plugins/python/pump_subhandler.o
[thread 2][clang] plugins/python/gil.o
[thread 0][clang] plugins/python/uwsgi_pymodule.o
[thread 1][clang] plugins/python/profiler.o
[thread 3][clang] plugins/python/symimporter.o
[thread 2][clang] plugins/python/tracebacker.o
[thread 0][clang] plugins/python/raw.o
[thread 1][clang] plugins/gevent/gevent.o
[thread 3][clang] plugins/gevent/hooks.o
[thread 2][clang] plugins/ping/ping_plugin.o
[thread 0][clang] plugins/cache/cache.o
[thread 1][clang] plugins/nagios/nagios.o
[thread 3][clang] plugins/rrdtool/rrdtool.o
[thread 2][clang] plugins/carbon/carbon.o
[thread 0][clang] plugins/rpc/rpc_plugin.o
[thread 1][clang] plugins/corerouter/cr_common.o
[thread 3][clang] plugins/corerouter/cr_map.o
[thread 2][clang] plugins/corerouter/corerouter.o
[thread 0][clang] plugins/fastrouter/fastrouter.o
[thread 1][clang] plugins/http/http.o
[thread 3][clang] plugins/http/keepalive.o
[thread 2][clang] plugins/http/https.o
[thread 0][clang] plugins/http/spdy3.o
[thread 1][clang] plugins/signal/signal_plugin.o
[thread 3][clang] plugins/syslog/syslog_plugin.o
[thread 2][clang] plugins/rsyslog/rsyslog_plugin.o
[thread 0][clang] plugins/logsocket/logsocket_plugin.o
[thread 1][clang] plugins/router_uwsgi/router_uwsgi.o
[thread 3][clang] plugins/router_redirect/router_redirect.o
[thread 2][clang] plugins/router_basicauth/router_basicauth.o
[thread 0][clang] plugins/zergpool/zergpool.o
[thread 1][clang] plugins/redislog/redislog_plugin.o
[thread 3][clang] plugins/mongodblog/mongodblog_plugin.o
[thread 2][clang] plugins/router_rewrite/router_rewrite.o
[thread 0][clang] plugins/router_http/router_http.o
[thread 1][clang] plugins/logfile/logfile.o
[thread 3][clang] plugins/router_cache/router_cache.o
[thread 2][clang] plugins/rawrouter/rawrouter.o
[thread 0][clang] plugins/router_static/router_static.o
[thread 1][clang] plugins/sslrouter/sslrouter.o
[thread 3][clang] plugins/spooler/spooler_plugin.o
[thread 2][clang] plugins/cheaper_busyness/cheaper_busyness.o
[thread 0][clang] plugins/symcall/symcall_plugin.o
[thread 1][clang] plugins/transformation_tofile/tofile.o
[thread 3][clang] plugins/transformation_gzip/gzip.o
[thread 2][clang] plugins/transformation_chunked/chunked.o
[thread 0][clang] plugins/transformation_offload/offload.o
[thread 1][clang] plugins/router_memcached/router_memcached.o
[thread 3][clang] plugins/router_redis/router_redis.o
[thread 2][clang] plugins/router_hash/router_hash.o
[thread 0][clang] plugins/router_expires/expires.o
[thread 1][clang] plugins/router_metrics/plugin.o
[thread 3][clang] plugins/transformation_template/tt.o
[thread 2][clang] plugins/stats_pusher_socket/plugin.o
[thread 0][clang] plugins/router_fcgi/router_fcgi.o
*** uWSGI linking ***
clang -o /Users/apearce/Desktop/uwsgi/env/bin/uwsgi -L/usr/local/opt/openssl/lib core/utils.o core/protocol.o core/socket.o core/logging.o core/master.o core/master_utils.o core/emperor.o core/notify.o core/mule.o core/subscription.o core/stats.o core/sendfile.o core/async.o core/master_checks.o core/fifo.o core/offload.o core/io.o core/static.o core/websockets.o core/spooler.o core/snmp.o core/exceptions.o core/config.o core/setup_utils.o core/clock.o core/init.o core/buffer.o core/reader.o core/writer.o core/alarm.o core/cron.o core/hooks.o core/plugins.o core/lock.o core/cache.o core/daemons.o core/errors.o core/hash.o core/master_events.o core/chunked.o core/queue.o core/event.o core/signal.o core/strings.o core/progress.o core/timebomb.o core/ini.o core/fsmon.o core/mount.o core/metrics.o core/plugins_builder.o core/sharedarea.o core/fork_server.o core/webdav.o core/zeus.o core/rpc.o core/gateway.o core/loop.o core/cookie.o core/querystring.o core/rb_timers.o core/transformations.o core/uwsgi.o proto/base.o proto/uwsgi.o proto/http.o proto/fastcgi.o proto/scgi.o proto/puwsgi.o core/zlib.o core/regexp.o core/routing.o core/yaml.o core/ssl.o core/legion.o core/xmlconf.o core/dot_h.o core/config_py.o plugins/python/python_plugin.o plugins/python/pyutils.o plugins/python/pyloader.o plugins/python/wsgi_handlers.o plugins/python/wsgi_headers.o plugins/python/wsgi_subhandler.o plugins/python/web3_subhandler.o plugins/python/pump_subhandler.o plugins/python/gil.o plugins/python/uwsgi_pymodule.o plugins/python/profiler.o plugins/python/symimporter.o plugins/python/tracebacker.o plugins/python/raw.o plugins/gevent/gevent.o plugins/gevent/hooks.o plugins/ping/ping_plugin.o plugins/cache/cache.o plugins/nagios/nagios.o plugins/rrdtool/rrdtool.o plugins/carbon/carbon.o plugins/rpc/rpc_plugin.o plugins/corerouter/cr_common.o plugins/corerouter/cr_map.o plugins/corerouter/corerouter.o plugins/fastrouter/fastrouter.o plugins/http/http.o plugins/http/keepalive.o plugins/http/https.o plugins/http/spdy3.o plugins/signal/signal_plugin.o plugins/syslog/syslog_plugin.o plugins/rsyslog/rsyslog_plugin.o plugins/logsocket/logsocket_plugin.o plugins/router_uwsgi/router_uwsgi.o plugins/router_redirect/router_redirect.o plugins/router_basicauth/router_basicauth.o plugins/zergpool/zergpool.o plugins/redislog/redislog_plugin.o plugins/mongodblog/mongodblog_plugin.o plugins/router_rewrite/router_rewrite.o plugins/router_http/router_http.o plugins/logfile/logfile.o plugins/router_cache/router_cache.o plugins/rawrouter/rawrouter.o plugins/router_static/router_static.o plugins/sslrouter/sslrouter.o plugins/spooler/spooler_plugin.o plugins/cheaper_busyness/cheaper_busyness.o plugins/symcall/symcall_plugin.o plugins/transformation_tofile/tofile.o plugins/transformation_gzip/gzip.o plugins/transformation_chunked/chunked.o plugins/transformation_offload/offload.o plugins/router_memcached/router_memcached.o plugins/router_redis/router_redis.o plugins/router_hash/router_hash.o plugins/router_expires/expires.o plugins/router_metrics/plugin.o plugins/transformation_template/tt.o plugins/stats_pusher_socket/plugin.o plugins/router_fcgi/router_fcgi.o -lpthread -lm -lz -L/usr/local/Cellar/pcre/8.39/lib -lpcre -lssl -lcrypto -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib -lxml2 -lz -lpthread -licucore -lm -ldl -framework CoreFoundation /usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/config-3.5m/libpython3.5m.a
################# uWSGI configuration #################

locking = osx_spinlock
filemonitor = kqueue
pcre = True
yaml = embedded
event = kqueue
json = False
ucontext = False
capabilities = False
routing = True
kernel = Darwin
timer = kqueue
ifaddrs = True
xml = libxml2
debug = False
zlib = True
malloc = libc
execinfo = False
plugin_dir = .
ssl = True

############## end of uWSGI configuration #############
total build time: 32 seconds
*** uWSGI is ready, launch it with /Users/apearce/Desktop/uwsgi/env/bin/uwsgi ***
running build
running build_py
creating build
creating build/lib
copying uwsgidecorators.py -> build/lib
running install_lib
copying build/lib/uwsgidecorators.py -> /Users/apearce/Desktop/uwsgi/env/lib/python3.5/site-packages
byte-compiling /Users/apearce/Desktop/uwsgi/env/lib/python3.5/site-packages/uwsgidecorators.py to uwsgidecorators.cpython-35.pyc
running install_egg_info
running egg_info
creating uWSGI.egg-info
writing top-level names to uWSGI.egg-info/top_level.txt
writing uWSGI.egg-info/PKG-INFO
writing dependency_links to uWSGI.egg-info/dependency_links.txt
writing manifest file 'uWSGI.egg-info/SOURCES.txt'
reading manifest file 'uWSGI.egg-info/SOURCES.txt'
writing manifest file 'uWSGI.egg-info/SOURCES.txt'
Copying uWSGI.egg-info to /Users/apearce/Desktop/uwsgi/env/lib/python3.5/site-packages/uWSGI-2.1_dev_4d41e906-py3.5.egg-info
running install_scripts

Server log

*** Starting uWSGI 2.1-dev-4d41e906 (64bit) on [Sun Jan 15 12:35:51 2017] ***
compiled with version: 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1) on 15 January 2017 12:33:07
os: Darwin-16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64
nodename: okami
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /Users/apearce/Desktop/uwsgi
detected binary path: /Users/apearce/Desktop/uwsgi/env/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 709
your memory page size is 4096 bytes
detected max file descriptor number: 256
- async cores set to 100 - fd table size: 256
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :9090 fd 3
Python version: 3.5.2 (default, Jul 28 2016, 21:28:00)  [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Set PythonHome to ./env
Python main interpreter initialized at 0x7fdd76c0a330
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
your request buffer size is 4096 bytes
mapped 1096864 bytes (1071 KB) for 100 cores
*** Operational MODE: async ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x7fdd76c0a330 pid: 90940 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 90940, cores: 100)
*** running gevent loop engine [addr:0x1018c2fb0] ***
[pid: 90940|app: 0|req: 1/1] 127.0.0.1 () {34 vars in 745 bytes} [Sun Jan 15 12:35:55 2017] GET / => generated 0 bytes in 9 msecs (HTTP/1.1 200) 1 headers in 44 bytes (1145 switches on core 99)
!!! uWSGI process 90940 got Segmentation Fault !!!
*** backtrace of 90940 ***
0   uwsgi                               0x00000001018977a0 uwsgi_backtrace + 48
1   uwsgi                               0x0000000101897ce3 uwsgi_segfault + 51
2   libsystem_platform.dylib            0x00007fff9ddbdbba _sigtramp + 26
3   ???                                 0x0000000102354b88 0x0 + 4332014472
*** end of backtrace ***

Comments

The backtrace is pretty short. Perhaps there's a build option I should activate to make debugging this easier?

alexpearce commented 7 years ago

The problem isn't present in e55ac, so . I don't have time to bisect right now but I can try to get around to it at some point.

alexpearce commented 3 years ago

Not sure what the state of this is in master, but will close the issue as stale.