summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2024-12-19Merge tag '1.34.0' into packaging1.34.0-1Konstantin Pavlov95-1534/+6530
Unit 1.34.0 release.
2024-12-19Add 1.34.0 CHANGES1.34.0Andrew Clayton1-0/+10
This is autogenerated from docs/changes.xml by $ make -C docs/ changes && mv build/CHANGES . Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-19docs/changes.xml: Add 1.34.0 changelog entriesAndrew Clayton1-4/+23
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18pkg/docker: Update dockerfiles for 1.34.0Andrew Clayton17-91/+428
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18docs/unit-openapi.yaml: Update version for 1.34.0Andrew Clayton1-1/+1
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18tools/unitctl: Update for version 1.34.0Andrew Clayton6-8/+8
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18.mailmap: Add an entry for IgorAndrew Clayton1-0/+1
You can always see the original names/addresses used by passing --no-mailmap to the various git commands. See gitmailmap(5) Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18Docker: update Rust versionKonstantin Pavlov1-1/+1
2024-12-18Docker: renamed branch to fetch from after successfull hg->git migrationoxpa1-1/+1
(cherry picked from commit 4ca64ff4cd71334c7661e487f7e7953c20e04154) Signed-off-by: Konstantin Pavlov <thresh@nginx.com>
2024-12-18Docker: enable otel and fix build with wasmtime 24+Konstantin Pavlov2-25/+26
2024-12-18Packages: enable otel supportKonstantin Pavlov4-7/+23
2024-12-18contrib: update wasmtime to 27.0.0Konstantin Pavlov2-2/+2
2024-12-18contrib: update njs to 0.8.8Konstantin Pavlov2-2/+2
2024-12-18wasm-wc: Update cratesAndrew Clayton1-417/+564
Run 'cargo update' to get the latest version of the required crates in preparation for the 1.34.0 release. This resolves a dependabot notification regarding 'idna'. Link: <https://github.com/nginx/unit/security/dependabot/13> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18tools/unitctl: Update cratesAndrew Clayton1-588/+767
Run 'cargo update' to get the latest version of the required crates in preparation for the 1.34.0 release. This resolves a dependabot notification regarding 'idna'. Link: <https://github.com/nginx/unit/security/dependabot/14> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18otel: Update cratesAndrew Clayton1-237/+531
Run 'cargo update' to get the latest version of the required crates in preparation for the 1.34.0 release. The rustls update fixes a panic in `rustls::server::Acceptor::accept()`, but Unit does not use this code path and was not affected. Link: <https://rustsec.org/advisories/RUSTSEC-2024-0399.html> Link: <https://github.com/nginx/unit/security/dependabot/11> Closes: <https://github.com/nginx/unit/issues/1503> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-18wasm-wc: Update to wasmtime 27.0.0Andrew Clayton2-76/+76
For no real reason other than to be on the latest release for the next release of Unit... Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-13auto/otel: Remove pkg-config checkAndrew Clayton1-3/+1
@thresheek reported an issue trying to configure OTEL support on Amazon Linux 2 checking for OTEL requirements: - checking for rust compiler ... found - checking for cargo ... found - checking for OpenSSL library ... found Package openssl was not found in the pkg-config search path. Perhaps you should add the directory containing `openssl.pc' to the PKG_CONFIG_PATH environment variable No package 'openssl' found We successfully built the test program with '-lssl -lcrypto', but then tried to use 'pkg-config openssl --cflags --libs' to override NXT_OTEL_LIBS. On Amazon Linux2 there is no openssl.pc, they have a openssl11.pc. Let's just remove the pkg-config check, if we get here, we have successfully built with '-lssl -lcrypto', so just go with that (it also matches what we do in auto/ssltls). Reported-by: Konstantin Pavlov <thresh@nginx.com> Closes: https://github.com/nginx/unit/issues/1510 Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-12Packages: add Fedora 41 supportKonstantin Pavlov7-7/+173
While at it, removed support for Fedora 39 as it's EOL.
2024-12-12Packages: support rpm 4.20+Konstantin Pavlov1-10/+16
In 4.20, rpm changed the way build roots are named. Our packaging relies on the symlinks being created as a part of a rule to make sure targets are being built correctly. This patch implements (a hacky) way to check what the build root should be named on a currently running rpm version and adjusts the symlinks accordingly.
2024-12-12Docker: update Python and PHP versionsKonstantin Pavlov4-8/+8
2024-12-10otel: Disable static_mut_refs warning for nxt_otel_rs_span_tx()Andrew Clayton1-0/+1
When compiling OTEL support with rustc 1.83.0 we started getting the following warning Compiling otel v0.1.0 (/home/andrew/src/unit/src/otel) warning: creating a mutable reference to mutable static is discouraged --> src/lib.rs:42:9 | 42 | SPAN_TX.take(); | ^^^^^^^^^^^^^^ mutable reference to mutable static | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives = note: `#[warn(static_mut_refs)]` on by default warning: `otel` (lib) generated 1 warning Finished `release` profile [optimized] target(s) in 1m 07s However it *seems* our usage is OK, so we can disable this warning (which it seems will soon turn into a hard error), fortunately we only need to disable it for the nxt_otel_rs_span_tx() function. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-09java: update third-party components to their recent versionsSergey A. Osokin3-13/+13
2024-12-05ci: Build with --otel on dev distrosAndrew Clayton1-6/+8
This just builds the OTEL stuff for the Fedora Rawhide and Alpine Edge distributions. If we ever get test cases covering OTEL we can figure out the best way to do it in the ci.yaml, but right now I don't see the point in building OTEL in every test configuration there... Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-12-05tools/unitctl: bump anstream from 0.6.5 to 0.6.15dependabot[bot]1-2/+9
Bumps [anstream](https://github.com/rust-cli/anstyle) from 0.6.5 to 0.6.15. - [Commits](https://github.com/rust-cli/anstyle/compare/anstream-v0.6.5...anstream-v0.6.15) --- updated-dependencies: - dependency-name: anstream dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-11-26wasm: Fix build with wasmtime 27.0.0Sergey A. Osokin1-0/+6
Wasmtime 27.0.0 adjusted the C API to start flowing through the directory and file permission bits of the underlying rust wasi_config_preopen_dir() implementation. The directory permissions control whether a directory is read-only or whether you can create/modify files within. You always need at least WASMTIME_WASI_DIR_PERMS_READ. The file permissions control whether you can read or read/write files. WASMTIME_WASI_FILE_PERMS_WRITE seems to imply WASMTIME_WASI_FILE_PERMS_READ (but we add both just to make it clear what we want) [ Permissions tweak and commit message - Andrew ] Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-11-19Decast nxt_cpymem()Andrew Clayton1-1/+1
nxt_cpymem() is basically mempcpy(3) Like mempcpy() nxt_cpymem() returns a void *. nxt_cpymem() is implemented as a wrapper around memcpy(3), however before returning the new pointer value we cast the return of memcpy(3) to a u_char *, then add the length parameter to it. I guess this was done to support compilers that do not support arithmetic on void pointers as the C standard forbids it. However since we removed support for compilers other than GCC and Clang (ending in commit 9cd11133 ("Remove support for Sun's Sun Studio/SunPro C compiler")) this is no longer an issue as both GCC and Clang support arithmetic on void pointers (without the -pedantic option) by treating the size of a void as 1. While removing the unnecessary casting in this case doesn't necessarily improve type-safety (as we're dealing with void *'s in and out), it does just make the code that little more readable. Oh and for interest we have actually already been relying on this extension src/nxt_array.c:143:40: warning: arithmetic on a pointer to void is a GNU extension [-Wgnu-pointer-arith] 143 | nxt_memcpy(data, src->elts + (i * size), size); | ~~~~~~~~~ ^ src/nxt_string.h:45:24: note: expanded from macro 'nxt_memcpy' 45 | (void) memcpy(dst, src, length) | ^~~ which was introduced in e2b53e16 ("Added "rootfs" feature.") back in 2020. Link: <https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html> Link: <https://clang.llvm.org/docs/LanguageExtensions.html#introduction> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-11-14tests: Add tests for JSON format access logZhidao HONG1-0/+24
2024-11-14http: Support JSON format in access logZhidao HONG2-16/+229
Allow format to be an object to generate JSON logs. The object keys become JSON field names, and values support string, variable, and JS. Note that when there is no JS in the format values, the object will be pre-serialized to a JSON template string at configuration phase for better performance. Example config: { "access_log": { "path": "/tmp/access.log", "format": { "remote_addr": "$remote_addr", "time_local": "$time_local", "request_line": "$request_line", "status": "$status", "body_bytes_sent": "$body_bytes_sent", "header_referer": "$header_referer", "header_user_agent": "$header_user_agent" } } }
2024-11-14http: Introduce nxt_router_access_log_format_t structureZhidao HONG2-37/+68
This is a preparatory refactoring for upcoming JSON format support in access log. We will extend format option to access object for JSON support. No functional changes.
2024-11-14http: Refactor format field in nxt_router_access_log_conf_tZhidao HONG1-12/+15
This is a preparatory refactoring for upcoming JSON format support in access log. No functional changes.
2024-11-14Make nxt_tstr_is_js() macro public in headerZhidao HONG2-4/+4
This is a preparatory refactoring for upcoming JSON format support in access log. No functional changes.
2024-11-12docs/openapi: update OpenAPI referencesAva Hahn2-0/+112
These changes are generated by the openapi generator through a make command. Signed-off-by: Ava Hahn <a.hahn@f5.com> Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
2024-11-12.editorconfig: fix bracket balance of editorconfig fileGabor Javorszky1-1/+1
Tiny bracket balance fix. Signed-off-by: Ava Hahn <a.hahn@f5.com> Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
2024-11-12otel: configuration items and their validationAva Hahn2-0/+151
Adds code responsible for users to apply the `telemetry` configuration options. configuration snippet as follows: { "settings": { "telemetry": { "batch_size": 20, "endpoint": "http://lgtm:4318/v1/traces", "protocol": "http", "sampling_ratio": 1 } }, "listeners": { "*:80": { "pass": "routes" } }, "routes": [ { "match": { "headers": { "accept": "*text/html*" } }, "action": { "share": "/usr/share/unit/welcome/welcome.html" } }, { "action": { "share": "/usr/share/unit/welcome/welcome.md" } } ] } Signed-off-by: Ava Hahn <a.hahn@f5.com> Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
2024-11-12otel: add header parsing and test call stateAva Hahn3-0/+20
Enables Unit to parse the tracestate and traceparent headers and add it to the list, as well as calls to nxt_otel_test_and_call_state. Signed-off-by: Ava Hahn <a.hahn@f5.com> Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
2024-11-12otel: add build tooling to include otel codeAva Hahn12-11/+621
Adds the --otel flag to the configure command and the various build time variables and checks that are needed in this flow. It also includes the nxt_otel.c and nxt_otel.h files that are needed for the rest of Unit to talk to the compiled static library that's generated from the rust crate. Signed-off-by: Ava Hahn <a.hahn@f5.com> Co-authored-by: Gabor Javorszky <g.javorszky@f5.com> Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
2024-11-12otel: add opentelemetry rust crate codeAva Hahn4-0/+2512
This is purely the source code of the rust end of opentelemetry. It does not have build tooling wired up yet, nor is this used from the C code. Signed-off-by: Ava Hahn <a.hahn@f5.com> Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
2024-11-12java: Update third-party components to their recent versionsSergey A. Osokin3-13/+13
[ Tweaked subject - Andrew ] Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-11-07wasm-wc: Update to wasmtime v26.0.1Andrew Clayton2-181/+177
This fixes an issue we had with wasm-wasi-component failing to load components with 2024/11/06 21:08:50 [alert] 107196#107196 failed to create initial state Caused by: 0: failed to compile component 1: WebAssembly translation error 2: Invalid input WebAssembly code at offset 15936: zero byte expected Which was a symptom of <https://github.com/bytecodealliance/wasmtime/issues/9130> Closes: https://github.com/nginx/unit/issues/1477 Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-11-05auto: Remove unused pthread spinlock checksAndrew Clayton1-50/+0
When configuring under Linux we always got the following checking for pthread spinlock zero initial value ... found but is not working Having *actually* taken a look at this, this check seems somewhat bogus, the first thing it does is pthread_spinlock_t lock = 0; which you shouldn't do anyway, you should use pthread_spin_init(3) to initialise the pthread_spinlock_t variable. But in any case, this thing, NXT_HAVE_PTHREAD_SPINLOCK_ZERO, isn't even checked for in the code. Neither is NXT_HAVE_PTHREAD_SPINLOCK, we don't use the pthread_spin_* API, but rather roll our own spinlock implementation. So let's just remove these checks, at the very least it'll speed ./configure up! Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-29ci: Add a clang-ast workflowAndrew Clayton1-0/+76
This does compile-time type and argument checking using a clang-plugin. It was run as part of buildbot. This covers unitd, src/test and the php, perl, python, ruby, wasm, java and nodejs language modules/support. It doesn't cover Go as that doesn't build anything with clang (uses cgo) or wasm-wasi-component as that uses rustc. Link: <https://github.com/nginx/clang-ast/tree/unit> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-29src/test: Fix missing parameter to nxt_log_alert() in nxt_base64_test()Andrew Clayton1-1/+2
nxt_log_alert() was missing the nxt_str_t parameter as required by the %V format specifier. This was found with the Unit clang-ast plugin. Fixes: 7bf625394 ("Custom implementation of Base64 decoding function.") Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-29Use nxt_nitems() instead of sizeof() for strings (arrays)Alejandro Colomar1-1/+1
sizeof() should never be used to get the size of an array. It is very unsafe, since arrays easily decay to pointers, and sizeof() applied to a pointer gives false results that compile and produce silent bugs. It's better to use nxt_items(), which implements sizeof() division, which recent compilers warn when used with pointers. This change would have caught a couple of bugs that were *almost* introduced First up is the _infamous_ ternary macro bug (yes, using the ternary operator in a macro is of itself a bad idea) nxt_str_set(&port, (r->tls ? "https://" : "http://")); which in the macro expansion runs: (&port)->length = nxt_length((r->tls ? : "https://" : "http://")); which evaluates to: port.length = sizeof(r->tls ? "https://" : "http://") - 1; which evaluates to: port.length = 8 - 1; Of course, we didn't want a compile-time-constant 8 there, but rather the length of the string. The above bug is not obvious to the untrained eye, so let's show some example programs that may give some more hints about the problem. $ cat sizeof.c #include <stdio.h> int main(void) { printf("%zu\n", sizeof("01")); printf("%zu\n", sizeof("012")); printf("%zu\n", sizeof(char *)); } $ cc -Wall -Wextra sizeof.c $ ./a.out 3 4 8 sizeof() returns the size in bytes of the array passed to it, which in case of char strings, it is equivalent to the length of the string + 1 (for the terminating '\0'). However, arrays decay very easily in C, and they decay to a pointer to the first element in the array. In case of strings, that is a 'char *'. When sizeof() is given a pointer, it returns the size of the pointer, which in most platforms is 8. The ternary operator (?) performs default promotions (and other nefarious stuff) that may surprise even the most experienced programmers. It contrasts the __builtin_choose_expr() GCC builtin [1], which performs almost equivalently, but without the unwanted effects of the ternary operator. [1]: <https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fchoose_005fexpr> $ cat ?.c #include <stdio.h> int main(void) { printf("%zu\n", sizeof("01")); printf("%zu\n", sizeof(__builtin_choose_expr(1, "01", "01"))); printf("%zu\n", sizeof(1 ? "01" : "01")); printf("%zu\n", sizeof(char *)); } $ cc -Wall -Wextra ?.c $ ./a.out 3 3 8 8 In the above program, we can see how the ternary operator (?) decays the array into a pointer, and makes it so that sizeof() will return a constant 8. As we can see, everything in the use of the macro would make it look like it should work, but the combination of some seemingly-safe side effects of various C features produces a completely unexpected bug. Second up is a more straight forward case of simply calling nxt_length() on a char * pointer. Like the above this will generally result in a length of 7. When you sit and think about it, you know very well sizeof(char *) is probably 8 these days (but may be some other value like 4). But when you're in the depths of code it's very easy to overlook this when all you're thinking about is to get the length of some string. Let's look at this patch in action $ cat sdiv.c #include <stdio.h> #define nxt_nitems(x) (sizeof(x) / sizeof((x)[0])) #define nxt_length(s) (nxt_nitems(s) - 1) #define nxt_unsafe_length(s) (sizeof(s) - 1) #define STR_LITERAL "1234567890" static const char *str_lit = "1234567890"; int main(void) { printf("[STR_LITERAL] nxt_unsafe_length(\"1234567890\") [%lu]\n", nxt_unsafe_length(STR_LITERAL)); printf("[STR_LITERAL] nxt_length(\"1234567890\") [%lu]\n", nxt_length(STR_LITERAL)); printf("[char * ] nxt_unsafe_length(\"1234567890\") [%lu]\n", nxt_unsafe_length(str_lit)); printf("[char * ] nxt_length(\"1234567890\") [%lu]\n", nxt_length(str_lit)); return 0; } First lets compile it without any flags $ make sdiv $ ./sdiv [STR_LITERAL] nxt_unsafe_length("1234567890") [10] [STR_LITERAL] nxt_length("1234567890") [10] [char * ] nxt_unsafe_length("1234567890") [7] [char * ] nxt_length("1234567890") [7] It compiled without error and runs, although with incorrect results for the two char *'s. Now lets build it with -Wsizeof-pointer-div (also enabled with -Wall) $ CFLAGS="-Wsizeof-pointer-div" make sdiv cc -Wsizeof-pointer-div nxt_nitems.c -o nxt_nitems sdiv.c: In function ‘main’: sdiv.c:3:44: warning: division ‘sizeof (const char *) / sizeof (char)’ does not compute the number of array elements [-Wsizeof-pointer-div] 3 | #define nxt_nitems(x) (sizeof(x) / sizeof((x)[0])) | ^ nxt_nitems.c:4:34: note: in expansion of macro ‘nxt_nitems’ 4 | #define nxt_length(s) (nxt_nitems(s) - 1) | ^~~~~~~~~~ nxt_nitems.c:22:16: note: in expansion of macro ‘nxt_length’ 22 | nxt_length(str_lit)); | ^~~~~~~~~~ nxt_nitems.c:10:20: note: first ‘sizeof’ operand was declared here 10 | static const char *str_lit = "1234567890"; | ^~~~~~~ So we now get a very loud compiler warning (coming from nxt_length(char *), nxt_unsafe_length() of course didn't trigger any warnings), telling us we're being daft. The good news is this didn't find any existing bugs! Let's keep it that way... Link: <https://stackoverflow.com/a/57537491> Cc: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Tested-by: Andrew Clayton <a.clayton@nginx.com> [ Tweaked and expanded the commit message - Andrew ] Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-24Some more variable constificationAndrew Clayton3-16/+16
Mostly more 'static nxt_str_t ...'s Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-22Fix missing newlines in access logs for JS configurationZhidao HONG1-13/+2
When using JS configuration for the "format" option, access log entries were being written without newline characters. This commit adds the missing newline character to each log entry. Closes: https://github.com/nginx/unit/issues/1458
2024-10-22Add flag for newline control in access log entriesZhidao HONG4-8/+24
This commit introduces a new flag to control the addition of newline characters in access log entries. This is prepared for fixing the issue where log entries lack newlines when using JS configuration.
2024-10-17perl: Remove unused module constructorAndrew Clayton1-3/+0
In the perl language module we create a new perl *module* on the fly comprised of some preamble, the specified perl script and some post-amble. In the preamble we create a constructor called new(), however this can clash with other constructors also called new. While this can be worked around by instead of doing ... new CLASS rather do ... CLASS->new() While this constructor was added in commit 3b2c1d0e ("Perl: added implementation delayed response and streaming body."), I don't see that we actually use it anywhere (nor is it seemingly something we document) and if we simply remove it then things still seem to work, including the Perl pytests ... test/test_perl_application.py::test_perl_streaming_body_multiple_responses[5.38.2] PASSED ... test/test_perl_application.py::test_perl_delayed_response[5.38.2] PASSED test/test_perl_application.py::test_perl_streaming_body[5.38.2] PASSED ... Closes: https://github.com/nginx/unit/issues/1456 Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-17ci: Drop PHP 8.1 from our testsAndrew Clayton1-2/+0
Under Ubuntu 24.04 the pytest for test/test_php_isolation.py::test_php_isolation_rootfs fails due to Unit aborting (SIGABRT) in the PHP language module due to FORIFY_SOURCE hardening detecting a buffer overflow 2024/10/16 16:46:54 [info] 11661#11661 "phpinfo" application started *** buffer overflow detected ***: terminated 2024/10/16 16:46:54 [alert] 11660#11660 app process 11661 exited on signal 6 After spending an extraordinary amount of time faffing around with Ubuntu and pytests (they don't make for a pleasant combination) I was able to reproduce it. The crash was occurring here #4 0x00007ebe818288ff in __GI_abort () at ./stdlib/abort.c:79 #5 0x00007ebe818297b6 in __libc_message_impl ( fmt=fmt@entry=0x7ebe819ce765 "*** %s ***: terminated\n") at ../sysdeps/posix/libc_fatal.c:132 #6 0x00007ebe81936c19 in __GI___fortify_fail ( msg=msg@entry=0x7ebe819ce74c "buffer overflow detected") at ./debug/fortify_fail.c:24 #7 0x00007ebe819365d4 in __GI___chk_fail () at ./debug/chk_fail.c:28 #8 0x00007ebe8134a055 in mempcpy (__len=10, __src=0x7ebe8160ade8, __dest=0x571ba9bd0930) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:45 #9 fake_data_segment (info=0x0, sysdb=0x571ba9bcf080) at /usr/src/php8.1-8.1.30-1+ubuntu24.04.1+deb.sury.org+1/ext/date/lib/parse_tz.c:921 #10 timelib_builtin_db () at /usr/src/php8.1-8.1.30-1+ubuntu24.04.1+deb.sury.org+1/ext/date/lib/parse_tz.c:1084 #11 0x00007ebe812e0885 in zm_info_date (zend_module=0x571ba9a14420) [Well as best as I can tell, as this is from the php 8.1 packages from <https://github.com/oerdnj/deb.sury.org>, I don't know where the packages (I'm assuming it's packages) shivammathur/setup-php@v2 installs come from.] So we get killed in fake_data_segment(), the thing is, that function (as well as timelib_builtin_db()) doesn't exist in upstream PHP. It turns out these come from a patch that is applied by distributions to make PHP use the system installed timezone database rather than the one built into PHP. I was unable to reproduce this with vanilla PHP 8.1. It can be triggered on affected builds with the following config { "listeners": { "[::1]:8080": { "pass": "applications/php" } }, "applications": { "php": { "type": "php", "root": "/app/php", "isolation": { "rootfs": "/tmp/unit-root", "namespaces": { "mount": true, "credential": true, "pid": true } } } } } The crux of the issue seems to come down to in this case PHP can't open the tz database as it's not contained in the new mount namespace. 190437 openat(AT_FDCWD, "/usr/share/zoneinfo/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory) 190437 openat(AT_FDCWD, "/usr/share/zoneinfo/zone.tab", O_RDONLY) = -1 ENOENT (No such file or directory) 190437 writev(2, [{iov_base="*** ", iov_len=4}, {iov_base="buffer overflow detected", iov_len=24}, {iov_base=" ***: terminated\n", iov_len=17}], 3) = 45 ... 190437 --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=2, si_uid=65534} --- 190437 +++ killed by SIGABRT +++ Specifically the issue is with the following code in the patch (certainly an earlier version of the patch, this is from a Debian patch <https://sources.debian.org/src/php8.2/8.2.20-1~deb12u1/debian/patches/0007-Add-support-for-use-of-the-system-timezone-database.patch/>) + data = malloc(3 * sysdb->index_size + 7); + + p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1); If the zone file hasn't been found then sysdb->index_size is 0. So we malloc(3) a total of 7 bytes. However, sizeof(FAKE_HEADER) - 1 is 10. (Hence the __len=10 in the mempcpy(3) in the above backtrace). Of course 10 doesn't fit into 7 and the FORTIFY_SOURCE hardening kicks in and SIGABRTs the process. Now, it's worth noting that this issue doesn't occur with PHP 8.2 and 8.3. As can been seen from the Fedora patch for this <https://src.fedoraproject.org/rpms/php/blob/rawhide/f/php-8.4.0-systzdata-v24.patch> They actually have a fix incorporated r23: fix possible buffer overflow So the above patch now does + data = malloc(3 * sysdb->index_size + sizeof(FAKE_HEADER) - 1); + + p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1); So you will always get at least the required 10 bytes allocated. I assume the PHP 8.2 & 8.3 packages either no longer use this patch or have the fixed version. I don't know... I haven't found the sources... Anyway the above was more about satisfying myself that the problem wasn't with Unit. PHP 8.1 is now in security maintenance mode and people are actively encouraged to upgrade to 8.2/8.3 So lets just remove 8.1 from our testing... [It's also worth noting that after all this, the ubuntu-latest runners seemed to have switched back from 24.04 to 22.04. However lets stick with this and the other ci fixes as who knows when it'll go back to 24.04 (or some other version) again...] Link: <https://www.php.net/supported-versions.php> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-10-17ci: Install pytest via apt(8)Andrew Clayton1-7/+4
With Ubuntu 24.04 installing it via pip gave this error error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.12/README.venv for more information. Installing it via the package manager is the better option anyway... Under Ubuntu 22.04 it only installs a /usr/bin/pytest-3 binary, rather than installing a /usr/bin/pytest binary and symlink for pytest-3, so use pytest-3 as the command. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>