Skip to content

Add clang ASAN/UBSAN push job #9878

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 180 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,188 @@
env:
CIRRUS_CLONE_DEPTH: 1
ARCH: amd64

freebsd_instance:
image_family: freebsd-13-0
asan_task:
name: ASAN_DEBUG_NTS
container:
image: gcc:latest
additional_containers:
- name: mysql
image: mysql:latest
port: 3306
env:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "test"
install_script:
- apt-get update -y
- >-
apt-get install -y
bison
re2c
locales
locales-all
`#ldap-utils`
openssl
`slapd`
libgmp-dev
libicu-dev
`#libtidy-dev`
`#libenchant-dev`
libaspell-dev
libpspell-dev
libsasl2-dev
libxpm-dev
libzip-dev
`#libsqlite3-dev`
libwebp-dev
libonig-dev
libkrb5-dev
libgssapi-krb5-2
libcurl4-openssl-dev
libxml2-dev
libxslt1-dev
libpq-dev
libreadline-dev
`#libldap2-dev`
libsodium-dev
libargon2-0-dev
libmm-dev
`#libsnmp-dev`
`#postgresql`
`#postgresql-contrib`
`#snmpd`
`#snmp-mibs-downloader`
`#freetds-dev`
`#unixodbc-dev`
llvm
clang
libc-client-dev
dovecot-core
dovecot-pop3d
dovecot-imapd
`#sendmail`
`#firebird-dev`
liblmdb-dev
libtokyocabinet-dev
libdb-dev
libqdbm-dev
libjpeg-dev
libpng-dev
libfreetype6-dev
build_script:
- ./buildconf -f
- >-
./configure
--enable-debug
--enable-zts
--enable-option-checking=fatal
--prefix=/usr
--enable-phpdbg
--enable-fpm
--enable-opcache
--disable-opcache-jit
--with-pdo-mysql=mysqlnd
--with-mysqli=mysqlnd
`#--with-pgsql`
`#--with-pdo-pgsql`
`#--with-pdo-sqlite`
--enable-intl
--without-pear
--enable-gd
--with-jpeg
--with-webp
--with-freetype
--with-xpm
--enable-exif
--with-zip
--with-zlib
--with-zlib-dir=/usr
--enable-soap
--enable-xmlreader
--with-xsl
`#--with-tidy`
--enable-sysvsem
--enable-sysvshm
--enable-shmop
--enable-pcntl
--with-readline
--enable-mbstring
--with-curl
--with-gettext
--enable-sockets
--with-bz2
--with-openssl
--with-gmp
--enable-bcmath
--enable-calendar
--enable-ftp
--with-pspell=/usr
`#--with-enchant=/usr`
--with-kerberos
--enable-sysvmsg
--with-ffi
--enable-zend-test
`#--enable-dl-test=shared`
`#--with-ldap`
`#--with-ldap-sasl`
--with-password-argon2
--with-mhash
--with-sodium
--enable-dba
--with-cdb
--enable-flatfile
--enable-inifile
--with-tcadb
--with-lmdb
--with-qdbm
`#--with-snmp`
`#--with-unixODBC`
`#--with-imap`
--with-kerberos
--with-imap-ssl
`#--with-pdo-odbc=unixODBC,/usr`
`#--with-pdo-oci=shared,instantclient,/opt/oracle/instantclient`
`#--with-oci8=shared,instantclient,/opt/oracle/instantclient`
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
`#--with-pdo-firebird`
`#--with-pdo-dblib`
--enable-werror
CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address'
CC=clang
CXX=clang++
- make -j2
- make install
- mkdir -p /etc/php.d
- echo opcache.enable_cli=1 > /etc/php.d/opcache.ini
- echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
# Specify opcache.preload_user as we're running as root.
- echo opcache.preload_user=root >> /etc/php.d/opcache.ini
tests_script:
- export SKIP_IO_CAPTURE_TESTS=1
- export CI_NO_IPV6=1
- export MYSQL_TEST_HOST=mysql
- export MYSQL_TEST_USER=root
- export MYSQL_TEST_PASSWD=root
- export PDO_MYSQL_TEST_DSN="mysql:host=mysql;dbname=test"
- export PDO_MYSQL_TEST_USER=root
- export PDO_MYSQL_TEST_PASS=root
- >-
sapi/cli/php run-tests.php
-P -q -x -j2
-g FAIL,BORK,LEAK,XLEAK
--no-progress
--offline
--show-diff
--show-slow 1000
--set-timeout 120
-d zend_extension=opcache.so
-d opcache.enable_cli=1
--asan

task:
freebsd_task:
name: FREEBSD_DEBUG_NTS
freebsd_instance:
image_family: freebsd-13-0
install_script:
#- sed -i -e 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf
#- pkg upgrade -y
Expand Down
4 changes: 4 additions & 0 deletions Zend/tests/runtime_compile_time_binary_operands.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Test binary operands exposing the same behavior at compile as at run time
--INI--
memory_limit=256M
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
?>
--FILE--
<?php

Expand Down
8 changes: 8 additions & 0 deletions ext/sockets/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ struct _WSAMSG {
#define MAX_USER_BUFF_SIZE ((size_t)(100*1024*1024))
#define DEFAULT_BUFF_SIZE 8192

/* The CMSG_DATA macro does pointer arithmetics on NULL which triggers errors in the Clang UBSAN build */
#ifdef __has_feature
# if __has_feature(undefined_behavior_sanitizer)
# undef CMSG_DATA
# define CMSG_DATA(cmsg) ((unsigned char *) ((uintptr_t) (cmsg) + sizeof(struct cmsghdr)))
# endif
#endif

struct _ser_context {
HashTable params; /* stores pointers; has to be first */
struct err_s err;
Expand Down
10 changes: 9 additions & 1 deletion ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,16 @@

ZEND_DECLARE_MODULE_GLOBALS(sockets)

#define SUN_LEN_NO_UB(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
/* The SUN_LEN macro does pointer arithmetics on NULL which triggers errors in the Clang UBSAN build */
#ifdef __has_feature
# if __has_feature(undefined_behavior_sanitizer)
# undef SUN_LEN
# define SUN_LEN(su) SUN_LEN_NO_UB(su)
# endif
#endif
#ifndef SUN_LEN
#define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
# define SUN_LEN(su) SUN_LEN_NO_UB(su)
#endif

#ifndef PF_INET
Expand Down
4 changes: 4 additions & 0 deletions ext/zlib/tests/inflate_add_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Test incremental inflate_add() functionality
--EXTENSIONS--
zlib
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
?>
--FILE--
<?php
function inflateStream($mode, $flushSize) {
Expand Down