Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 680058 - www-servers/uwsgi-2.0.18 : /.../environment:line <snip>: <snip> Segmentation fault python uwsgiconfig.py --build gentoo
Summary: www-servers/uwsgi-2.0.18 : /.../environment:line <snip>: <snip> Segmentation ...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Ultrabug
URL:
Whiteboard:
Keywords:
: 690450 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-03-11 19:42 UTC by Toralf Förster
Modified: 2019-09-05 19:41 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge-info.txt (emerge-info.txt,16.43 KB, text/plain)
2019-03-11 19:42 UTC, Toralf Förster
Details
emerge-history.txt (emerge-history.txt,194.37 KB, text/plain)
2019-03-11 19:42 UTC, Toralf Förster
Details
environment (environment,254.58 KB, text/plain)
2019-03-11 19:42 UTC, Toralf Förster
Details
etc.portage.tbz2 (etc.portage.tbz2,15.36 KB, application/x-bzip)
2019-03-11 19:42 UTC, Toralf Förster
Details
logs.tbz2 (logs.tbz2,137 bytes, application/x-bzip)
2019-03-11 19:42 UTC, Toralf Förster
Details
temp.tbz2 (temp.tbz2,52.60 KB, application/x-bzip)
2019-03-11 19:42 UTC, Toralf Förster
Details
www-servers:uwsgi-2.0.18:20190311-025329.log (www-servers:uwsgi-2.0.18:20190311-025329.log,10.33 KB, text/plain)
2019-03-11 19:42 UTC, Toralf Förster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2019-03-11 19:42:02 UTC
*** uWSGI compiling embedded plugins ***
[thread 8][x86_64-pc-linux-gnu-gcc -pthread] plugins/ping/ping_plugin.o
/var/tmp/portage/www-servers/uwsgi-2.0.18/temp/environment: line 6614:    27 Segmentation fault      python uwsgiconfig.py --build gentoo
 * ERROR: www-servers/uwsgi-2.0.18::gentoo failed (compile phase):
 *   building uwsgi failed
 * 

  -------------------------------------------------------------------

  This is an unstable amd64 chroot image at a tinderbox (==build bot)
  name: 17.1-systemd_abi32+64_20190306-071626

  -------------------------------------------------------------------

gcc-config -l:
 [1] x86_64-pc-linux-gnu-7.3.1
 [2] x86_64-pc-linux-gnu-8.3.0 *

Available Python interpreters, in order of preference:
  [1]   python3.6
  [2]   python2.7 (fallback)
Available Ruby profiles:
  [1]   ruby24 (with Rubygems) *
  [2]   ruby25 (with Rubygems)
  [3]   ruby26 (with Rubygems)
Available Rust versions:
  [1]   rust-1.32.0 *
  [2]   rust-bin-1.32.0



emerge -qpvO www-servers/uwsgi
[ebuild  N    ] www-servers/uwsgi-2.0.18  USE="caps embedded pcre perl routing ssl xml -apache2 -cgi -debug -expat -go -jemalloc -json -libressl -lua -mono -php -pypy -python -python_asyncio -python_gevent -ruby (-selinux) -yajl -yaml -zeromq" PHP_TARGETS="php5-6 php7-1 -php7-2 -php7-3" PYTHON_TARGETS="python2_7 python3_6 -pypy -python3_4 -python3_5 -python3_7" RUBY_TARGETS="ruby24 ruby25 -ruby23" UWSGI_PLUGINS="cache carbon cheaper_busyness corerouter fastrouter http logfile logsocket mongodblog nagios ping rawrouter redislog router_basicauth router_cache router_expires router_hash router_http router_memcached router_metrics router_redirect router_redis router_rewrite router_static router_uwsgi rpc rrdtool rsyslog signal spooler sslrouter symcall syslog transformation_chunked transformation_gzip transformation_offload transformation_tofile ugreen zergpool -alarm_curl -alarm_xmpp -clock_monotonic -clock_realtime -curl_cron -dumbloop -echo -emperor_amqp -emperor_pg -emperor_zeromq -forkptyrouter -geoip -graylog2 -ldap -legion_cache_fetch -logcrypto -logpipe -notfound -pam -rados -router_access -router_radius -router_spnego -router_xmldir -sqlite -ssi -stats_pusher_statsd -systemd_logger -transformation_toupper -tuntap -webdav -xattr -xslt -zabbix"
Comment 1 Toralf Förster gentoo-dev 2019-03-11 19:42:05 UTC
Created attachment 568588 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2019-03-11 19:42:08 UTC
Created attachment 568590 [details]
emerge-history.txt
Comment 3 Toralf Förster gentoo-dev 2019-03-11 19:42:11 UTC
Created attachment 568592 [details]
environment
Comment 4 Toralf Förster gentoo-dev 2019-03-11 19:42:13 UTC
Created attachment 568594 [details]
etc.portage.tbz2
Comment 5 Toralf Förster gentoo-dev 2019-03-11 19:42:16 UTC
Created attachment 568596 [details]
logs.tbz2
Comment 6 Toralf Förster gentoo-dev 2019-03-11 19:42:19 UTC
Created attachment 568598 [details]
temp.tbz2
Comment 7 Toralf Förster gentoo-dev 2019-03-11 19:42:22 UTC
Created attachment 568600 [details]
www-servers:uwsgi-2.0.18:20190311-025329.log
Comment 8 Louis Sautier (sbraz) gentoo-dev 2019-03-30 15:54:09 UTC
Works with sys-apps/sandbox 2.14 but not 2.15.
Looks like this is the only commit between them:
https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=f3e51a930312422cc78b693a247b7c5704ac90a2
Comment 9 Sergei Trofimovich gentoo-dev 2019-03-30 18:52:16 UTC
Reproduced locally. I'll have a look and get a backtrace.
Comment 10 Sergei Trofimovich gentoo-dev 2019-03-30 19:53:02 UTC
Trigger:

uwsgi does something very unusual: it runs execve() syscall from a separate thread similar to vfork() but done manually(?) via clone() without CLONE_VM|CLONE_THREAD.

A few examples from strace are:

  8810  clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fba46f66a10) = 8827
  8827  execve("/bin/sh", ["/bin/sh", "-c", "pcre-config --libs"], 0x7ffdb82b33b0 /* 36 vars */ <unfinished ...>
  8827  <... execve resumed>)             = 0

  8827  clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f93dd430850) = 8828
  8828  execve("/usr/bin/uname", ["uname", "-s"], 0x560a14ae7bc0 /* 36 vars */) = 0

Breakage mechanics:

Lack of CLONE_VM will introduce loads/stores of 'environ' global variable in sandbox's execvp() (I think) wrapper. Lack of CLONE_THREAD allows you to run execv*() syscalls in standalone threads sharing address space.

I don't know if uwsgi explicitly imposes a limitation on mutation of global state. The setup looks very fragile. But not unreasonable.

Possible plan for a fix:

On linux we can work it around in sandbox by emulating execvp(ARGS) via execvpe(ARGS, <sandbox_srafter_env>). execvpe() is non-standard (available on _GNU_SOURCE)

Workarounds:

Build single-threaded (equivalent of MAKEOPTS=-j1) or disable sandbox in uwsgi ebuild.
Comment 11 Toralf Förster gentoo-dev 2019-09-05 19:41:46 UTC
*** Bug 690450 has been marked as a duplicate of this bug. ***