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

Using --enable-fuzzer with --enable-zts cause compilation to fail #14243

Closed
Girgias opened this issue May 15, 2024 · 2 comments · Fixed by #14273
Closed

Using --enable-fuzzer with --enable-zts cause compilation to fail #14243

Girgias opened this issue May 15, 2024 · 2 comments · Fixed by #14273

Comments

@Girgias
Copy link
Member

Girgias commented May 15, 2024

Description

I am not sure if both flags are supported together, if not it should fail at configure and not when compiling as it took me a while to figure out the issue.

A simple reproducible configure command is:

./configure -C CC=clang CFLAGS="-DPROFITABILITY_CHECKS=0 -DZEND_RC_DEBUG=1 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_TRACK_ARENA_ALLOC=1 -ggdb3"  --enable-address-sanitizer --disable-all --enable-debug --enable-zts  --enable-fuzzer

For reference, the compilation error is as follows:

In file included from /home/girgias/dev/php-src/sapi/fuzzer/fuzzer-unserialize.c:22:
In file included from /home/girgias/dev/php-src/main/php_main.h:22:
/home/girgias/dev/php-src/main/php_globals.h:28:8: error: unknown type name 'PHPAPI'
   28 | extern PHPAPI int core_globals_id;
      |        ^
/home/girgias/dev/php-src/main/php_globals.h:29:8: error: unknown type name 'PHPAPI'
   29 | extern PHPAPI size_t core_globals_offset;
      |        ^
/home/girgias/dev/php-src/main/php_globals.h:29:21: error: expected ';' after top level declarator
   29 | extern PHPAPI size_t core_globals_offset;
      |                     ^
      |                     ;
3 errors generated.
make: *** [Makefile:502: sapi/fuzzer/fuzzer-unserialize.lo] Error 1
make: *** Waiting for unfinished jobs....
In file included from /home/girgias/dev/php-src/sapi/fuzzer/fuzzer-unserializehash.c:20:
In file included from /home/girgias/dev/php-src/main/php_main.h:22:
/home/girgias/dev/php-src/main/php_globals.h:28:8: error: unknown type name 'PHPAPI'
   28 | extern PHPAPI int core_globals_id;
      |        ^
/home/girgias/dev/php-src/main/php_globals.h:29:8: error: unknown type name 'PHPAPI'
   29 | extern PHPAPI size_t core_globals_offset;
      |        ^
/home/girgias/dev/php-src/main/php_globals.h:29:21: error: expected ';' after top level declarator
   29 | extern PHPAPI size_t core_globals_offset;
      |                     ^
      |                     ;
3 errors generated.
In file included from /home/girgias/dev/php-src/sapi/fuzzer/fuzzer-json.c:24:
In file included from /home/girgias/dev/php-src/main/php_main.h:22:
/home/girgias/dev/php-src/main/php_globals.h:28:8: error: unknown type name 'PHPAPI'
   28 | extern PHPAPI int core_globals_id;
      |        ^
/home/girgias/dev/php-src/main/php_globals.h:29:8: error: unknown type name 'PHPAPI'
   29 | extern PHPAPI size_t core_globals_offset;
      |        ^
/home/girgias/dev/php-src/main/php_globals.h:29:21: error: expected ';' after top level declarator
   29 | extern PHPAPI size_t core_globals_offset;
      |                     ^
      |                     ;
3 errors generated.
make: *** [Makefile:508: sapi/fuzzer/fuzzer-json.lo] Error 1

PHP Version

master

Operating System

No response

@nielsdos
Copy link
Member

Including php.h instead of php_main.h would fix the build, but then you'd still need to initialize the tsrm before calling sapi_startup.
After doing that it gets as far as into request startup where it crashes on a bogus pointer.
This couldn't have ever worked.

@Girgias
Copy link
Member Author

Girgias commented May 20, 2024

Right, so throwing an error during configure seems the better option. @petk could you possibly have a look at this?

petk added a commit to petk/php-src that referenced this issue May 20, 2024
Thread safety (--enable-zts) is not supported when building fuzzer
(--enable-fuzzer).

Fixes phpGH-14243
petk added a commit that referenced this issue May 20, 2024
Thread safety (--enable-zts) is not supported when building fuzzer
(--enable-fuzzer).

Fixes GH-14243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants