Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system() broken on nt #31

Closed
l1ghtn1ngth1ef opened this issue Jan 12, 2021 · 2 comments
Closed

system() broken on nt #31

l1ghtn1ngth1ef opened this issue Jan 12, 2021 · 2 comments
Assignees

Comments

@l1ghtn1ngth1ef
Copy link

l1ghtn1ngth1ef commented Jan 12, 2021

First of all Justine I'd just like to go on the record as to commend you for all of your hard work and ongoing efforts regarding such a wonderful C Library. Honestly, hats off to you for such arduous, though rewarding work. Thank you :)

Sidenote: I've googled you out and you seem like a highly knowledgeable and rather inspiring character. Thank you again ;)

To the problems at hand, as confirmed earlier via private channels I am experiencing issues with system() calls not functioning on linux.

for example;

int main(){system("pause");return 0;}

The above appears to be working in windows with regard to system("pause"); however the former appears to cause a segmentation fault on my linux system.

Similarly, int main() {system("notepad");return 0;} also appears to exit in windows without running any programs.

The command line used to build the program is;

gcc -O -s -static -nostdlib -nostdinc -fno-pie -Wl,--oformat=binary -Wl,-T,ape.lds -o velociraptor.com velociraptor.c -include cosmopolitan.h crt.o ape.o cosmopolitan.a

My build system is sexy (though not exotic) and is as follows;

Portage 3.0.12 (python 3.8.6-final-0, default/linux/amd64/17.1, gcc-9.3.0, glibc-2.32-r3, 5.4.38-gentoo x86_64)

System uname: Linux-5.4.38-gentoo-x86_64-Intel_Core_Processor_-Skylake,_IBRS-with-glibc2.2.5
KiB Mem: 2031684 total, 120236 free
KiB Swap: 2097148 total, 1108220 free
Timestamp of repository gentoo: Wed, 06 Jan 2021 17:00:01 +0000
Head commit of repository gentoo: 40b5215293801bc29a2410a16a0da1725faadb67
sh bash 5.0_p18
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
app-shells/bash: 5.0_p18::gentoo
dev-java/java-config: 2.3.1::gentoo
dev-lang/perl: 5.30.3::gentoo
dev-lang/python: 2.7.18-r5::gentoo, 3.7.9-r1::gentoo, 3.8.6-r1::gentoo, 3.9.0-r1::gentoo
dev-util/cmake: 3.17.4-r1::gentoo
sys-apps/baselayout: 2.7::gentoo
sys-apps/openrc: 0.42.1::gentoo
sys-apps/sandbox: 2.20::gentoo
sys-devel/autoconf: 2.69-r5::gentoo
sys-devel/automake: 1.16.2-r1::gentoo
sys-devel/binutils: 2.33.1-r1::gentoo, 2.34-r2::gentoo
sys-devel/gcc: 9.3.0-r2::gentoo
sys-devel/gcc-config: 2.3.2-r1::gentoo
sys-devel/libtool: 2.4.6-r6::gentoo
sys-devel/make: 4.3::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc: 2.32-r3::gentoo
Repositories:

gentoo
location: /var/db/repos/gentoo
sync-type: rsync
sync-uri: rsync://rsync.gentoo.org/gentoo-portage
priority: -1000
sync-rsync-verify-max-age: 24
sync-rsync-extra-opts:
sync-rsync-verify-jobs: 1
sync-rsync-verify-metamanifest: yes

x-portage
location: /usr/local/portage
masters: gentoo
priority: 0

lmiphay
location: /var/lib/layman/lmiphay
masters: gentoo
priority: 50

lua
location: /var/lib/layman/lua
masters: gentoo
priority: 50

menelkir
location: /var/lib/layman/menelkir
masters: gentoo
priority: 50

spikyatlinux
location: /var/lib/layman/spikyatlinux
masters: gentoo
priority: 50

vmacs
location: /var/lib/layman/vmacs
masters: gentoo
priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -Wno-error=unused-result -Wno-error=unused-result"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.4/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cli-php7.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -Wno-error=unused-result"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe -Wno-error=unused-result"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -Wno-error=unused-result"
GENTOO_MIRRORS="ftp://ftp.swin.edu.au/gentoo http://ftp.swin.edu.au/gentoo"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j2"
PKGDIR="/var/cache/binpkgs"
PORTAGE_BINHOST="http://packages.gentooexperimental.org/packages/amd64-stable/"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 berkdb bindist bzip2 clamav cli cron crypt curl dhcp dovecot dovecot-sasl dri fortran fpm gdbm geoip geoip2 gnutls gzip iconv imap ipv6 libglvnd libtirpc lua luajit mailbox maildir mailutils mariadb mbox multilib mysql ncurses nginx nls nptl ocaml openmp pam pcre php pop postfix readline sasl sasl-auth saslauth seccomp sendmail smtp sockets spamassassin split-usr sqlite ssl sslv3 tcpd unicode xattr zip zlib" ABI_X86="32 64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="openssl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" NGINX_MODULES_HTTP="image_filter access auth_basic autoindex browser charset empty_gif fastcgi geo grpc gzip limit_conn limit_req map memcached mirror proxy referer rewrite scgi split_clients ssi upstream_hash upstream_ip_hash upstream_keepalive upstream_least_conn upstream_zone userid uwsgi" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python2_7 python3_8" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTSURSEXYLOL

I hope we can get this working soon :)

Thanks!

@l1ghtn1ngth1ef l1ghtn1ngth1ef changed the title System Calls Failing for Linix System Calls Failing for Linux Jan 12, 2021
@l1ghtn1ngth1ef l1ghtn1ngth1ef changed the title System Calls Failing for Linux System Calls Failing for Linux & Windows Jan 12, 2021
@jart jart changed the title System Calls Failing for Linux & Windows system() broken on nt Jan 16, 2021
@jart jart self-assigned this Jan 16, 2021
jart added a commit that referenced this issue Jan 17, 2021
It turned out that the linker was doing the wrong with the amalgamation
library concerning weak stubs. A regression test has been added and new
binaries have been uploaded to https://justine.lol/cosmopolitan/

Ideally this should be fixed by building a tool that turns multiple .a
files into a single .a file with deduplication. As a workaround for now
the cosmopolitan.a build is restructured to not include LIBC_STUBS which
meant technical debt needed to be paid off where non-stub interfaces
were moved to LIBC_INTRIN and LIBC_NEXGEN32E.

Thank @PerfectProductions in #31 for the report!
@l1ghtn1ngth1ef
Copy link
Author

Hey Justine. Thanks for the update. I'm happy to confirm the new commit resolves my linux system() issues.

Looking very much forward to the Win/NT solution.

Will keep an eye on things for you.

Cheers!

@jart
Copy link
Owner

jart commented Jan 20, 2021

Glad to hear it! The commit log documents other cool bugs that got fixed last weekend. You'll be pleased to know we now have an x86_64-linux-gnu toolchain for Windows that lets you compile your Actually Portable Executables on Windows: https://justine.lol/cosmopolitan/windows-compiling.html Thank NASA for helping to make that possible. You'll be the first to know when system() on windows is fixed. Please file issues if you encounter anything else.

@jart jart closed this as completed in 45b7248 Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants