[php-src] Issue #20002: Building with --enable-memory-sanitizer on FreeBSD errors with duplicate strlcpy and strlcat
| From: | outtersg | Date: | Tue, 30 Sep 2025 08:26:18 +0000 |
| Subject: | [php-src] Issue #20002: Building with --enable-memory-sanitizer on FreeBSD errors with duplicate strlcpy and strlcat | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250947@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20002
Author: outtersg
### Description
```sh
./configure --with-pdo-pgsql=$HOME/local --enable-memory-sanitizer
make -j8
```
```
ld: error: duplicate symbol: strlcpy
>>> defined at msan_interceptors.cpp
>>> msan_interceptors.o:(strlcpy) in archive
>>> /usr/lib/clang/19/lib/freebsd/libclang_rt.msan-x86_64.a
>>> defined at zend_string.c:507 (Zend/zend_string.c:507)
>>> Zend/zend_string.o:(.text+0x5500)
```
And in fact the stock FreeBSD 14.3 clang, as well as my home-compiled ones, define the symbols,
contrary to [what is suggested in a
comment](https://github.com/php/php-src/blob/master/Zend/zend_string.c#L503):
```c
/* strlcpy and strlcat are not intercepted by msan, so we need to do it ourselves. */
#if __has_feature(memory_sanitizer)
/* here strlcat and strlcpy are redefined with some msan */
#endif
```
while, as seen with
nm -o:
```
/usr/lib/clang/19/lib/freebsd/libclang_rt.msan-x86_64.a:msan_interceptors.o:000000000000073f T
strlcpy
/home/gui/local/clang+libcxx+omp+rt-20.1.4/lib/clang/20/lib/freebsd/libclang_rt.msan-x86_64.a:msan_interceptors.cpp.o:000000000000073f
T strlcpy
```
**The #if should probably be more subtle**, from [the commit
comment](https://github.com/php/php-src/commit/99504aa148b80a54319713f632c65d6771e38c02) it applied
to Clang 17 but I can't say to what compiler and versions it should be limited: should it be
detected in the configure?
### PHP Version
```plain
master 2025-09-30
```
### Operating System
_No response_