Skip to content

Commit 743d378

Browse files
committed
Add clang ASAN/UBSAN push job
Closes GH-9507
1 parent ed202b2 commit 743d378

File tree

6 files changed

+209
-6
lines changed

6 files changed

+209
-6
lines changed

.cirrus.yml

Lines changed: 180 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,188 @@
11
env:
22
CIRRUS_CLONE_DEPTH: 1
3-
ARCH: amd64
43

5-
freebsd_instance:
6-
image_family: freebsd-13-0
4+
asan_task:
5+
name: ASAN_DEBUG_NTS
6+
container:
7+
image: gcc:latest
8+
additional_containers:
9+
- name: mysql
10+
image: mysql:latest
11+
port: 3306
12+
env:
13+
MYSQL_ROOT_PASSWORD: "root"
14+
MYSQL_DATABASE: "test"
15+
install_script:
16+
- apt-get update -y
17+
- >-
18+
apt-get install -y
19+
bison
20+
re2c
21+
locales
22+
locales-all
23+
`#ldap-utils`
24+
openssl
25+
`slapd`
26+
libgmp-dev
27+
libicu-dev
28+
`#libtidy-dev`
29+
`#libenchant-dev`
30+
libaspell-dev
31+
libpspell-dev
32+
libsasl2-dev
33+
libxpm-dev
34+
libzip-dev
35+
`#libsqlite3-dev`
36+
libwebp-dev
37+
libonig-dev
38+
libkrb5-dev
39+
libgssapi-krb5-2
40+
libcurl4-openssl-dev
41+
libxml2-dev
42+
libxslt1-dev
43+
libpq-dev
44+
libreadline-dev
45+
`#libldap2-dev`
46+
libsodium-dev
47+
libargon2-0-dev
48+
libmm-dev
49+
`#libsnmp-dev`
50+
`#postgresql`
51+
`#postgresql-contrib`
52+
`#snmpd`
53+
`#snmp-mibs-downloader`
54+
`#freetds-dev`
55+
`#unixodbc-dev`
56+
llvm
57+
clang
58+
libc-client-dev
59+
dovecot-core
60+
dovecot-pop3d
61+
dovecot-imapd
62+
`#sendmail`
63+
`#firebird-dev`
64+
liblmdb-dev
65+
libtokyocabinet-dev
66+
libdb-dev
67+
libqdbm-dev
68+
libjpeg-dev
69+
libpng-dev
70+
libfreetype6-dev
71+
build_script:
72+
- ./buildconf -f
73+
- >-
74+
./configure
75+
--enable-debug
76+
--enable-zts
77+
--enable-option-checking=fatal
78+
--prefix=/usr
79+
--enable-phpdbg
80+
--enable-fpm
81+
--enable-opcache
82+
--disable-opcache-jit
83+
--with-pdo-mysql=mysqlnd
84+
--with-mysqli=mysqlnd
85+
`#--with-pgsql`
86+
`#--with-pdo-pgsql`
87+
`#--with-pdo-sqlite`
88+
--enable-intl
89+
--without-pear
90+
--enable-gd
91+
--with-jpeg
92+
--with-webp
93+
--with-freetype
94+
--with-xpm
95+
--enable-exif
96+
--with-zip
97+
--with-zlib
98+
--with-zlib-dir=/usr
99+
--enable-soap
100+
--enable-xmlreader
101+
--with-xsl
102+
`#--with-tidy`
103+
--enable-sysvsem
104+
--enable-sysvshm
105+
--enable-shmop
106+
--enable-pcntl
107+
--with-readline
108+
--enable-mbstring
109+
--with-curl
110+
--with-gettext
111+
--enable-sockets
112+
--with-bz2
113+
--with-openssl
114+
--with-gmp
115+
--enable-bcmath
116+
--enable-calendar
117+
--enable-ftp
118+
--with-pspell=/usr
119+
`#--with-enchant=/usr`
120+
--with-kerberos
121+
--enable-sysvmsg
122+
--with-ffi
123+
--enable-zend-test
124+
`#--enable-dl-test=shared`
125+
`#--with-ldap`
126+
`#--with-ldap-sasl`
127+
--with-password-argon2
128+
--with-mhash
129+
--with-sodium
130+
--enable-dba
131+
--with-cdb
132+
--enable-flatfile
133+
--enable-inifile
134+
--with-tcadb
135+
--with-lmdb
136+
--with-qdbm
137+
`#--with-snmp`
138+
`#--with-unixODBC`
139+
`#--with-imap`
140+
--with-kerberos
141+
--with-imap-ssl
142+
`#--with-pdo-odbc=unixODBC,/usr`
143+
`#--with-pdo-oci=shared,instantclient,/opt/oracle/instantclient`
144+
`#--with-oci8=shared,instantclient,/opt/oracle/instantclient`
145+
--with-config-file-path=/etc
146+
--with-config-file-scan-dir=/etc/php.d
147+
`#--with-pdo-firebird`
148+
`#--with-pdo-dblib`
149+
--enable-werror
150+
CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address'
151+
CC=clang
152+
CXX=clang++
153+
- make -j2
154+
- make install
155+
- mkdir -p /etc/php.d
156+
- echo opcache.enable_cli=1 > /etc/php.d/opcache.ini
157+
- echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
158+
# Specify opcache.preload_user as we're running as root.
159+
- echo opcache.preload_user=root >> /etc/php.d/opcache.ini
160+
tests_script:
161+
- export SKIP_IO_CAPTURE_TESTS=1
162+
- export CI_NO_IPV6=1
163+
- export MYSQL_TEST_HOST=mysql
164+
- export MYSQL_TEST_USER=root
165+
- export MYSQL_TEST_PASSWD=root
166+
- export PDO_MYSQL_TEST_DSN="mysql:host=mysql;dbname=test"
167+
- export PDO_MYSQL_TEST_USER=root
168+
- export PDO_MYSQL_TEST_PASS=root
169+
- >-
170+
sapi/cli/php run-tests.php
171+
-P -q -x -j2
172+
-g FAIL,BORK,LEAK,XLEAK
173+
--no-progress
174+
--offline
175+
--show-diff
176+
--show-slow 1000
177+
--set-timeout 120
178+
-d zend_extension=opcache.so
179+
-d opcache.enable_cli=1
180+
--asan
7181
8-
task:
182+
freebsd_task:
9183
name: FREEBSD_DEBUG_NTS
184+
freebsd_instance:
185+
image_family: freebsd-13-0
10186
install_script:
11187
#- sed -i -e 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf
12188
#- pkg upgrade -y

Zend/tests/runtime_compile_time_binary_operands.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Test binary operands exposing the same behavior at compile as at run time
33
--INI--
44
memory_limit=256M
5+
--SKIPIF--
6+
<?php
7+
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
8+
?>
59
--FILE--
610
<?php
711

ext/date/tests/gh-124.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ Test for timelib #124: Problem with large negative timestamps
33
--INI--
44
date.timezone=UTC
55
--SKIPIF--
6-
<?php if (PHP_INT_SIZE != 8) echo "skip this test is for 64-bit only"; ?>
6+
<?php
7+
if (PHP_INT_SIZE != 8) echo "skip this test is for 64-bit only";
8+
if (getenv('SKIP_ASAN')) die('skip triggers undefined behavior');
9+
?>
710
--FILE--
811
<?php
912
var_dump((new DateTime("@-9223372036854775808"))->getTimestamp());

ext/sockets/conversions.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ struct _WSAMSG {
6060
#define MAX_USER_BUFF_SIZE ((size_t)(100*1024*1024))
6161
#define DEFAULT_BUFF_SIZE 8192
6262

63+
/* The CMSG_DATA macro does pointer arithmetics on NULL which triggers errors in the Clang UBSAN build */
64+
#ifdef __has_feature
65+
# if __has_feature(undefined_behavior_sanitizer)
66+
# undef CMSG_DATA
67+
# define CMSG_DATA(cmsg) ((unsigned char *) ((uintptr_t) (cmsg) + sizeof(struct cmsghdr)))
68+
# endif
69+
#endif
70+
6371
struct _ser_context {
6472
HashTable params; /* stores pointers; has to be first */
6573
struct err_s err;

ext/sockets/sockets.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,16 @@
7676

7777
ZEND_DECLARE_MODULE_GLOBALS(sockets)
7878

79+
#define SUN_LEN_NO_UB(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
80+
/* The SUN_LEN macro does pointer arithmetics on NULL which triggers errors in the Clang UBSAN build */
81+
#ifdef __has_feature
82+
# if __has_feature(undefined_behavior_sanitizer)
83+
# undef SUN_LEN
84+
# define SUN_LEN(su) SUN_LEN_NO_UB(su)
85+
# endif
86+
#endif
7987
#ifndef SUN_LEN
80-
#define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
88+
# define SUN_LEN(su) SUN_LEN_NO_UB(su)
8189
#endif
8290

8391
#ifndef PF_INET

ext/zlib/tests/inflate_add_basic.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Test incremental inflate_add() functionality
33
--EXTENSIONS--
44
zlib
5+
--SKIPIF--
6+
<?php
7+
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
8+
?>
59
--FILE--
610
<?php
711
function inflateStream($mode, $flushSize) {

0 commit comments

Comments
 (0)