The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code: DatasetGenerationCastError
Exception: DatasetGenerationCastError
Message: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 2 new columns ({'docker_image', 'swe_type'})
This happened while the json dataset builder was generating data using
hf://datasets/ernie-research/MEnvData-SWE/swe-images.jsonl (at revision 2f2c5efe0ddcfbf54f3c35740e154949ac7a5802), [/tmp/hf-datasets-cache/medium/datasets/78380009121373-config-parquet-and-info-ernie-research-MEnvData-S-cd349d9b/hub/datasets--ernie-research--MEnvData-SWE/snapshots/2f2c5efe0ddcfbf54f3c35740e154949ac7a5802/swe-images.jsonl (origin=hf://datasets/ernie-research/MEnvData-SWE@2f2c5efe0ddcfbf54f3c35740e154949ac7a5802/swe-images.jsonl)]
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback: Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1887, in _prepare_split_single
writer.write_table(table)
File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 674, in write_table
pa_table = table_cast(pa_table, self._schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2272, in table_cast
return cast_table_to_schema(table, schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2218, in cast_table_to_schema
raise CastError(
datasets.table.CastError: Couldn't cast
repo: string
pull_number: int64
instance_id: string
issue_numbers: list<item: int64>
child 0, item: int64
base_commit: string
patch: string
test_patch: string
problem_statement: string
hints_text: string
all_hints_text: string
commit_urls: list<item: string>
child 0, item: string
created_at: timestamp[s]
version: string
language: string
env_setup_script: string
original_env_setup_script: string
eval_script: string
image_name: string
swe_type: string
docker_image: string
to
{'repo': Value('string'), 'pull_number': Value('int64'), 'instance_id': Value('string'), 'issue_numbers': List(Value('int64')), 'base_commit': Value('string'), 'patch': Value('string'), 'test_patch': Value('string'), 'problem_statement': Value('string'), 'hints_text': Value('string'), 'all_hints_text': Value('string'), 'commit_urls': List(Value('string')), 'created_at': Value('timestamp[s]'), 'version': Value('string'), 'language': Value('string'), 'env_setup_script': Value('string'), 'original_env_setup_script': Value('string'), 'eval_script': Value('string'), 'image_name': Value('string')}
because column names don't match
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1347, in compute_config_parquet_and_info_response
parquet_operations = convert_to_parquet(builder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 980, in convert_to_parquet
builder.download_and_prepare(
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 884, in download_and_prepare
self._download_and_prepare(
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 947, in _download_and_prepare
self._prepare_split(split_generator, **prepare_split_kwargs)
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1736, in _prepare_split
for job_id, done, content in self._prepare_split_single(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1889, in _prepare_split_single
raise DatasetGenerationCastError.from_cast_error(
datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 2 new columns ({'docker_image', 'swe_type'})
This happened while the json dataset builder was generating data using
hf://datasets/ernie-research/MEnvData-SWE/swe-images.jsonl (at revision 2f2c5efe0ddcfbf54f3c35740e154949ac7a5802), [/tmp/hf-datasets-cache/medium/datasets/78380009121373-config-parquet-and-info-ernie-research-MEnvData-S-cd349d9b/hub/datasets--ernie-research--MEnvData-SWE/snapshots/2f2c5efe0ddcfbf54f3c35740e154949ac7a5802/swe-images.jsonl (origin=hf://datasets/ernie-research/MEnvData-SWE@2f2c5efe0ddcfbf54f3c35740e154949ac7a5802/swe-images.jsonl)]
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
repo
string | pull_number
int64 | instance_id
string | issue_numbers
list | base_commit
string | patch
string | test_patch
string | problem_statement
string | hints_text
string | all_hints_text
string | commit_urls
list | created_at
timestamp[us] | version
string | language
string | env_setup_script
string | original_env_setup_script
string | eval_script
string | image_name
string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
systemd/systemd
| 24,645
|
systemd__systemd-24645
|
[
17078
] |
6d64cb0625691e2b9eda8babe07ac8281f9467ee
|
diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c
index 882547d655fba..cd0915e2b2661 100644
--- a/src/shared/seccomp-util.c
+++ b/src/shared/seccomp-util.c
@@ -1602,7 +1602,7 @@ int seccomp_restrict_address_families(Set *address_families, bool allow_list) {
return 0;
}
-int seccomp_restrict_realtime(void) {
+int seccomp_restrict_realtime_full(int error_code) {
static const int permitted_policies[] = {
SCHED_OTHER,
SCHED_BATCH,
@@ -1613,6 +1613,8 @@ int seccomp_restrict_realtime(void) {
uint32_t arch;
unsigned i;
+ assert(error_code > 0);
+
/* Determine the highest policy constant we want to allow */
for (i = 0; i < ELEMENTSOF(permitted_policies); i++)
if (permitted_policies[i] > max_policy)
@@ -1646,7 +1648,7 @@ int seccomp_restrict_realtime(void) {
/* Deny this policy */
r = seccomp_rule_add_exact(
seccomp,
- SCMP_ACT_ERRNO(EPERM),
+ SCMP_ACT_ERRNO(error_code),
SCMP_SYS(sched_setscheduler),
1,
SCMP_A1(SCMP_CMP_EQ, p));
@@ -1660,7 +1662,7 @@ int seccomp_restrict_realtime(void) {
* are unsigned here, hence no need no check for < 0 values. */
r = seccomp_rule_add_exact(
seccomp,
- SCMP_ACT_ERRNO(EPERM),
+ SCMP_ACT_ERRNO(error_code),
SCMP_SYS(sched_setscheduler),
1,
SCMP_A1(SCMP_CMP_GT, max_policy));
diff --git a/src/shared/seccomp-util.h b/src/shared/seccomp-util.h
index aa249539f33d1..3f1a993e11cdc 100644
--- a/src/shared/seccomp-util.h
+++ b/src/shared/seccomp-util.h
@@ -96,7 +96,10 @@ int seccomp_restrict_namespaces(unsigned long retain);
int seccomp_protect_sysctl(void);
int seccomp_protect_syslog(void);
int seccomp_restrict_address_families(Set *address_families, bool allow_list);
-int seccomp_restrict_realtime(void);
+int seccomp_restrict_realtime_full(int error_code); /* This is mostly for testing code. */
+static inline int seccomp_restrict_realtime(void) {
+ return seccomp_restrict_realtime_full(EPERM);
+}
int seccomp_memory_deny_write_execute(void);
int seccomp_lock_personality(unsigned long personality);
int seccomp_protect_hostname(void);
|
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
index 3aaeb7147ef00..4c704badbd71c 100644
--- a/src/test/test-seccomp.c
+++ b/src/test/test-seccomp.c
@@ -559,22 +559,32 @@ TEST(restrict_realtime) {
assert_se(pid >= 0);
if (pid == 0) {
- assert_se(sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) >= 0);
- assert_se(sched_setscheduler(0, SCHED_RR, &(struct sched_param) { .sched_priority = 1 }) >= 0);
+ /* On some CI environments, the restriction may be already enabled. */
+ if (sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) < 0) {
+ log_full_errno(errno == EPERM ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to set scheduler parameter for FIFO: %m");
+ assert(errno == EPERM);
+ }
+ if (sched_setscheduler(0, SCHED_RR, &(struct sched_param) { .sched_priority = 1 }) < 0) {
+ log_full_errno(errno == EPERM ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to set scheduler parameter for RR: %m");
+ assert(errno == EPERM);
+ }
+
assert_se(sched_setscheduler(0, SCHED_IDLE, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_BATCH, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_OTHER, &(struct sched_param) {}) >= 0);
- assert_se(seccomp_restrict_realtime() >= 0);
+ assert_se(seccomp_restrict_realtime_full(ENOANO) >= 0);
assert_se(sched_setscheduler(0, SCHED_IDLE, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_BATCH, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_OTHER, &(struct sched_param) {}) >= 0);
assert_se(sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) < 0);
- assert_se(errno == EPERM);
+ assert_se(errno == ENOANO);
assert_se(sched_setscheduler(0, SCHED_RR, &(struct sched_param) { .sched_priority = 1 }) < 0);
- assert_se(errno == EPERM);
+ assert_se(errno == ENOANO);
_exit(EXIT_SUCCESS);
}
|
test: test-seccomp randomly fails on CentOS CI (CentOS 7/8)
https://jenkins-systemd.apps.ocp.ci.centos.org/job/upstream-centos7/127/artifact//systemd-centos-ci/artifacts_xC5blF/testsuite-logs-upstream.rAb/ninja-test_FAIL.log
https://jenkins-systemd.apps.ocp.ci.centos.org/job/upstream-centos7/132/artifact//systemd-centos-ci/artifacts_ic4A9k/testsuite-logs-upstream.aZx/ninja-test_FAIL.log
```
303/476 test-seccomp FAIL 0.98 s (killed by signal 6 SIGABRT)
--- command ---
SYSTEMD_LANGUAGE_FALLBACK_MAP='/root/systemd/src/locale/language-fallback-map' PATH='/root/systemd/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin' SYSTEMD_KBD_MODEL_MAP='/root/systemd/src/locale/kbd-model-map' /root/systemd/build/test-seccomp
--- Listing only the last 100 lines from a long log. ---
System call semtimedop_time64 is not known, ignoring.
Failed to add rule for system call send() / -109, ignoring: Numerical argument out of domain
Failed to add rule for system call sendfile64() / -10043, ignoring: Numerical argument out of domain
Failed to add rule for system call setfsgid32() / -10044, ignoring: Numerical argument out of domain
Failed to add rule for system call setfsuid32() / -10045, ignoring: Numerical argument out of domain
Failed to add rule for system call setgid32() / -10046, ignoring: Numerical argument out of domain
Failed to add rule for system call setgroups32() / -10047, ignoring: Numerical argument out of domain
System call sethae is not known, ignoring.
System call setpgrp is not known, ignoring.
Failed to add rule for system call setregid32() / -10048, ignoring: Numerical argument out of domain
Failed to add rule for system call setresgid32() / -10049, ignoring: Numerical argument out of domain
Failed to add rule for system call setresuid32() / -10050, ignoring: Numerical argument out of domain
Failed to add rule for system call setreuid32() / -10051, ignoring: Numerical argument out of domain
Failed to add rule for system call setuid32() / -10052, ignoring: Numerical argument out of domain
Failed to add rule for system call sgetmask() / -10053, ignoring: Numerical argument out of domain
Failed to add rule for system call sigaction() / -10054, ignoring: Numerical argument out of domain
Failed to add rule for system call signal() / -10055, ignoring: Numerical argument out of domain
Failed to add rule for system call sigpending() / -10056, ignoring: Numerical argument out of domain
Failed to add rule for system call sigprocmask() / -10057, ignoring: Numerical argument out of domain
Failed to add rule for system call sigreturn() / -10058, ignoring: Numerical argument out of domain
Failed to add rule for system call sigsuspend() / -10059, ignoring: Numerical argument out of domain
Failed to add rule for system call socketcall() / -10060, ignoring: Numerical argument out of domain
Failed to add rule for system call spu_create() / -10188, ignoring: Numerical argument out of domain
Failed to add rule for system call spu_run() / -10189, ignoring: Numerical argument out of domain
Failed to add rule for system call ssetmask() / -10061, ignoring: Numerical argument out of domain
Failed to add rule for system call stat64() / -10062, ignoring: Numerical argument out of domain
Failed to add rule for system call statfs64() / -10063, ignoring: Numerical argument out of domain
Failed to add rule for system call stime() / -10064, ignoring: Numerical argument out of domain
Failed to add rule for system call subpage_prot() / -10189, ignoring: Numerical argument out of domain
Failed to add rule for system call swapcontext() / -10190, ignoring: Numerical argument out of domain
Failed to add rule for system call switch_endian() / -10191, ignoring: Numerical argument out of domain
Failed to add rule for system call sync_file_range2() / -10089, ignoring: Numerical argument out of domain
Failed to add rule for system call sys_debug_setcontext() / -10191, ignoring: Numerical argument out of domain
Failed to add rule for system call syscall() / -10090, ignoring: Numerical argument out of domain
Failed to add rule for system call sysmips() / -10106, ignoring: Numerical argument out of domain
System call timer_gettime64 is not known, ignoring.
System call timer_settime64 is not known, ignoring.
Failed to add rule for system call timerfd() / -10107, ignoring: Numerical argument out of domain
System call timerfd_gettime64 is not known, ignoring.
System call timerfd_settime64 is not known, ignoring.
Failed to add rule for system call truncate64() / -10066, ignoring: Numerical argument out of domain
System call udftrap is not known, ignoring.
Failed to add rule for system call ugetrlimit() / -10068, ignoring: Numerical argument out of domain
Failed to add rule for system call umount() / -10070, ignoring: Numerical argument out of domain
System call utimensat_time64 is not known, ignoring.
System call utimesat is not known, ignoring.
System call utrap_install is not known, ignoring.
Failed to add rule for system call vm86() / -10071, ignoring: Numerical argument out of domain
Failed to add rule for system call vm86old() / -10072, ignoring: Numerical argument out of domain
Failed to add rule for system call waitpid() / -10073, ignoring: Numerical argument out of domain
@known succeeded.
/* test_filter_sets_ordered */
/* test_restrict_namespace */
Restricting namespace to: net mnt.
Operating on architecture: x86
Blocking cgroup.
Blocking ipc.
Permitting net.
Permitting mnt.
Blocking pid.
Blocking user.
Blocking uts.
Operating on architecture: x32
Blocking cgroup.
Blocking ipc.
Permitting net.
Permitting mnt.
Blocking pid.
Blocking user.
Blocking uts.
Operating on architecture: x86-64
Blocking cgroup.
Blocking ipc.
Permitting net.
Permitting mnt.
Blocking pid.
Blocking user.
Blocking uts.
nsseccomp succeeded.
/* test_protect_sysctl */
Operating on architecture: x86
Operating on architecture: x32
Operating on architecture: x86-64
sysctlseccomp succeeded.
/* test_protect_syslog */
syslogseccomp succeeded.
/* test_restrict_address_families */
Operating on architecture: x86
Operating on architecture: x32
Operating on architecture: x86-64
Operating on architecture: x86
Operating on architecture: x32
Operating on architecture: x86-64
socketseccomp succeeded.
/* test_restrict_realtime */
Assertion 'sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) >= 0' failed at src/test/test-seccomp.c:492, function test_restrict_realtime(). Aborting.
realtimeseccomp terminated by signal ABRT.
Assertion 'wait_for_terminate_and_check("realtimeseccomp", pid, WAIT_LOG) == EXIT_SUCCESS' failed at src/test/test-seccomp.c:512, function test_restrict_realtime(). Aborting.
-------
```
|
I checked last ~60 CentOS 7 builds and the issue seems to be gone (given the previous frequency of the fails). Closing this for now, please reopen if the issue reoccurs.
*Sigh*, looks like the issue resurfaced one again... I wonder what set it off.
* https://jenkins-systemd.apps.ocp.ci.centos.org/job/upstream-centos7/1694/artifact//systemd-centos-ci/artifacts_yczT54/testsuite-logs-upstream.P5E/ninja-test_FAIL.log
* https://jenkins-systemd.apps.ocp.ci.centos.org/job/upstream-centos7/1692/artifact//systemd-centos-ci/artifacts_kO2sZf/testsuite-logs-upstream.i7I/ninja-test_FAIL.log
@mrc0mmand Is this still relevant?
I'll reenable the test in CI to check it.
|
I checked last ~60 CentOS 7 builds and the issue seems to be gone (given the previous frequency of the fails). Closing this for now, please reopen if the issue reoccurs.
*Sigh*, looks like the issue resurfaced one again... I wonder what set it off.
* https://jenkins-systemd.apps.ocp.ci.centos.org/job/upstream-centos7/1694/artifact//systemd-centos-ci/artifacts_yczT54/testsuite-logs-upstream.P5E/ninja-test_FAIL.log
* https://jenkins-systemd.apps.ocp.ci.centos.org/job/upstream-centos7/1692/artifact//systemd-centos-ci/artifacts_kO2sZf/testsuite-logs-upstream.i7I/ninja-test_FAIL.log
@mrc0mmand Is this still relevant?
I'll reenable the test in CI to check it.
|
[
"https://github.com/systemd/systemd/commit/436095a4cf09bb32690c300e044e394ac2f57091"
] | 2022-09-12T17:40:20
|
0.0
|
C
|
#!/usr/bin/env bash
set -e
cd /testbed
git reset --hard 6d64cb0625691e2b9eda8babe07ac8281f9467ee
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export DEBIAN_FRONTEND=noninteractive
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3 python3-pip python3-setuptools python3-jinja2 python3-lxml python3-pyparsing python3-pyelftools python3-pefile python3-evdev \
ninja-build gperf pkg-config \
gcc clang llvm \
libcap-dev libmount-dev libblkid-dev libbpf-dev libseccomp-dev libkmod-dev libcryptsetup-dev libaudit-dev libacl1-dev libmicrohttpd-dev \
libssl-dev liblz4-dev liblzma-dev libzstd-dev libcurl4-gnutls-dev libgpg-error-dev libpwquality-dev libtss2-dev libfido2-dev libp11-kit-dev \
libqrencode-dev libxkbcommon-dev libxtables-dev libarchive-dev libfdisk-dev mold \
gettext iputils-ping isc-dhcp-client itstool kbd net-tools unifont util-linux quota strace \
cryptsetup-bin expect fdisk mount || { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# Install meson>=0.62.0 via pip
python3 -m pip install --user --upgrade "meson>=0.62.0" || { echo "[FATAL] pip meson install failed"; exit 1; }
# Ensure pip-installed meson is in PATH
export PATH="$(python3 -m site --user-base)/bin:${PATH}"
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# No vcpkg/conan needed for systemd's Meson build
# ========================================================
# 5️⃣ Build Attempts (Test-focused)
# ========================================================
# Verify meson version before setup
echo "[INFO] Meson version to be used for build:"
meson --version || { echo "[FATAL] meson not found in PATH"; exit 1; }
# Configure for tests only
meson setup -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror -Dnobody-group=nogroup -Ddebug=false build/ || { echo "[FATAL] meson setup failed"; exit 1; }
# Verify build.ninja exists
test -f build/build.ninja || { echo "[FATAL] build.ninja not found after meson setup"; exit 1; }
# Build only the test-varlink target
meson compile -C build test-varlink || { echo "[FATAL] meson compile test-varlink failed"; exit 1; }
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] Final Meson version:"
meson --version
echo "[INFO] Ninja version:"
ninja --version
echo "[INFO] Build directory exists and build.ninja present:"
ls -ld /testbed/build
ls -l /testbed/build/build.ninja
echo "[INFO] test-varlink binary location:"
find /testbed/build -name test-varlink -type f -executable || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -uxo pipefail
# === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
cd /testbed
git config --global --add safe.directory /testbed
# === Repository Status Before Patch ===
echo "=== Repository Status Before Patch ==="
git status
git show --stat
meson --version # systemd uses meson+ninja
ninja --version
# === Reset Test Files to Clean State ===
echo "=== Resetting Test Files to Clean State ==="
git checkout 6d64cb0625691e2b9eda8babe07ac8281f9467ee -- src/test/test-seccomp.c || true
# === Apply Test Patch ===
# [IMPORTANT NOTE]: The [test patch content] between EOF_114329324912 below is a fixed placeholder.
# DO NOT modify/delete it. The actual Git Patch content will be manually replaced in subsequent processes.
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
index 3aaeb7147ef00..4c704badbd71c 100644
--- a/src/test/test-seccomp.c
+++ b/src/test/test-seccomp.c
@@ -559,22 +559,32 @@ TEST(restrict_realtime) {
assert_se(pid >= 0);
if (pid == 0) {
- assert_se(sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) >= 0);
- assert_se(sched_setscheduler(0, SCHED_RR, &(struct sched_param) { .sched_priority = 1 }) >= 0);
+ /* On some CI environments, the restriction may be already enabled. */
+ if (sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) < 0) {
+ log_full_errno(errno == EPERM ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to set scheduler parameter for FIFO: %m");
+ assert(errno == EPERM);
+ }
+ if (sched_setscheduler(0, SCHED_RR, &(struct sched_param) { .sched_priority = 1 }) < 0) {
+ log_full_errno(errno == EPERM ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to set scheduler parameter for RR: %m");
+ assert(errno == EPERM);
+ }
+
assert_se(sched_setscheduler(0, SCHED_IDLE, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_BATCH, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_OTHER, &(struct sched_param) {}) >= 0);
- assert_se(seccomp_restrict_realtime() >= 0);
+ assert_se(seccomp_restrict_realtime_full(ENOANO) >= 0);
assert_se(sched_setscheduler(0, SCHED_IDLE, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_BATCH, &(struct sched_param) { .sched_priority = 0 }) >= 0);
assert_se(sched_setscheduler(0, SCHED_OTHER, &(struct sched_param) {}) >= 0);
assert_se(sched_setscheduler(0, SCHED_FIFO, &(struct sched_param) { .sched_priority = 1 }) < 0);
- assert_se(errno == EPERM);
+ assert_se(errno == ENOANO);
assert_se(sched_setscheduler(0, SCHED_RR, &(struct sched_param) { .sched_priority = 1 }) < 0);
- assert_se(errno == EPERM);
+ assert_se(errno == ENOANO);
_exit(EXIT_SUCCESS);
}
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD -- src/test/test-seccomp.c
# === Configure with meson ===
echo "=== Configure with meson ==="
rm -rf build
meson setup build --werror || true
# === Detect test target for test-seccomp ===
echo "=== Detecting test binaries ==="
meson introspect --targets build | jq -r '.[] | select(.name | test("test.*seccomp")) | .name' || true
# === Build test target ===
echo "=== Build test-seccomp target ==="
ninja -C build test-seccomp || true
# === Run test binary directly ===
echo "=== Running test-seccomp ==="
./build/test-seccomp | tee -a results.log
rc_seccomp=$?
# === Compute final exit code ===
final_rc=$rc_seccomp
# === Restore Repository State ===
echo "=== Restoring Repository State ==="
git checkout 6d64cb0625691e2b9eda8babe07ac8281f9467ee -- src/test/test-seccomp.c || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:systemd-systemd-pr-24645
|
systemd/systemd
| 31,171
|
systemd__systemd-31171
|
[
31168
] |
3092bd7aa12ca6c51cba8dae937c9a5c360c4e6a
|
diff --git a/src/libsystemd-network/ndisc-router.c b/src/libsystemd-network/ndisc-router.c
index 89681d00758b9..e50a0b966b627 100644
--- a/src/libsystemd-network/ndisc-router.c
+++ b/src/libsystemd-network/ndisc-router.c
@@ -9,6 +9,7 @@
#include "alloc-util.h"
#include "dns-domain.h"
+#include "escape.h"
#include "hostname-util.h"
#include "memory-util.h"
#include "missing_network.h"
@@ -716,8 +717,12 @@ int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret) {
e[n] = 0;
r = dns_name_normalize(e, 0, &normalized);
- if (r < 0)
- return r;
+ if (r < 0) {
+ _cleanup_free_ char *escaped = cescape(e);
+ log_debug_errno(r, "Failed to normalize advertised domain name \"%s\": %m", strna(escaped));
+ /* Here, do not propagate error code from dns_name_normalize() except for ENOMEM. */
+ return r == -ENOMEM ? -ENOMEM : -EBADMSG;
+ }
/* Ignore the root domain name or "localhost" and friends */
if (!is_localhost(normalized) &&
@@ -753,8 +758,12 @@ int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret) {
e[n++] = '.';
r = dns_label_escape((char*) p+1, *p, e + n, DNS_LABEL_ESCAPED_MAX);
- if (r < 0)
- return r;
+ if (r < 0) {
+ _cleanup_free_ char *escaped = cescape_length((const char*) p+1, *p);
+ log_debug_errno(r, "Failed to escape advertised domain name \"%s\": %m", strna(escaped));
+ /* Here, do not propagate error code from dns_label_escape() except for ENOMEM. */
+ return r == -ENOMEM ? -ENOMEM : -EBADMSG;
+ }
n += r;
|
diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c
index d0648b95fabf1..cc00461839fe3 100644
--- a/src/libsystemd-network/test-ndisc-rs.c
+++ b/src/libsystemd-network/test-ndisc-rs.c
@@ -150,6 +150,10 @@ static void router_dump(sd_ndisc_router *rt) {
int n, i;
n = sd_ndisc_router_dnssl_get_domains(rt, &l);
+ if (n == -EBADMSG) {
+ log_info("Invalid domain(s).");
+ break;
+ }
assert_se(n > 0);
for (i = 0; i < n; i++)
@@ -167,18 +171,23 @@ static void router_dump(sd_ndisc_router *rt) {
static int send_ra(uint8_t flags) {
uint8_t advertisement[] = {
+ /* struct nd_router_advert */
0x86, 0x00, 0xde, 0x83, 0x40, 0xc0, 0x00, 0xb4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x03 (SD_NDISC_OPTION_PREFIX_INFORMATION), length = 32 */
0x03, 0x04, 0x40, 0xc0, 0x00, 0x00, 0x01, 0xf4,
0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x00,
0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x19 (SD_NDISC_OPTION_RDNSS), length = 24 */
0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ /* type = 0x1f (SD_NDISC_OPTION_DNSSL), legnth = 24 */
0x1f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x03, 0x6c, 0x61, 0x62, 0x05, 0x69, 0x6e, 0x74,
0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x01 (SD_NDISC_OPTION_SOURCE_LL_ADDRESS), legth = 8 */
0x01, 0x01, 0x78, 0x2b, 0xcb, 0xb3, 0x6d, 0x53,
};
@@ -224,6 +233,7 @@ static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router
return;
}
+ idx = 0;
sd_event_exit(e, 0);
}
@@ -261,6 +271,80 @@ TEST(rs) {
test_fd[1] = safe_close(test_fd[1]);
}
+static int send_ra_invalid_domain(uint8_t flags) {
+ uint8_t advertisement[] = {
+ /* struct nd_router_advert */
+ 0x86, 0x00, 0xde, 0x83, 0x40, 0xc0, 0x00, 0xb4,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x03 (SD_NDISC_OPTION_PREFIX_INFORMATION), length = 32 */
+ 0x03, 0x04, 0x40, 0xc0, 0x00, 0x00, 0x01, 0xf4,
+ 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x00,
+ 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x19 (SD_NDISC_OPTION_RDNSS), length = 24 */
+ 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
+ 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ /* type = 0x1f (SD_NDISC_OPTION_DNSSL), legnth = 112 */
+ 0x1f, 0x0e, 0xee, 0x68, 0xb0, 0xf4, 0x36, 0x39,
+ 0x2c, 0xbc, 0x0b, 0xbc, 0xa9, 0x97, 0x71, 0x37,
+ 0xad, 0x86, 0x80, 0x14, 0x2e, 0x58, 0xaa, 0x8a,
+ 0xb7, 0xa1, 0xbe, 0x91, 0x59, 0x00, 0xc4, 0xe8,
+ 0xdd, 0xd8, 0x6d, 0xe5, 0x4a, 0x7a, 0x71, 0x42,
+ 0x74, 0x45, 0x9e, 0x2e, 0xfd, 0x9d, 0x71, 0x1d,
+ 0xd0, 0xc0, 0x54, 0x0c, 0x4d, 0x1f, 0xbf, 0x90,
+ 0xd9, 0x79, 0x58, 0xc0, 0x1d, 0xa3, 0x39, 0xcf,
+ 0xb8, 0xec, 0xd2, 0xe4, 0xcd, 0xb6, 0x13, 0x2f,
+ 0xc0, 0x46, 0xe8, 0x07, 0x3f, 0xaa, 0x28, 0xa5,
+ 0x23, 0xf1, 0xf0, 0xca, 0xd3, 0x19, 0x3f, 0xfa,
+ 0x6c, 0x7c, 0xec, 0x1b, 0xcf, 0x71, 0xeb, 0xba,
+ 0x68, 0x1b, 0x8e, 0x7d, 0x93, 0x7e, 0x0b, 0x9f,
+ 0xdb, 0x12, 0x9c, 0x75, 0x22, 0x5f, 0x12, 0x00,
+ /* type = 0x01 (SD_NDISC_OPTION_SOURCE_LL_ADDRESS), legth = 8 */
+ 0x01, 0x01, 0x78, 0x2b, 0xcb, 0xb3, 0x6d, 0x53,
+ };
+
+ advertisement[5] = flags;
+
+ printf("sizeof(nd_router_advert)=%zu\n", sizeof(struct nd_router_advert));
+
+ assert_se(write(test_fd[1], advertisement, sizeof(advertisement)) ==
+ sizeof(advertisement));
+
+ if (verbose)
+ printf(" sent RA with flag 0x%02x\n", flags);
+
+ return 0;
+}
+
+TEST(invalid_domain) {
+ _cleanup_(sd_event_unrefp) sd_event *e = NULL;
+ _cleanup_(sd_ndisc_unrefp) sd_ndisc *nd = NULL;
+
+ send_ra_function = send_ra_invalid_domain;
+
+ assert_se(sd_event_new(&e) >= 0);
+
+ assert_se(sd_ndisc_new(&nd) >= 0);
+ assert_se(nd);
+
+ assert_se(sd_ndisc_attach_event(nd, e, 0) >= 0);
+
+ assert_se(sd_ndisc_set_ifindex(nd, 42) >= 0);
+ assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
+ assert_se(sd_ndisc_set_callback(nd, test_callback, e) >= 0);
+
+ assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
+ 30 * USEC_PER_SEC, 0,
+ NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
+
+ assert_se(sd_ndisc_start(nd) >= 0);
+
+ assert_se(sd_event_loop(e) >= 0);
+
+ test_fd[1] = safe_close(test_fd[1]);
+}
+
static int test_timeout_value(uint8_t flags) {
static int count = 0;
static usec_t last = 0;
|
networkd: "State changed: configured -> failed" on receiving malformed DNSSL RA options
```sh
eived Router Advertisement: flags none preference medium lifetime 30min
host0: NDISC: Invoking callback for 'router' event.
host0: Requesting NDisc route (configuring,configured): dst: n/a, src: n/a, gw: fe80::741a:afff:fe88:1910, prefsrc: n/a, table: main(254), priority: 1024, proto: ra, scope: global, type: unicast, flags: n/a
host0: Failed to get DNSSL addresses: Invalid argument
host0: Failed
host0: State changed: configured -> failed
Sent message type
```
The DNSSL option was
```python
>>> p[ICMPv6NDOptDNSSL].show()
###[ ICMPv6 Neighbor Discovery Option - DNS Search List Option ]###
type = 31
len = 14
res = 61032
lifetime = 2968794681
searchlist= ['\\xbc\x0b\\xbc\\xa9\\x97q7\\xad\\x86\\x80\x14.X\\xaa\\x8a\\x.7\\xa1\\xbe\\x91Y\x00\\xc4\\xe8\\xdd\\xd8m\\xe5JzqBtE\\x9e.\\xfd\\x9dq\x1d\\xd0\\xc0T\x0cM\x1f\\xbf\\x90\\xd9yX\\xc0\x1d\\xa39ϸ\\xec.xd2\\xe4Ͷ\x13/\\xc0F\\xe8\x07?\\xaa(\\xa5#\\xf1\\xf0\\xca\\xd3\x19?\\xfal|\\xec\x1b\\xcfq\\xeb\\xbah\x1b\\x8e}\\x93~\x0b\\x9f\\x.b\x12\\x9cu"_\x12\x00.']
```
```python
>>> hexdump(p[ICMPv6NDOptDNSSL])
0000 1F 0E EE 68 B0 F4 36 39 2C BC 0B BC A9 97 71 37 ...h..69,.....q7
0010 AD 86 80 14 2E 58 AA 8A B7 A1 BE 91 59 00 C4 E8 .....X......Y...
0020 DD D8 6D E5 4A 7A 71 42 74 45 9E 2E FD 9D 71 1D ..m.JzqBtE....q.
0030 D0 C0 54 0C 4D 1F BF 90 D9 79 58 C0 1D A3 39 CF ..T.M....yX...9.
0040 B8 EC D2 E4 CD B6 13 2F C0 46 E8 07 3F AA 28 A5 ......./.F..?.(.
0050 23 F1 F0 CA D3 19 3F FA 6C 7C EC 1B CF 71 EB BA #.....?.l|...q..
0060 68 1B 8E 7D 93 7E 0B 9F DB 12 9C 75 22 5F 12 00 h..}.~.....u"_..
```
Currently I have to restart networkd every 10 seconds to keep the fuzzer going.
|
@evverx Thank you for the detailed reproducer. Fix is waiting in #31171.
|
@evverx Thank you for the detailed reproducer. Fix is waiting in #31171.
What's weird is that it seems the idea behind c2eb7753dd47ec04ae0d66400e70bc87fbf1adcc was to fix things automatically (at least when failures aren't caused deliberately very often) but it doesn't seem to always work with transient one-off failures. I'll try to figure out what's going on there.
> the idea behind https://github.com/systemd/systemd/commit/c2eb7753dd47ec04ae0d66400e70bc87fbf1adcc was to fix things automatically ... it doesn't seem to always work with transient one-off failures
Looks like it was a false alarm. Turns out I sent 1000 packets instead of 1. When I actually sent 1 packet to emulate a transient failure networkd successfully reconfigured the interface.
> > the idea behind [c2eb775](https://github.com/systemd/systemd/commit/c2eb7753dd47ec04ae0d66400e70bc87fbf1adcc) was to fix things automatically ... it doesn't seem to always work with transient one-off failures
>
> Looks like it was a false alarm. Turns out I sent 1000 packets instead of 1. When I actually sent 1 packet to emulate a transient failure networkd successfully reconfigured the interface.
Nice! Thank you!
|
[
"https://github.com/systemd/systemd/commit/6244184e3ff2f7659406c2d08a9a4d75e08bccb2",
"https://github.com/systemd/systemd/commit/38a80ba1089fcad427f4376e28f74f9eb630fb91",
"https://github.com/systemd/systemd/commit/a39d8396a986cb6291486b1d8451de8b0fd2b6cc"
] | 2024-02-02T02:01:01
|
0.0
|
C
|
#!/usr/bin/env bash
set -e
cd /testbed
git reset --hard 3092bd7aa12ca6c51cba8dae937c9a5c360c4e6a
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export DEBIAN_FRONTEND=noninteractive
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3 python3-pip python3-setuptools python3-jinja2 python3-lxml python3-pyparsing python3-pyelftools python3-pefile python3-evdev \
ninja-build gperf pkg-config \
gcc clang llvm \
libcap-dev libmount-dev libblkid-dev libbpf-dev libseccomp-dev libkmod-dev libcryptsetup-dev libaudit-dev libacl1-dev libmicrohttpd-dev \
libssl-dev liblz4-dev liblzma-dev libzstd-dev libcurl4-gnutls-dev libgpg-error-dev libpwquality-dev libtss2-dev libfido2-dev libp11-kit-dev \
libqrencode-dev libxkbcommon-dev libxtables-dev libarchive-dev libfdisk-dev mold \
gettext iputils-ping isc-dhcp-client itstool kbd net-tools unifont util-linux quota strace \
cryptsetup-bin expect fdisk mount || { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# Install meson>=0.62.0 via pip
python3 -m pip install --user --upgrade "meson>=0.62.0" || { echo "[FATAL] pip meson install failed"; exit 1; }
# Ensure pip-installed meson is in PATH
export PATH="$(python3 -m site --user-base)/bin:${PATH}"
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# No vcpkg/conan needed for systemd's Meson build
# ========================================================
# 5️⃣ Build Attempts (Test-focused)
# ========================================================
# Verify meson version before setup
echo "[INFO] Meson version to be used for build:"
meson --version || { echo "[FATAL] meson not found in PATH"; exit 1; }
# Configure for tests only
meson setup -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror -Dnobody-group=nogroup -Ddebug=false build/ || { echo "[FATAL] meson setup failed"; exit 1; }
# Verify build.ninja exists
test -f build/build.ninja || { echo "[FATAL] build.ninja not found after meson setup"; exit 1; }
# Build only the test-varlink target
meson compile -C build test-varlink || { echo "[FATAL] meson compile test-varlink failed"; exit 1; }
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] Final Meson version:"
meson --version
echo "[INFO] Ninja version:"
ninja --version
echo "[INFO] Build directory exists and build.ninja present:"
ls -ld /testbed/build
ls -l /testbed/build/build.ninja
echo "[INFO] test-varlink binary location:"
find /testbed/build -name test-varlink -type f -executable || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/bin/bash
set -uxo pipefail
# === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
cd /testbed
git config --global --add safe.directory /testbed
echo "=== Repository Status Before Patch ==="
git status
git show --stat
meson --version
ninja --version
echo "=== Resetting Test Files to Clean State ==="
git checkout HEAD -- src/libsystemd-network/test-ndisc-rs.c || true
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c
index d0648b95fabf1..cc00461839fe3 100644
--- a/src/libsystemd-network/test-ndisc-rs.c
+++ b/src/libsystemd-network/test-ndisc-rs.c
@@ -150,6 +150,10 @@ static void router_dump(sd_ndisc_router *rt) {
int n, i;
n = sd_ndisc_router_dnssl_get_domains(rt, &l);
+ if (n == -EBADMSG) {
+ log_info("Invalid domain(s).");
+ break;
+ }
assert_se(n > 0);
for (i = 0; i < n; i++)
@@ -167,18 +171,23 @@ static void router_dump(sd_ndisc_router *rt) {
static int send_ra(uint8_t flags) {
uint8_t advertisement[] = {
+ /* struct nd_router_advert */
0x86, 0x00, 0xde, 0x83, 0x40, 0xc0, 0x00, 0xb4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x03 (SD_NDISC_OPTION_PREFIX_INFORMATION), length = 32 */
0x03, 0x04, 0x40, 0xc0, 0x00, 0x00, 0x01, 0xf4,
0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x00,
0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x19 (SD_NDISC_OPTION_RDNSS), length = 24 */
0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ /* type = 0x1f (SD_NDISC_OPTION_DNSSL), legnth = 24 */
0x1f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x03, 0x6c, 0x61, 0x62, 0x05, 0x69, 0x6e, 0x74,
0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x01 (SD_NDISC_OPTION_SOURCE_LL_ADDRESS), legth = 8 */
0x01, 0x01, 0x78, 0x2b, 0xcb, 0xb3, 0x6d, 0x53,
};
@@ -224,6 +233,7 @@ static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router
return;
}
+ idx = 0;
sd_event_exit(e, 0);
}
@@ -261,6 +271,80 @@ TEST(rs) {
test_fd[1] = safe_close(test_fd[1]);
}
+static int send_ra_invalid_domain(uint8_t flags) {
+ uint8_t advertisement[] = {
+ /* struct nd_router_advert */
+ 0x86, 0x00, 0xde, 0x83, 0x40, 0xc0, 0x00, 0xb4,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x03 (SD_NDISC_OPTION_PREFIX_INFORMATION), length = 32 */
+ 0x03, 0x04, 0x40, 0xc0, 0x00, 0x00, 0x01, 0xf4,
+ 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, 0x00,
+ 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* type = 0x19 (SD_NDISC_OPTION_RDNSS), length = 24 */
+ 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
+ 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ /* type = 0x1f (SD_NDISC_OPTION_DNSSL), legnth = 112 */
+ 0x1f, 0x0e, 0xee, 0x68, 0xb0, 0xf4, 0x36, 0x39,
+ 0x2c, 0xbc, 0x0b, 0xbc, 0xa9, 0x97, 0x71, 0x37,
+ 0xad, 0x86, 0x80, 0x14, 0x2e, 0x58, 0xaa, 0x8a,
+ 0xb7, 0xa1, 0xbe, 0x91, 0x59, 0x00, 0xc4, 0xe8,
+ 0xdd, 0xd8, 0x6d, 0xe5, 0x4a, 0x7a, 0x71, 0x42,
+ 0x74, 0x45, 0x9e, 0x2e, 0xfd, 0x9d, 0x71, 0x1d,
+ 0xd0, 0xc0, 0x54, 0x0c, 0x4d, 0x1f, 0xbf, 0x90,
+ 0xd9, 0x79, 0x58, 0xc0, 0x1d, 0xa3, 0x39, 0xcf,
+ 0xb8, 0xec, 0xd2, 0xe4, 0xcd, 0xb6, 0x13, 0x2f,
+ 0xc0, 0x46, 0xe8, 0x07, 0x3f, 0xaa, 0x28, 0xa5,
+ 0x23, 0xf1, 0xf0, 0xca, 0xd3, 0x19, 0x3f, 0xfa,
+ 0x6c, 0x7c, 0xec, 0x1b, 0xcf, 0x71, 0xeb, 0xba,
+ 0x68, 0x1b, 0x8e, 0x7d, 0x93, 0x7e, 0x0b, 0x9f,
+ 0xdb, 0x12, 0x9c, 0x75, 0x22, 0x5f, 0x12, 0x00,
+ /* type = 0x01 (SD_NDISC_OPTION_SOURCE_LL_ADDRESS), legth = 8 */
+ 0x01, 0x01, 0x78, 0x2b, 0xcb, 0xb3, 0x6d, 0x53,
+ };
+
+ advertisement[5] = flags;
+
+ printf("sizeof(nd_router_advert)=%zu\n", sizeof(struct nd_router_advert));
+
+ assert_se(write(test_fd[1], advertisement, sizeof(advertisement)) ==
+ sizeof(advertisement));
+
+ if (verbose)
+ printf(" sent RA with flag 0x%02x\n", flags);
+
+ return 0;
+}
+
+TEST(invalid_domain) {
+ _cleanup_(sd_event_unrefp) sd_event *e = NULL;
+ _cleanup_(sd_ndisc_unrefp) sd_ndisc *nd = NULL;
+
+ send_ra_function = send_ra_invalid_domain;
+
+ assert_se(sd_event_new(&e) >= 0);
+
+ assert_se(sd_ndisc_new(&nd) >= 0);
+ assert_se(nd);
+
+ assert_se(sd_ndisc_attach_event(nd, e, 0) >= 0);
+
+ assert_se(sd_ndisc_set_ifindex(nd, 42) >= 0);
+ assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
+ assert_se(sd_ndisc_set_callback(nd, test_callback, e) >= 0);
+
+ assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
+ 30 * USEC_PER_SEC, 0,
+ NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
+
+ assert_se(sd_ndisc_start(nd) >= 0);
+
+ assert_se(sd_event_loop(e) >= 0);
+
+ test_fd[1] = safe_close(test_fd[1]);
+}
+
static int test_timeout_value(uint8_t flags) {
static int count = 0;
static usec_t last = 0;
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD
echo "=== Configure Project ==="
if [ ! -d build ]; then
meson setup build
fi
echo "=== Building test-ndisc-rs target ==="
meson compile -C build test-ndisc-rs
echo "=== Running test-ndisc-rs via meson test ==="
meson test -C build test-ndisc-rs --print-errorlogs
rc_ndisc_rs=$?
final_rc=$rc_ndisc_rs
echo "=== Restoring Repository State ==="
git checkout HEAD -- src/libsystemd-network/test-ndisc-rs.c || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:systemd-systemd-pr-31171
|
libgit2/libgit2
| 6,125
|
libgit2__libgit2-6125
|
[
6065
] |
f9c4dc10d90732cfbe2271dd58b01dd8f4003d15
|
diff --git a/src/commit.c b/src/commit.c
index 752d98b022f..81e5b02d352 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -546,7 +546,7 @@ const char *git_commit_message(const git_commit *commit)
const char *git_commit_summary(git_commit *commit)
{
git_str summary = GIT_STR_INIT;
- const char *msg, *space;
+ const char *msg, *space, *next;
bool space_contains_newline = false;
GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
@@ -555,10 +555,21 @@ const char *git_commit_summary(git_commit *commit)
for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) {
char next_character = msg[0];
/* stop processing at the end of the first paragraph */
- if (next_character == '\n' && (!msg[1] || msg[1] == '\n'))
- break;
+ if (next_character == '\n') {
+ if (!msg[1])
+ break;
+ if (msg[1] == '\n')
+ break;
+ /* stop processing if next line contains only whitespace */
+ next = msg + 1;
+ while (*next && git__isspace_nonlf(*next)) {
+ ++next;
+ }
+ if (!*next || *next == '\n')
+ break;
+ }
/* record the beginning of contiguous whitespace runs */
- else if (git__isspace(next_character)) {
+ if (git__isspace(next_character)) {
if(space == NULL) {
space = msg;
space_contains_newline = false;
|
diff --git a/tests/commit/commit.c b/tests/commit/commit.c
index d4e333b6ad8..fd574f7f254 100644
--- a/tests/commit/commit.c
+++ b/tests/commit/commit.c
@@ -139,8 +139,11 @@ void test_commit_commit__summary(void)
{
assert_commit_summary("One-liner with no trailing newline", "One-liner with no trailing newline");
assert_commit_summary("One-liner with trailing newline", "One-liner with trailing newline\n");
+ assert_commit_summary("One-liner with trailing newline and space", "One-liner with trailing newline and space\n ");
assert_commit_summary("Trimmed leading&trailing newlines", "\n\nTrimmed leading&trailing newlines\n\n");
assert_commit_summary("First paragraph only", "\nFirst paragraph only\n\n(There are more!)");
+ assert_commit_summary("First paragraph only with space in the next line", "\nFirst paragraph only with space in the next line\n \n(There are more!)");
+ assert_commit_summary("First paragraph only with spaces in the next line", "\nFirst paragraph only with spaces in the next line\n \n(There are more!)");
assert_commit_summary("First paragraph with unwrapped trailing\tlines", "\nFirst paragraph\nwith unwrapped\ntrailing\tlines\n\n(Yes, unwrapped!)");
assert_commit_summary("\tLeading tabs", "\tLeading\n\ttabs\n\nare preserved"); /* tabs around newlines are collapsed down to a single space */
assert_commit_summary(" Leading Spaces", " Leading\n Spaces\n\nare preserved"); /* spaces around newlines are collapsed down to a single space */
|
`git_commit_summary` creates too long output for some commits
### Description
`git_commit_summary` produces too long paragraphs for some commits, like for this one in the Linux repository - https://github.com/torvalds/linux/commit/3218357c94af92478ef39163163a81e654385320. It creates 925 characters long text (almost the whole commit message) instead of 46 characters long (just the first line).
### Reproduction steps
Create a project with following files:
main.cpp:
```c++
#include "deps/libgit2/include/git2.h"
#include <iostream>
int main()
{
git_libgit2_init();
const std::string repoPath = "path_to_linux_repository"; // INSERT YOUR OWN
git_repository* repo = nullptr;
if (const auto status = git_repository_open(&repo, repoPath.c_str()); status != 0)
{
throw std::runtime_error("Failed to open repository at " + repoPath + ", status: " + std::to_string(status));
}
git_oid id{};
if (const auto status = git_oid_fromstr(&id, "3218357c94af92478ef39163163a81e654385320"); status != 0)
{
throw std::runtime_error("Failed to create OID, status: " + std::to_string(status));
}
git_commit* commit = nullptr;
if (const auto status = git_commit_lookup(&commit, repo, &id); status != 0)
{
throw std::runtime_error("Failed to lookup commit, status: " + std::to_string(status));
}
const std::string summary = git_commit_summary(commit);
std::cout << "git_commit_summary returned (size: " + std::to_string(summary.size()) + "): " << summary << "\n";
return 0;
}
```
CMakeLists.txt:
```cmake
project(libgit2-commit-summary-test)
cmake_minimum_required(VERSION 3.0)
add_subdirectory(deps/libgit2)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} git2)
```
Also download libgit2 as the dependency:
```
mkdir deps && cd deps
git clone https://github.com/libgit2/libgit2.git
cd ..
```
Build and run the project:
```
mkdir build && cd build
cmake ..
cmake --build .
./libgit2-commit-summary-test
```
### Expected behavior
The summary should be: `[MIPS] More uaccess.h fixes with gcc >= 4.0.1.`
### Actual behavior
The summary is:
`[MIPS] More uaccess.h fixes with gcc >= 4.0.1. From Richard Sandiford <richard@codesourcery.com>: This patch caused a miscompilation of the restore_gp_regs() block in restore_sigcontext(). This was in a 32-bit kernel compiled with GCC CVS head. restore_gp_regs() copies 64-bit user fields into 32-bit variables, and in this combination, the new __get_user_asm_ll32() clobbers too many registers. It says: /* * Get a long long 64 using 32 bit registers. */ { \ __asm__ __volatile__( \ "1: lw %1, (%3) \n" \ "2: lw %D1, 4(%3) \n" \ " move %0, $0 \n" \ "3: .section .fixup,\"ax\" \n" \ "4: li %0, %4 \n" \ " move %1, $0 \n" \ " move %D1, $0 \n" \ " j 3b \n" \ " .previous \n" \ " .section __ex_table,\"a\" \n" \ " " __UA_ADDR " 1b, 4b \n" \ " " __UA_ADDR " 2b, 4b \n" \ " .previous \n" \ : "=r" (__gu_err), "=&r" (val) \ : "0" (0), "r" (addr), "i" (-EFAULT)); \ }`
### Version of libgit2 (release number or SHA1)
0a8728622ecf77ce4185139761b31f0c6f77f04e
### Operating system(s) tested
Manjaro
|
Indeed. The commit message in https://github.com/torvalds/linux/commit/3218357c94af92478ef39163163a81e654385320 is `message<nl><sp><sp><sp><sp><nl>...` We should treat two newlines as a paragraph separator even when those two newlines have whitespace in between.
The documentation of [git_commit_summary](https://libgit2.org/libgit2/#v0.24.0/group/commit/git_commit_summary) says:
> The returned message is the summary of the commit, comprising the first paragraph of the message with whitespace trimmed and squashed.
So I believe the whitespace at the end should be removed.
Edit: This comment was an answer to another comment, which is no longer visible here (removed?).
Yeah sorry, I posted the question bu re-read the code itself and saw the the behaviour of squashing whitespace at the end was already implemented, so I removed my comment.
|
Indeed. The commit message in https://github.com/torvalds/linux/commit/3218357c94af92478ef39163163a81e654385320 is `message<nl><sp><sp><sp><sp><nl>...` We should treat two newlines as a paragraph separator even when those two newlines have whitespace in between.
The documentation of [git_commit_summary](https://libgit2.org/libgit2/#v0.24.0/group/commit/git_commit_summary) says:
> The returned message is the summary of the commit, comprising the first paragraph of the message with whitespace trimmed and squashed.
So I believe the whitespace at the end should be removed.
Edit: This comment was an answer to another comment, which is no longer visible here (removed?).
Yeah sorry, I posted the question bu re-read the code itself and saw the the behaviour of squashing whitespace at the end was already implemented, so I removed my comment.
|
[
"https://github.com/libgit2/libgit2/commit/1e015088d0878ebbf6545702688dff2d69c9eeb5"
] | 2021-11-25T14:21:48
|
1.3
|
C
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential ninja-build cmake python3 pkg-config \
libssl-dev zlib1g-dev libssh2-1-dev libffi-dev curl \
git openssh-client ca-certificates \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# None (libgit2 uses system libs only)
# ========================================================
# 5️⃣ Build Attempts (test-focused only)
# ========================================================
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=ON \
-DTHREADSAFE=ON \
-DUSE_HTTPS=ON \
-DUSE_SSH=ON \
-DENABLE_WERROR=OFF
cmake --build build --target libgit2_tests
# Ensure libgit2_tests exists
if [ ! -f build/libgit2_tests ]; then
echo "ERROR: libgit2_tests binary not built"
ls -l build/
exit 1
fi
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"; $CC --version
echo "[INFO] CMake version:"; cmake --version
echo "[INFO] Ninja version:"; ninja --version
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential ninja-build cmake python3 pkg-config \
libssl-dev zlib1g-dev libssh2-1-dev libffi-dev valgrind \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (none required for this project)
# ========================================================
# No conan/vcpkg/bazel needed for libgit2
# ========================================================
# 5️⃣ Build Attempts (test-focused only)
# ========================================================
# Configure with tests enabled
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_CLAR=ON \
-DTHREADSAFE=ON \
-DUSE_HTTPS=ON \
-DUSE_SSH=ON || true
# Build only the test executable
cmake --build build --target libgit2_clar || true
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] CMake version:"
cmake --version || true
echo "[INFO] Ninja version:"
ninja --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/bin/bash
set -uxo pipefail
cd /testbed
echo "=== Reset patched test files to clean state ==="
git checkout f9c4dc10d90732cfbe2271dd58b01dd8f4003d15 -- tests/commit/commit.c
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/tests/commit/commit.c b/tests/commit/commit.c
index d4e333b6ad8..fd574f7f254 100644
--- a/tests/commit/commit.c
+++ b/tests/commit/commit.c
@@ -139,8 +139,11 @@ void test_commit_commit__summary(void)
{
assert_commit_summary("One-liner with no trailing newline", "One-liner with no trailing newline");
assert_commit_summary("One-liner with trailing newline", "One-liner with trailing newline\n");
+ assert_commit_summary("One-liner with trailing newline and space", "One-liner with trailing newline and space\n ");
assert_commit_summary("Trimmed leading&trailing newlines", "\n\nTrimmed leading&trailing newlines\n\n");
assert_commit_summary("First paragraph only", "\nFirst paragraph only\n\n(There are more!)");
+ assert_commit_summary("First paragraph only with space in the next line", "\nFirst paragraph only with space in the next line\n \n(There are more!)");
+ assert_commit_summary("First paragraph only with spaces in the next line", "\nFirst paragraph only with spaces in the next line\n \n(There are more!)");
assert_commit_summary("First paragraph with unwrapped trailing\tlines", "\nFirst paragraph\nwith unwrapped\ntrailing\tlines\n\n(Yes, unwrapped!)");
assert_commit_summary("\tLeading tabs", "\tLeading\n\ttabs\n\nare preserved"); /* tabs around newlines are collapsed down to a single space */
assert_commit_summary(" Leading Spaces", " Leading\n Spaces\n\nare preserved"); /* spaces around newlines are collapsed down to a single space */
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD --name-only
echo "=== Re-build only tests after patching ==="
cd build
cmake --build . --target libgit2_tests
echo "=== Run commit::commit suite with verbose output to ensure patched test executes ==="
./libgit2_tests -scommit::commit -v -v | tee /tmp/test_result.log
rc_test=${PIPESTATUS[0]}
echo "=== Restoring Repository State ==="
cd /testbed
git checkout f9c4dc10d90732cfbe2271dd58b01dd8f4003d15 -- tests/commit/commit.c
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$rc_test"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:libgit2-libgit2-pr-6125
|
libuv/libuv
| 4,040
|
libuv__libuv-4040
|
[
4036
] |
b9b6db052b82dd0a429091238181195ec785ac0b
|
diff --git a/docs/src/pipe.rst b/docs/src/pipe.rst
index 9d95b206a97..4abdc65e715 100644
--- a/docs/src/pipe.rst
+++ b/docs/src/pipe.rst
@@ -68,15 +68,18 @@ API
Bind the pipe to a file path (Unix) or a name (Windows).
- ``flags`` must be zero. Returns ``UV_EINVAL`` for unsupported flags
- without performing the bind operation.
+ ``flags`` must be zero or ``UV_PIPE_NO_TRUNCATE``. Returns ``UV_EINVAL``
+ for unsupported flags without performing the bind operation.
Supports Linux abstract namespace sockets. ``namelen`` must include
the leading nul byte but not the trailing nul byte.
+ .. versionadded:: 1.46.0
+
.. note::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes,
- typically between 92 and 108 bytes.
+ typically between 92 and 108 bytes, unless the ``UV_PIPE_NO_TRUNCATE``
+ flag is specified, in which case an ``UV_EINVAL`` error is returned.
.. c:function:: void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, const char* name, uv_connect_cb cb)
@@ -95,15 +98,18 @@ API
Connect to the Unix domain socket or the Windows named pipe.
- ``flags`` must be zero. Returns ``UV_EINVAL`` for unsupported flags
- without performing the connect operation.
+ ``flags`` must be zero or ``UV_PIPE_NO_TRUNCATE``. Returns ``UV_EINVAL``
+ for unsupported flags without performing the connect operation.
Supports Linux abstract namespace sockets. ``namelen`` must include
the leading nul byte but not the trailing nul byte.
+ .. versionadded:: 1.46.0
+
.. note::
Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes,
- typically between 92 and 108 bytes.
+ typically between 92 and 108 bytes, unless the ``UV_PIPE_NO_TRUNCATE``
+ flag is specified, in which case an ``UV_EINVAL`` error is returned.
.. c:function:: int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size)
diff --git a/include/uv.h b/include/uv.h
index 0f624f4d7f7..f68ff083b04 100644
--- a/include/uv.h
+++ b/include/uv.h
@@ -807,6 +807,10 @@ inline int uv_tty_set_mode(uv_tty_t* handle, int mode) {
UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
+enum {
+ UV_PIPE_NO_TRUNCATE = 1u << 0
+};
+
/*
* uv_pipe_t is a subclass of uv_stream_t.
*
diff --git a/src/unix/pipe.c b/src/unix/pipe.c
index 823deb3d975..d332f351830 100644
--- a/src/unix/pipe.c
+++ b/src/unix/pipe.c
@@ -56,7 +56,7 @@ int uv_pipe_bind2(uv_pipe_t* handle,
pipe_fname = NULL;
- if (flags != 0)
+ if (flags & ~UV_PIPE_NO_TRUNCATE)
return UV_EINVAL;
if (name == NULL)
@@ -71,6 +71,10 @@ int uv_pipe_bind2(uv_pipe_t* handle,
return UV_EINVAL;
#endif
+ if (flags & UV_PIPE_NO_TRUNCATE)
+ if (namelen > sizeof(saddr.sun_path))
+ return UV_EINVAL;
+
/* Truncate long paths. Documented behavior. */
if (namelen > sizeof(saddr.sun_path))
namelen = sizeof(saddr.sun_path);
@@ -221,7 +225,7 @@ int uv_pipe_connect2(uv_connect_t* req,
int err;
int r;
- if (flags != 0)
+ if (flags & ~UV_PIPE_NO_TRUNCATE)
return UV_EINVAL;
if (name == NULL)
@@ -236,6 +240,10 @@ int uv_pipe_connect2(uv_connect_t* req,
return UV_EINVAL;
#endif
+ if (flags & UV_PIPE_NO_TRUNCATE)
+ if (namelen > sizeof(saddr.sun_path))
+ return UV_EINVAL;
+
/* Truncate long paths. Documented behavior. */
if (namelen > sizeof(saddr.sun_path))
namelen = sizeof(saddr.sun_path);
diff --git a/src/win/pipe.c b/src/win/pipe.c
index a3daa3b7a18..f0cac382256 100644
--- a/src/win/pipe.c
+++ b/src/win/pipe.c
@@ -706,7 +706,7 @@ int uv_pipe_bind2(uv_pipe_t* handle,
int i, err, nameSize;
uv_pipe_accept_t* req;
- if (flags != 0) {
+ if (flags & ~UV_PIPE_NO_TRUNCATE) {
return UV_EINVAL;
}
@@ -722,6 +722,12 @@ int uv_pipe_bind2(uv_pipe_t* handle,
return UV_EINVAL;
}
+ if (flags & UV_PIPE_NO_TRUNCATE) {
+ if (namelen > 256) {
+ return UV_EINVAL;
+ }
+ }
+
if (handle->flags & UV_HANDLE_BOUND) {
return UV_EINVAL;
}
@@ -859,7 +865,7 @@ int uv_pipe_connect2(uv_connect_t* req,
HANDLE pipeHandle = INVALID_HANDLE_VALUE;
DWORD duplex_flags;
- if (flags != 0) {
+ if (flags & ~UV_PIPE_NO_TRUNCATE) {
return UV_EINVAL;
}
@@ -875,6 +881,12 @@ int uv_pipe_connect2(uv_connect_t* req,
return UV_EINVAL;
}
+ if (flags & UV_PIPE_NO_TRUNCATE) {
+ if (namelen > 256) {
+ return UV_EINVAL;
+ }
+ }
+
UV_REQ_INIT(req, UV_CONNECT);
req->handle = (uv_stream_t*) handle;
req->cb = cb;
|
diff --git a/test/test-list.h b/test/test-list.h
index 6da7812360a..b2c88170051 100644
--- a/test/test-list.h
+++ b/test/test-list.h
@@ -198,6 +198,7 @@ TEST_DECLARE (pipe_connect_close_multiple)
TEST_DECLARE (pipe_connect_multiple)
TEST_DECLARE (pipe_listen_without_bind)
TEST_DECLARE (pipe_bind_or_listen_error_after_close)
+TEST_DECLARE (pipe_overlong_path)
TEST_DECLARE (pipe_connect_bad_name)
TEST_DECLARE (pipe_connect_to_file)
TEST_DECLARE (pipe_connect_on_prepare)
@@ -799,6 +800,7 @@ TASK_LIST_START
TEST_ENTRY (pipe_connect_multiple)
TEST_ENTRY (pipe_listen_without_bind)
TEST_ENTRY (pipe_bind_or_listen_error_after_close)
+ TEST_ENTRY (pipe_overlong_path)
TEST_ENTRY (pipe_getsockname)
TEST_ENTRY (pipe_getsockname_abstract)
TEST_ENTRY (pipe_getsockname_blocking)
diff --git a/test/test-pipe-bind-error.c b/test/test-pipe-bind-error.c
index 88ece6ba5d8..f8626302a1d 100644
--- a/test/test-pipe-bind-error.c
+++ b/test/test-pipe-bind-error.c
@@ -153,3 +153,27 @@ TEST_IMPL(pipe_bind_or_listen_error_after_close) {
MAKE_VALGRIND_HAPPY(uv_default_loop());
return 0;
}
+
+TEST_IMPL(pipe_overlong_path) {
+ char path[512];
+ uv_pipe_t pipe;
+ uv_connect_t req;
+
+ memset(path, '@', sizeof(path));
+ ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe, 0));
+ ASSERT_EQ(UV_EINVAL,
+ uv_pipe_bind2(&pipe, path, sizeof(path), UV_PIPE_NO_TRUNCATE));
+ ASSERT_EQ(UV_EINVAL,
+ uv_pipe_connect2(&req,
+ &pipe,
+ path,
+ sizeof(path),
+ UV_PIPE_NO_TRUNCATE,
+ (uv_connect_cb) abort));
+ uv_close((uv_handle_t*) &pipe, NULL);
+ ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+
+ MAKE_VALGRIND_HAPPY(uv_default_loop());
+ return 0;
+
+}
|
unix: return error if strlen(socket path) > sizeof sun_path?
https://github.com/nodejs/node/issues/48316 made me realize that:
1. libuv currently truncates long paths, but
2. when #4030 lands, it returns `UV_EINVAL` when the path is too long
It's an unintentional change (because I thought it already worked that way) so I'd like to discuss:
1. whether to keep or back out that change, and
2. if and how to harmonize with src/win/pipe.c. MSDN says the "entire pipe name string can be up to 256 characters long" (characters, not bytes) but I don't know if CreateNamedPipeW() returns an error if it's longer than that. Easy to enforce ourselves though, I think:
```diff
diff --git a/src/win/pipe.c b/src/win/pipe.c
index a3daa3b7..f1634cf2 100644
--- a/src/win/pipe.c
+++ b/src/win/pipe.c
@@ -722,6 +722,11 @@ int uv_pipe_bind2(uv_pipe_t* handle,
return UV_EINVAL;
}
+ nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR);
+ if (nameSize > 256 * sizeof(WCHAR)) {
+ return UV_EINVAL;
+ }
+
if (handle->flags & UV_HANDLE_BOUND) {
return UV_EINVAL;
}
@@ -749,7 +754,6 @@ int uv_pipe_bind2(uv_pipe_t* handle,
}
/* Convert name to UTF16. */
- nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR);
handle->name = uv__malloc(nameSize);
if (!handle->name) {
uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
```
|
Both uv_pipe_bind() and uv_pipe_connect() document the fact that libuv truncates the path:
> Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
So I suppose that speaks in favor of backing out the change but we should probably address the Windows discrepancy.
|
Both uv_pipe_bind() and uv_pipe_connect() document the fact that libuv truncates the path:
> Paths on Unix get truncated to ``sizeof(sockaddr_un.sun_path)`` bytes, typically between
So I suppose that speaks in favor of backing out the change but we should probably address the Windows discrepancy.
|
[
"https://github.com/libuv/libuv/commit/ee357219db8dab3c74725c53c15bd5e77386d231",
"https://github.com/libuv/libuv/commit/21b219698b59ebbb9d7978d7a633610faa7306e1"
] | 2023-06-04T21:03:43
|
0.7
|
C
|
#!/usr/bin/env bash
set -e
cd /testbed
git reset --hard b9b6db052b82dd0a429091238181195ec785ac0b
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
cmake \
ninja-build \
autotools-dev \
autoconf \
automake \
libtool \
libssl-dev \
zlib1g-dev \
libffi-dev \
git \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# Not needed for libuv
# ========================================================
# 5️⃣ Build Attempts
# ========================================================
# Configure CMake with tests enabled
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
|| true
# Build only test targets
cmake --build build --target uv_run_tests --target uv_run_tests_a || true
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] CMake version:"
cmake --version || true
echo "[INFO] Ninja version:"
ninja --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/bin/bash
set -euxo pipefail
# === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export UV_TEST_TIMEOUT_MULTIPLIER=2
cd /testbed
git config --global --add safe.directory /testbed
# === Pre-Patch Info ===
echo "=== Repository Status Before Patch ==="
git status
git show --stat b9b6db052b82dd0a429091238181195ec785ac0b
cmake --version
ctest --version
if [ -d build ]; then
(cd build && cmake --build . --target help) || true
fi
# === Reset patched test files to clean state ===
echo "=== Resetting test-list.h and test-pipe-bind-error.c to clean state ==="
git checkout b9b6db052b82dd0a429091238181195ec785ac0b -- test/test-list.h test/test-pipe-bind-error.c || true
# === Apply Test Patch ===
# [IMPORTANT NOTE]: The [test patch content] between EOF_114329324912 below is a fixed placeholder.
# DO NOT modify/delete it. The actual Git Patch content will be manually replaced in subsequent processes.
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/test/test-list.h b/test/test-list.h
index 6da7812360a..b2c88170051 100644
--- a/test/test-list.h
+++ b/test/test-list.h
@@ -198,6 +198,7 @@ TEST_DECLARE (pipe_connect_close_multiple)
TEST_DECLARE (pipe_connect_multiple)
TEST_DECLARE (pipe_listen_without_bind)
TEST_DECLARE (pipe_bind_or_listen_error_after_close)
+TEST_DECLARE (pipe_overlong_path)
TEST_DECLARE (pipe_connect_bad_name)
TEST_DECLARE (pipe_connect_to_file)
TEST_DECLARE (pipe_connect_on_prepare)
@@ -799,6 +800,7 @@ TASK_LIST_START
TEST_ENTRY (pipe_connect_multiple)
TEST_ENTRY (pipe_listen_without_bind)
TEST_ENTRY (pipe_bind_or_listen_error_after_close)
+ TEST_ENTRY (pipe_overlong_path)
TEST_ENTRY (pipe_getsockname)
TEST_ENTRY (pipe_getsockname_abstract)
TEST_ENTRY (pipe_getsockname_blocking)
diff --git a/test/test-pipe-bind-error.c b/test/test-pipe-bind-error.c
index 88ece6ba5d8..f8626302a1d 100644
--- a/test/test-pipe-bind-error.c
+++ b/test/test-pipe-bind-error.c
@@ -153,3 +153,27 @@ TEST_IMPL(pipe_bind_or_listen_error_after_close) {
MAKE_VALGRIND_HAPPY(uv_default_loop());
return 0;
}
+
+TEST_IMPL(pipe_overlong_path) {
+ char path[512];
+ uv_pipe_t pipe;
+ uv_connect_t req;
+
+ memset(path, '@', sizeof(path));
+ ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe, 0));
+ ASSERT_EQ(UV_EINVAL,
+ uv_pipe_bind2(&pipe, path, sizeof(path), UV_PIPE_NO_TRUNCATE));
+ ASSERT_EQ(UV_EINVAL,
+ uv_pipe_connect2(&req,
+ &pipe,
+ path,
+ sizeof(path),
+ UV_PIPE_NO_TRUNCATE,
+ (uv_connect_cb) abort));
+ uv_close((uv_handle_t*) &pipe, NULL);
+ ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+
+ MAKE_VALGRIND_HAPPY(uv_default_loop());
+ return 0;
+
+}
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD || true
# === Ensure non-root user exists ===
if ! id -u testuser &>/dev/null; then
useradd -m -s /bin/bash testuser
fi
chown -R testuser:testuser /testbed
# === Configure and Build uv_run_tests_a target ===
echo "=== Configure and build uv_run_tests_a ==="
rm -rf build/ && mkdir build && cd build
cmake -G Ninja ..
cmake --build . --target uv_run_tests_a
cd ..
# === Run the SINGLE added test via uv_run_tests_a binary (pipe_overlong_path) ===
echo "=== Running pipe_overlong_path test directly via uv_run_tests_a ==="
su - testuser -c "cd /testbed/build && ./uv_run_tests_a pipe_overlong_path" | tee /tmp/test_pipe_overlong_path.log
rc_pipe=$?
# Capture Exit Code
final_rc=0
if [ "$rc_pipe" -ne 0 ]; then
final_rc=$rc_pipe
fi
# === Restore Test Files ===
cd /testbed
echo "=== Restoring Repository State ==="
git checkout b9b6db052b82dd0a429091238181195ec785ac0b -- test/test-list.h test/test-pipe-bind-error.c || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:libuv-libuv-pr-4040
|
libgit2/libgit2
| 5,360
|
libgit2__libgit2-5360
|
[
5357
] |
dea5ce3df6f62a490b3307edd06958eddc5e90f4
|
diff --git a/src/refs.c b/src/refs.c
index 29dd1bdebe0..633d83abdde 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -145,6 +145,11 @@ int git_reference_delete(git_reference *ref)
const git_oid *old_id = NULL;
const char *old_target = NULL;
+ if (!strcmp(ref->name, "HEAD")) {
+ git_error_set(GIT_ERROR_REFERENCE, "cannot delete HEAD");
+ return GIT_ERROR;
+ }
+
if (ref->type == GIT_REFERENCE_DIRECT)
old_id = &ref->target.oid;
else
|
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index 926cc6af0fc..72f8bf42cca 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -620,6 +620,7 @@ void test_iterator_workdir__filesystem2(void)
"heads/subtrees",
"heads/test",
"heads/testrepo-worktree",
+ "symref",
"tags/e90810b",
"tags/foo/bar",
"tags/foo/foo/bar",
@@ -632,7 +633,7 @@ void test_iterator_workdir__filesystem2(void)
cl_git_pass(git_iterator_for_filesystem(
&i, "testrepo/.git/refs", NULL));
- expect_iterator_items(i, 16, expect_base, 16, expect_base);
+ expect_iterator_items(i, 17, expect_base, 17, expect_base);
git_iterator_free(i);
}
diff --git a/tests/refs/delete.c b/tests/refs/delete.c
index a3344964124..3e99a7959b7 100644
--- a/tests/refs/delete.c
+++ b/tests/refs/delete.c
@@ -105,3 +105,14 @@ void test_refs_delete__remove(void)
cl_git_fail(git_reference_lookup(&ref, g_repo, packed_test_head_name));
}
+
+void test_refs_delete__head(void)
+{
+ git_reference *ref;
+
+ /* Check that it is not possible to delete HEAD */
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
+ cl_git_fail(git_reference_delete(ref));
+ git_reference_free(ref);
+}
diff --git a/tests/refs/list.c b/tests/refs/list.c
index 3e8c82c94b6..725d38161fe 100644
--- a/tests/refs/list.c
+++ b/tests/refs/list.c
@@ -36,7 +36,7 @@ void test_refs_list__all(void)
/* We have exactly 12 refs in total if we include the packed ones:
* there is a reference that exists both in the packfile and as
* loose, but we only list it once */
- cl_assert_equal_i((int)ref_list.count, 18);
+ cl_assert_equal_i((int)ref_list.count, 19);
git_strarray_free(&ref_list);
}
@@ -51,7 +51,7 @@ void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_exten
"144344043ba4d4a405da03de3844aa829ae8be0e\n");
cl_git_pass(git_reference_list(&ref_list, g_repo));
- cl_assert_equal_i((int)ref_list.count, 18);
+ cl_assert_equal_i((int)ref_list.count, 19);
git_strarray_free(&ref_list);
}
diff --git a/tests/refs/races.c b/tests/refs/races.c
index fbecf4a75ee..04a1bc17b3b 100644
--- a/tests/refs/races.c
+++ b/tests/refs/races.c
@@ -74,8 +74,8 @@ void test_refs_races__delete(void)
git_reference_free(ref);
/* We cannot delete a symbolic value that doesn't match */
- cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
- cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "HEAD", other_refname, 1, NULL, refname));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+ cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "refs/symref", other_refname, 1, NULL, refname));
cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
git_reference_free(ref);
@@ -131,19 +131,19 @@ void test_refs_races__switch_symbolic_to_oid(void)
git_oid_fromstr(&other_id, other_commit_id);
/* Removing a symbolic ref when it's currently direct should fail */
- cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
- cl_git_pass(git_reference_create(&ref2, g_repo, "HEAD", &id, 1, NULL));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+ cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL));
cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
git_reference_free(ref);
git_reference_free(ref2);
- cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "HEAD", refname, 1, NULL));
+ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "refs/symref", refname, 1, NULL));
git_reference_free(ref);
/* Updating a symbolic ref when it's currently direct should fail */
- cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
- cl_git_pass(git_reference_create(&ref2, g_repo, "HEAD", &id, 1, NULL));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+ cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL));
cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL));
git_reference_free(ref);
diff --git a/tests/resources/testrepo/.gitted/refs/symref b/tests/resources/testrepo/.gitted/refs/symref
new file mode 100644
index 00000000000..cb089cd89a7
--- /dev/null
+++ b/tests/resources/testrepo/.gitted/refs/symref
@@ -0,0 +1,1 @@
+ref: refs/heads/master
|
reject attempts to delete HEAD
I just wrote some buggy code in which I accidentally deleted HEAD, rather than its symbolic target. However, HEAD is required to exist.
Given that deleting HEAD is not a legitimate git operation (it turns a git dir into a non-git dit), perhaps libgit2 could prevent this by returning an error when `git_reference_delete` is called on HEAD. I'm not sure what error code/class would be the right one, though.
Sound ok?
|
Yeah, deleting HEAD is no good. We should prevent this. Here's what git says when you try to `symbolic-ref --delete HEAD`:
> deleting 'HEAD' is not allowed
I think the `GIT_ERROR_REFERENCE` is appropriate here.
|
Yeah, deleting HEAD is no good. We should prevent this. Here's what git says when you try to `symbolic-ref --delete HEAD`:
> deleting 'HEAD' is not allowed
I think the `GIT_ERROR_REFERENCE` is appropriate here.
|
[
"https://github.com/libgit2/libgit2/commit/852c83ee44d6d53137f12443c9f82f70bbabbadc"
] | 2020-01-15T21:57:11
|
0.99
|
C
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
# Retry apt-get update and install to handle transient mirror issues
for i in 1 2 3; do
apt-get update && break || { echo "apt-get update failed, retrying in 15s..."; sleep 15; }
done
apt-get install -y --no-install-recommends \
build-essential ninja-build cmake python3 pkg-config \
libssl-dev zlib1g-dev libssh2-1-dev libcurl4-gnutls-dev libffi-dev valgrind openssh-server \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# No conan/vcpkg/bazel required for libgit2
# ========================================================
# 5️⃣ Build Attempts (test-focused only)
# ========================================================
# Configure with tests enabled (no valgrind flags to avoid OpenSSL issues)
echo "[INFO] Configuring CMake..."
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-Wno-error=deprecated-declarations -Wno-error=format-overflow -Wno-error=stringop-truncation -Wno-error=maybe-uninitialized" \
-DBUILD_CLAR=ON \
-DENABLE_WERROR=OFF \
-DTHREADSAFE=ON \
-DUSE_HTTPS=ON \
-DUSE_SSH=ON
echo "[INFO] Building libgit2_clar test executable..."
cmake --build build --target libgit2_clar
echo "[INFO] Verifying libgit2_clar binary exists and is executable..."
test -x build/libgit2_clar || { echo "[FATAL] libgit2_clar not found or not executable"; exit 1; }
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] CMake version:"
cmake --version
echo "[INFO] Ninja version:"
ninja --version
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential ninja-build cmake python3 pkg-config \
libssl-dev zlib1g-dev libssh2-1-dev libffi-dev valgrind \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (none required for this project)
# ========================================================
# No conan/vcpkg/bazel needed for libgit2
# ========================================================
# 5️⃣ Build Attempts (test-focused only)
# ========================================================
# Configure with tests enabled
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_CLAR=ON \
-DTHREADSAFE=ON \
-DUSE_HTTPS=ON \
-DUSE_SSH=ON || true
# Build only the test executable
cmake --build build --target libgit2_clar || true
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] CMake version:"
cmake --version || true
echo "[INFO] Ninja version:"
ninja --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/bin/bash
set -uxo pipefail
# === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
cd /testbed
git config --global --add safe.directory /testbed
# === Pre-Patch Info ===
echo "=== Repository Status Before Patch ==="
git status
git show --stat
# === Reset Test Files ===
echo "=== Resetting patched test files to clean state ==="
git checkout dea5ce3df6f62a490b3307edd06958eddc5e90f4 -- \
tests/iterator/workdir.c \
tests/refs/delete.c \
tests/refs/list.c \
tests/refs/races.c \
tests/resources/testrepo/.gitted/refs/symref || true
# === Apply Patch ===
# [IMPORTANT NOTE]: The [test patch content] between EOF_114329324912 below is a fixed placeholder.
# DO NOT modify/delete it. The actual Git Patch content will be manually replaced in subsequent processes.
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index 926cc6af0fc..72f8bf42cca 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -620,6 +620,7 @@ void test_iterator_workdir__filesystem2(void)
"heads/subtrees",
"heads/test",
"heads/testrepo-worktree",
+ "symref",
"tags/e90810b",
"tags/foo/bar",
"tags/foo/foo/bar",
@@ -632,7 +633,7 @@ void test_iterator_workdir__filesystem2(void)
cl_git_pass(git_iterator_for_filesystem(
&i, "testrepo/.git/refs", NULL));
- expect_iterator_items(i, 16, expect_base, 16, expect_base);
+ expect_iterator_items(i, 17, expect_base, 17, expect_base);
git_iterator_free(i);
}
diff --git a/tests/refs/delete.c b/tests/refs/delete.c
index a3344964124..3e99a7959b7 100644
--- a/tests/refs/delete.c
+++ b/tests/refs/delete.c
@@ -105,3 +105,14 @@ void test_refs_delete__remove(void)
cl_git_fail(git_reference_lookup(&ref, g_repo, packed_test_head_name));
}
+
+void test_refs_delete__head(void)
+{
+ git_reference *ref;
+
+ /* Check that it is not possible to delete HEAD */
+
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
+ cl_git_fail(git_reference_delete(ref));
+ git_reference_free(ref);
+}
diff --git a/tests/refs/list.c b/tests/refs/list.c
index 3e8c82c94b6..725d38161fe 100644
--- a/tests/refs/list.c
+++ b/tests/refs/list.c
@@ -36,7 +36,7 @@ void test_refs_list__all(void)
/* We have exactly 12 refs in total if we include the packed ones:
* there is a reference that exists both in the packfile and as
* loose, but we only list it once */
- cl_assert_equal_i((int)ref_list.count, 18);
+ cl_assert_equal_i((int)ref_list.count, 19);
git_strarray_free(&ref_list);
}
@@ -51,7 +51,7 @@ void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_exten
"144344043ba4d4a405da03de3844aa829ae8be0e\n");
cl_git_pass(git_reference_list(&ref_list, g_repo));
- cl_assert_equal_i((int)ref_list.count, 18);
+ cl_assert_equal_i((int)ref_list.count, 19);
git_strarray_free(&ref_list);
}
diff --git a/tests/refs/races.c b/tests/refs/races.c
index fbecf4a75ee..04a1bc17b3b 100644
--- a/tests/refs/races.c
+++ b/tests/refs/races.c
@@ -74,8 +74,8 @@ void test_refs_races__delete(void)
git_reference_free(ref);
/* We cannot delete a symbolic value that doesn't match */
- cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
- cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "HEAD", other_refname, 1, NULL, refname));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+ cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "refs/symref", other_refname, 1, NULL, refname));
cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
git_reference_free(ref);
@@ -131,19 +131,19 @@ void test_refs_races__switch_symbolic_to_oid(void)
git_oid_fromstr(&other_id, other_commit_id);
/* Removing a symbolic ref when it's currently direct should fail */
- cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
- cl_git_pass(git_reference_create(&ref2, g_repo, "HEAD", &id, 1, NULL));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+ cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL));
cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref));
git_reference_free(ref);
git_reference_free(ref2);
- cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "HEAD", refname, 1, NULL));
+ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "refs/symref", refname, 1, NULL));
git_reference_free(ref);
/* Updating a symbolic ref when it's currently direct should fail */
- cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
- cl_git_pass(git_reference_create(&ref2, g_repo, "HEAD", &id, 1, NULL));
+ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref"));
+ cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL));
cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL));
git_reference_free(ref);
diff --git a/tests/resources/testrepo/.gitted/refs/symref b/tests/resources/testrepo/.gitted/refs/symref
new file mode 100644
index 00000000000..cb089cd89a7
--- /dev/null
+++ b/tests/resources/testrepo/.gitted/refs/symref
@@ -0,0 +1,1 @@
+ref: refs/heads/master
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD
# === Regenerate test suite and rebuild libgit2_clar ===
echo "=== Regenerating test suite and rebuilding libgit2_clar ==="
cd build
python3 ../tests/generate.py -o . -f .
cmake --build . --target libgit2_clar
# === Run target tests directly via libgit2_clar ===
echo "=== Execute target tests via libgit2_clar ==="
./libgit2_clar -siterator::workdir -srefs::delete -srefs::list -srefs::races -v -v | tee /tmp/test_result.log
rc_test=${PIPESTATUS[0]}
# === Compute Final Exit Code ===
final_rc=0
if [ "$rc_test" -ne 0 ]; then
final_rc=$rc_test
fi
# === Restore Repo ===
cd /testbed
echo "=== Restoring Repository State ==="
git checkout dea5ce3df6f62a490b3307edd06958eddc5e90f4 -- \
tests/iterator/workdir.c \
tests/refs/delete.c \
tests/refs/list.c \
tests/refs/races.c \
tests/resources/testrepo/.gitted/refs/symref || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:libgit2-libgit2-pr-5360
|
fluent/fluent-bit
| 4,510
|
fluent__fluent-bit-4510
|
[
4509
] |
b3857f4961216b87e61dc49c388ac99f605aed39
|
diff --git a/src/flb_filter.c b/src/flb_filter.c
index 3afbadfdfd6..43af1e14731 100644
--- a/src/flb_filter.c
+++ b/src/flb_filter.c
@@ -316,7 +316,7 @@ struct flb_filter_instance *flb_filter_new(struct flb_config *config,
mk_list_foreach(head, &config->filter_plugins) {
plugin = mk_list_entry(head, struct flb_filter_plugin, _head);
- if (strcmp(plugin->name, filter) == 0) {
+ if (strcasecmp(plugin->name, filter) == 0) {
break;
}
plugin = NULL;
|
diff --git a/tests/runtime/filter_stdout.c b/tests/runtime/filter_stdout.c
index 886faf8a193..8d75c155a6e 100644
--- a/tests/runtime/filter_stdout.c
+++ b/tests/runtime/filter_stdout.c
@@ -7,13 +7,36 @@
/* Test functions */
void flb_test_filter_stdout_json_multiple(void);
+void flb_test_filter_stdout_case_insensitive(void);
/* Test list */
TEST_LIST = {
{"json_multiple", flb_test_filter_stdout_json_multiple },
+ {"case_insensitive_name", flb_test_filter_stdout_case_insensitive},
{NULL, NULL}
};
+/*
+ * This test case is to check if fluent-bit allows case-insensitive plugin name.
+ * This test is not unique to filter_stdout, but we test here :) ,
+ */
+
+void flb_test_filter_stdout_case_insensitive(void)
+{
+ int filter_ffd;
+ char filter_name[] = "stDoUt";
+ flb_ctx_t *ctx;
+
+ ctx = flb_create();
+
+ filter_ffd = flb_filter(ctx, (char *) filter_name, NULL);
+ if(!TEST_CHECK(filter_ffd >= 0)) {
+ TEST_MSG("%s should be valid\n", filter_name);
+ }
+
+ flb_destroy(ctx);
+}
+
void flb_test_filter_stdout_json_multiple(void)
{
int i;
|
Filter plugin name is case sensitive
## Bug Report
**Describe the bug**
<!--- A clear and concise description of what the bug is. -->
Fluent-bit allows case-sensitive filter plugin name.
e.g. `recOrd_ModiFier` is not allowed.
On the other hand, fluent-bit allows case-insensitive input/output plugin name.
**To Reproduce**
- Rubular link if applicable:None
- Example log message if applicable: None
- Steps to reproduce the problem:`fluent-bit -i cpu -o null -F Stdout -m '*'`
**Expected behavior**
<!--- A clear and concise description of what you expected to happen. -->
Allow case-insensitive filter plugin name.
**Screenshots**
<!--- If applicable, add screenshots to help explain your problem. -->
**Your Environment**
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: v1.8.11
* Configuration: None
* Environment name and version (e.g. Kubernetes? What version?): Ubuntu 20.04
* Server type and version: Ubuntu 20.04
* Operating System and version: Ubuntu 20.04
* Filters and plugins: stdout
**Additional context**
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
Below config is valid.
It means `mEm` and `stDOut` are allowed.
```
[INPUT]
Name mEm
[OUTPUT]
Name stDOut
Match *
```
|
[
"https://github.com/fluent/fluent-bit/commit/545c70255240591e8a5540220513bf5dd45d6da5",
"https://github.com/fluent/fluent-bit/commit/417f5a64049c6ba3d2791dc072b2299b3fe102e6"
] | 2021-12-22T07:41:30
|
1.8
|
C
|
#!/usr/bin/env bash
set -e
cd /testbed
git reset --hard b3857f4961216b87e61dc49c388ac99f605aed39
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
curl \
ca-certificates \
libssl-dev \
libsasl2-dev \
pkg-config \
libsystemd-dev \
zlib1g-dev \
libpq-dev \
postgresql-server-dev-all \
flex \
bison \
libyaml-dev \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
# Force Unix Makefiles generator to avoid Ninja $-escape issues
export CMAKE_GENERATOR="Unix Makefiles"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# No external package managers required for Fluent Bit build
# ========================================================
# 5️⃣ Build Attempts (Test–Focused Mode)
# ========================================================
# Configure CMake with test flags enabled (fail fast on error)
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DFLB_TESTS_INTERNAL=On \
-DFLB_TESTS_RUNTIME=On \
-DFLB_STREAM_PROCESSOR=On
# Full project build to ensure all dependencies (LuaJIT etc.) are compiled
cmake --build build -- -j$(nproc)
# Build only stream processor test target (fail fast on error)
cmake --build build --target flb-it-stream_processor -- -j$(nproc)
# Wait for the binary to be present before continuing
while [ ! -f build/bin/flb-it-stream_processor ]; do
sleep 2
done
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] CMake version:"
cmake --version || true
echo "[INFO] Make version:"
make --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -euxo pipefail
### === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
cd /testbed
git config --global --add safe.directory /testbed
### === Pre-Patch Info ===
echo "=== Repository Status Before Patch ==="
git status
git show --stat
cmake --version
ctest --version
if [ -d build ]; then
(cd build && cmake --build . --target help) || true
fi
### === Clean Reset Target Test File ===
echo "=== Resetting Target Test File to Clean State ==="
git checkout b3857f4961216b87e61dc49c388ac99f605aed39 -- tests/runtime/filter_stdout.c || true
### === Apply Test Patch ===
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/tests/runtime/filter_stdout.c b/tests/runtime/filter_stdout.c
index 886faf8a193..8d75c155a6e 100644
--- a/tests/runtime/filter_stdout.c
+++ b/tests/runtime/filter_stdout.c
@@ -7,13 +7,36 @@
/* Test functions */
void flb_test_filter_stdout_json_multiple(void);
+void flb_test_filter_stdout_case_insensitive(void);
/* Test list */
TEST_LIST = {
{"json_multiple", flb_test_filter_stdout_json_multiple },
+ {"case_insensitive_name", flb_test_filter_stdout_case_insensitive},
{NULL, NULL}
};
+/*
+ * This test case is to check if fluent-bit allows case-insensitive plugin name.
+ * This test is not unique to filter_stdout, but we test here :) ,
+ */
+
+void flb_test_filter_stdout_case_insensitive(void)
+{
+ int filter_ffd;
+ char filter_name[] = "stDoUt";
+ flb_ctx_t *ctx;
+
+ ctx = flb_create();
+
+ filter_ffd = flb_filter(ctx, (char *) filter_name, NULL);
+ if(!TEST_CHECK(filter_ffd >= 0)) {
+ TEST_MSG("%s should be valid\n", filter_name);
+ }
+
+ flb_destroy(ctx);
+}
+
void flb_test_filter_stdout_json_multiple(void)
{
int i;
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD
### === Configure Build ===
echo "=== Configuring Build ==="
mkdir -p build
cd build
cmake -DFLB_TESTS_RUNTIME=On .. || true
### === Detect Test Targets and Build Only Needed Ones ===
echo "=== Detecting Test Targets and Building Only Needed Ones ==="
ctest -N -V | tee ctest_list.txt || true
grep -iE "filter_stdout" ctest_list.txt | tee filter_stdout_tests.txt || true
if [ -s filter_stdout_tests.txt ]; then
echo "Found filter_stdout related tests, building only test targets"
cmake --build . --target flb-test-runtime || \
cmake --build . --target $(cmake --build . --target help | grep -iE "test" | awk '{print $1}' | tr '\n' ' ') || \
cmake --build . || true
else
echo "No specific test targets mapped, building project"
cmake --build . || true
fi
### === Run Target Test ===
echo "=== Running Target Test: filter_stdout ==="
ctest -V -j$(nproc) -R filter_stdout --output-on-failure
rc_filter_stdout=$?
### === Compute Final Exit Code ===
final_rc=$rc_filter_stdout
### === Restore Target Test File ===
cd /testbed
echo "=== Restoring Repository State ==="
git checkout b3857f4961216b87e61dc49c388ac99f605aed39 -- tests/runtime/filter_stdout.c || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:fluent-fluent-bit-pr-4510
|
||
cc65/cc65
| 1,842
|
cc65__cc65-1842
|
[
1812
] |
168f42bb836ba940ec7aedaf76356d3facf7d595
|
diff --git a/src/cc65/compile.c b/src/cc65/compile.c
index d6069e9143..11dcbced0b 100644
--- a/src/cc65/compile.c
+++ b/src/cc65/compile.c
@@ -396,9 +396,10 @@ void Compile (const char* FileName)
DefineNumericMacro ("__EAGERLY_INLINE_FUNCS__", 1);
}
- /* Placeholders for __FILE__ and __LINE__ macros */
+ /* Placeholders for __FILE__, __LINE__ and __COUNTER__ macros */
DefineTextMacro ("__FILE__", "");
DefineTextMacro ("__LINE__", "");
+ DefineTextMacro ("__COUNTER__", "");
/* __TIME__ and __DATE__ macros */
Time = time (0);
diff --git a/src/cc65/input.c b/src/cc65/input.c
index c6037091f6..0e8fc32764 100644
--- a/src/cc65/input.c
+++ b/src/cc65/input.c
@@ -106,6 +106,9 @@ static Collection AFiles = STATIC_COLLECTION_INITIALIZER;
/* Input stack used when preprocessing. */
static Collection InputStack = STATIC_COLLECTION_INITIALIZER;
+/* Counter for the __COUNTER__ macro */
+static unsigned MainFileCounter;
+
/*****************************************************************************/
@@ -280,6 +283,9 @@ void OpenMainFile (const char* Name)
** the main file before the first line is read.
*/
UpdateLineInfo (MainFile->Input, MainFile->Line, Line);
+
+ /* Initialize the __COUNTER__ counter */
+ MainFileCounter = 0;
}
@@ -658,6 +664,14 @@ void SetCurrentFilename (const char* Name)
+unsigned GetCurrentCounter (void)
+/* Return the counter number in the current input file */
+{
+ return MainFileCounter++;
+}
+
+
+
static void WriteEscaped (FILE* F, const char* Name)
/* Write a file name to a dependency file escaping spaces */
{
diff --git a/src/cc65/input.h b/src/cc65/input.h
index cf529e169e..fb24bbaa8d 100644
--- a/src/cc65/input.h
+++ b/src/cc65/input.h
@@ -128,6 +128,9 @@ void SetCurrentLine (unsigned LineNum);
void SetCurrentFilename (const char* Name);
/* Set the presumed name of the current input file */
+unsigned GetCurrentCounter (void);
+/* Return the counter number in the current input file */
+
void CreateDependencies (void);
/* Create dependency files requested by the user */
diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c
index 91aa503fcc..020df011a3 100644
--- a/src/cc65/preproc.c
+++ b/src/cc65/preproc.c
@@ -1630,9 +1630,15 @@ static int ParseDirectives (unsigned ModeFlags)
void HandleSpecialMacro (Macro* M, const char* Name)
-/* Handle special mandatory macros */
+/* Handle special "magic" macros that may change */
{
- if (strcmp (Name, "__LINE__") == 0) {
+ if (strcmp (Name, "__COUNTER__") == 0) {
+ /* Replace __COUNTER__ with the current counter number */
+ if (IS_Get (&Standard) < STD_CC65) {
+ PPWarning ("__COUNTER__ is a cc65 extension");
+ }
+ SB_Printf (&M->Replacement, "%u", GetCurrentCounter ());
+ } else if (strcmp (Name, "__LINE__") == 0) {
/* Replace __LINE__ with the current line number */
SB_Printf (&M->Replacement, "%u", GetCurrentLine ());
} else if (strcmp (Name, "__FILE__") == 0) {
diff --git a/src/cc65/preproc.h b/src/cc65/preproc.h
index 2143dde98b..a4619e545e 100644
--- a/src/cc65/preproc.h
+++ b/src/cc65/preproc.h
@@ -91,7 +91,7 @@ void DonePreprocess (void);
/* Done with preprocessor */
void HandleSpecialMacro (Macro* M, const char* Name);
-/* Handle special mandatory macros */
+/* Handle special "magic" macros that may change */
|
diff --git a/test/val/counter.c b/test/val/counter.c
new file mode 100644
index 0000000000..4efa18359e
--- /dev/null
+++ b/test/val/counter.c
@@ -0,0 +1,60 @@
+/* Tests for predefined macro __COUNTER__ */
+
+#include <stdio.h>
+
+static int failures = 0;
+
+#if __COUNTER__ /* 0 */
+# error __COUNTER__ should begin at 0!
+#elif __COUNTER__ == 1 /* 1 */
+# define CONCAT(a,b) CONCAT_impl_(a,b)
+# define CONCAT_impl_(a,b) a##b
+#endif
+
+#line 42 "What is the answer?"
+int CONCAT(ident,__COUNTER__)[0+__LINE__] = {__LINE__}, CONCAT(ident,__COUNTER__)[0+__LINE__] = {__LINE__}; /* 2,3 */
+
+#if __COUNTER__ == 4 ? 1 || __COUNTER__ : 0 && __COUNTER__ /* 4,5,6 */
+_Static_assert(__COUNTER__ == 7, "__COUNTER__ should be 7 here!"); /* 7 */
+# define GET_COUNTER() __COUNTER__
+# define GET_LINE() __LINE__
+# warning __COUNTER__ in #warning is just output as text and will never increase!
+#else
+# if __COUNTER__ + __COUNTER__ + __COUNTER__ /* Skipped as a whole and not incrementing */
+# endif
+# error __COUNTER__ is skipped along with the whole #error line and will never increase anyways! */
+#endif
+
+#include "counter.h"
+#include "counter.h"
+
+_Static_assert(GET_COUNTER() == 10, "__COUNTER__ should be 10 here!"); /* 10 */
+
+int main(void)
+{
+ if (ident2[0] != 42) {
+ printf("Expected ident2[0]: %s, got: %s\n", 42, ident2[0]);
+ ++failures;
+ }
+
+ if (ident3[0] != 42) {
+ printf("Expected ident3[0]: %s, got: %s\n", 42, ident3[0]);
+ ++failures;
+ }
+
+ if (ident8 != 8) {
+ printf("Expected ident8: %s, got: %s\n", 8, ident8);
+ ++failures;
+ }
+
+ if (ident9 != 9) {
+ printf("Expected ident9: %s, got: %s\n", 9, ident9);
+ ++failures;
+ }
+
+ if (failures != 0) {
+ printf("Failures: %d\n", failures);
+ }
+
+ return failures;
+}
diff --git a/test/val/counter.h b/test/val/counter.h
new file mode 100644
index 0000000000..b6b5a98e2c
--- /dev/null
+++ b/test/val/counter.h
@@ -0,0 +1,4 @@
+/* Tests for predefined macro __COUNTER__ */
+
+#line GET_COUNTER() /* 1st: 8; 2nd: 9 */
+int CONCAT(ident,GET_LINE()) = GET_LINE();
|
[cc65] Extension: predefined macro __COUNTER__
`__COUNTER__` is a commonly supported predefined macro in many major C compilers (eg. [GCC](https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html)), which has well-established and understood behavior (except when involved with precompiled headers, maybe) and been used in practice.
For those who might be unfamiliar with it: `__COUNTER__` is a "magical" macro that evaluates to an integer literal whose value is starting from 0 and increased by one every time it is found in a source code text. It is a convenient way to provide a unqinue identifier in conjunctions with the `##` operator.
Is this feature desired for cc65?
|
Yes, I use WDMs with unique signature bytes at the beginning of each proc I am debugging to tell them apart. It would be nice if the signature bytes could be generated automatically at assemble-time and some kind of map back to proc names were generated.
On second thought, having a `__LINE__` predefined macros would probably be easier to work with. Two adjacent WDMs would be enough for small projects.
we HAVE __LINE__, no?
It looks like cc65 has `__LINE__` but ca65 does not.
> we HAVE **LINE**, no?
Actually, I came up with this topic when I was working on a fix for #1573. `__COUNTER__` allows to get multiple unique identifiers on the same line more easily than `__LINE__` does.
feel free to implement this :) and please add a test - this sounds like something that could be easily screwed up in a non trivial situation.
|
[
"https://github.com/cc65/cc65/commit/43d2fd2a960c1fb40c740eb057a34329f8d54075"
] | 2022-08-27T05:07:36
|
2.19
|
C
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages) with retries
# ========================================================
for i in {1..3}; do
apt-get update && break || sleep 5
done
for i in {1..3}; do
apt-get install -y --no-install-recommends \
build-essential \
libc6-dev \
pkg-config \
linuxdoc-tools \
linuxdoc-tools-info \
binutils-mingw-w64-i686 \
gcc-mingw-w64-i686 \
sshpass \
&& break || sleep 5
done || { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/testbed/bin:/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# cc65 uses no external package managers; skip
# ========================================================
# 5️⃣ Build Attempts (test-focused)
# ========================================================
# Only install OS dependencies and prepare the environment.
# The actual patched cc65 toolchain rebuild will be done in the eval script
# after the patch is applied, ensuring __COUNTER__ support.
echo "[INFO] Environment prepared. Full cc65 rebuild must occur after patch application."
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] Make version:"
make --version
echo "[INFO] ar version:"
ar --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
libc6-dev \
pkg-config \
linuxdoc-tools \
linuxdoc-tools-info \
binutils-mingw-w64-i686 \
gcc-mingw-w64-i686 \
sshpass \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
export CMAKE_GENERATOR="Ninja"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# cc65 uses no external package managers; skip
# ========================================================
# 5️⃣ Build Attempts (test-focused)
# ========================================================
# Build cc65 tools and required runtime libraries
make bin USER_CFLAGS="-Wno-format-overflow" && \
make lib QUIET=1 || { echo "[FATAL] cc65 build failed"; exit 1; }
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] Make version:"
make --version
echo "[INFO] ar version:"
ar --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -uxo pipefail
# === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
cd /testbed
git config --global --add safe.directory /testbed
# === Repository Status Before Patch ===
echo "=== Repository Status Before Patch ==="
git status
git show --stat
# === Ensure Clean State ===
echo "=== Resetting Test Files to Clean State ==="
git checkout 168f42bb836ba940ec7aedaf76356d3facf7d595 \
test/val/counter.c \
test/val/counter.h || true
# === Apply Test Patch ===
# [IMPORTANT NOTE]: The [test patch content] between EOF_114329324912 below is a fixed placeholder.
# DO NOT modify/delete it. The actual Git Patch content will be manually replaced in subsequent processes.
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/test/val/counter.c b/test/val/counter.c
new file mode 100644
index 0000000000..4efa18359e
--- /dev/null
+++ b/test/val/counter.c
@@ -0,0 +1,60 @@
+/* Tests for predefined macro __COUNTER__ */
+
+#include <stdio.h>
+
+static int failures = 0;
+
+#if __COUNTER__ /* 0 */
+# error __COUNTER__ should begin at 0!
+#elif __COUNTER__ == 1 /* 1 */
+# define CONCAT(a,b) CONCAT_impl_(a,b)
+# define CONCAT_impl_(a,b) a##b
+#endif
+
+#line 42 "What is the answer?"
+int CONCAT(ident,__COUNTER__)[0+__LINE__] = {__LINE__}, CONCAT(ident,__COUNTER__)[0+__LINE__] = {__LINE__}; /* 2,3 */
+
+#if __COUNTER__ == 4 ? 1 || __COUNTER__ : 0 && __COUNTER__ /* 4,5,6 */
+_Static_assert(__COUNTER__ == 7, "__COUNTER__ should be 7 here!"); /* 7 */
+# define GET_COUNTER() __COUNTER__
+# define GET_LINE() __LINE__
+# warning __COUNTER__ in #warning is just output as text and will never increase!
+#else
+# if __COUNTER__ + __COUNTER__ + __COUNTER__ /* Skipped as a whole and not incrementing */
+# endif
+# error __COUNTER__ is skipped along with the whole #error line and will never increase anyways! */
+#endif
+
+#include "counter.h"
+#include "counter.h"
+
+_Static_assert(GET_COUNTER() == 10, "__COUNTER__ should be 10 here!"); /* 10 */
+
+int main(void)
+{
+ if (ident2[0] != 42) {
+ printf("Expected ident2[0]: %s, got: %s\n", 42, ident2[0]);
+ ++failures;
+ }
+
+ if (ident3[0] != 42) {
+ printf("Expected ident3[0]: %s, got: %s\n", 42, ident3[0]);
+ ++failures;
+ }
+
+ if (ident8 != 8) {
+ printf("Expected ident8: %s, got: %s\n", 8, ident8);
+ ++failures;
+ }
+
+ if (ident9 != 9) {
+ printf("Expected ident9: %s, got: %s\n", 9, ident9);
+ ++failures;
+ }
+
+ if (failures != 0) {
+ printf("Failures: %d\n", failures);
+ }
+
+ return failures;
+}
diff --git a/test/val/counter.h b/test/val/counter.h
new file mode 100644
index 0000000000..b6b5a98e2c
--- /dev/null
+++ b/test/val/counter.h
@@ -0,0 +1,4 @@
+/* Tests for predefined macro __COUNTER__ */
+
+#line GET_COUNTER() /* 1st: 8; 2nd: 9 */
+int CONCAT(ident,GET_LINE()) = GET_LINE();
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD
# === Rebuild cc65 Toolchain After Patch ===
echo "=== Rebuilding cc65 toolchain with patch applied ==="
make clean
make -j"$(nproc)" bin USER_CFLAGS="-Werror"
make lib QUIET=1
# === Run All Variants of the New Counter Test ===
echo "=== Running all counter test variants ==="
final_rc=0
# Delegate to test/val/Makefile which builds and runs every variant
# (6502/65c02 × all optimization levels) and exits non-zero on any failure
make -C test/val all
make_rc=$?
if [ "$make_rc" -eq 0 ]; then
echo "test/val/counter: all variants passed"
else
echo "test/val/counter: at least one variant failed"
final_rc=1
fi
# === Restoring Repository State ===
git checkout 168f42bb836ba940ec7aedaf76356d3facf7d595 \
test/val/counter.c \
test/val/counter.h || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:cc65-cc65-pr-1842
|
|
fluent/fluent-bit
| 5,412
|
fluent__fluent-bit-5412
|
[
5336
] |
26926608acf30e438ba0b84b1ed1dc3554c557b3
|
diff --git a/src/flb_pack.c b/src/flb_pack.c
index 1adea691ede..249b075ee94 100644
--- a/src/flb_pack.c
+++ b/src/flb_pack.c
@@ -361,24 +361,33 @@ int flb_pack_json_state(const char *js, size_t len,
* are OK in the array of tokens, if any, process them and adjust
* the JSMN context/buffers.
*/
+
+ /*
+ * jsmn_parse updates jsmn_parser members. (state->parser)
+ * A member 'toknext' points next incomplete object token.
+ * We use toknext - 1 as an index of last member of complete JSON.
+ */
int i;
int found = 0;
- for (i = 1; i < state->tokens_count; i++) {
+ if (state->parser.toknext == 0) {
+ return ret;
+ }
+
+ for (i = (int)state->parser.toknext - 1; i >= 1; i--) {
t = &state->tokens[i];
if (t->parent == -1 && (t->end != 0)) {
found++;
delim = i;
+ break;
}
}
- if (found > 0) {
- state->tokens_count += delim;
- }
- else {
- return ret;
+ if (found == 0) {
+ return ret; /* FLB_ERR_JSON_PART */
}
+ state->tokens_count += delim;
}
else if (ret != 0) {
return ret;
|
diff --git a/tests/internal/pack.c b/tests/internal/pack.c
index 4b635394c00..4b1ec0d6dc5 100644
--- a/tests/internal/pack.c
+++ b/tests/internal/pack.c
@@ -634,6 +634,154 @@ void test_json_pack_bug1278()
}
}
+static int check_msgpack_val(msgpack_object obj, int expected_type, char *expected_val)
+{
+ int len;
+
+ if (!TEST_CHECK(obj.type == expected_type)) {
+ TEST_MSG("type mismatch\nexpected=%d got=%d", expected_type, obj.type);
+ return -1;
+ }
+ switch(obj.type) {
+ case MSGPACK_OBJECT_MAP:
+ if(!TEST_CHECK(obj.via.map.size == atoi(expected_val))) {
+ TEST_MSG("map size mismatch\nexpected=%s got=%d", expected_val, obj.via.map.size);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_ARRAY:
+ if(!TEST_CHECK(obj.via.array.size == atoi(expected_val))) {
+ TEST_MSG("array size mismatch\nexpected=%s got=%d", expected_val, obj.via.array.size);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_STR:
+ len = strlen(expected_val);
+ if (!TEST_CHECK(obj.via.str.size == strlen(expected_val))) {
+ TEST_MSG("str size mismatch\nexpected=%d got=%d", len, obj.via.str.size);
+ return -1;
+ }
+ else if(!TEST_CHECK(strncmp(expected_val, obj.via.str.ptr ,len) == 0)) {
+ TEST_MSG("str mismatch\nexpected=%.*s got=%.*s", len, expected_val, len, obj.via.str.ptr);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_POSITIVE_INTEGER:
+ if(!TEST_CHECK(obj.via.u64 == (uint64_t)atoi(expected_val))) {
+ TEST_MSG("int mismatch\nexpected=%s got=%"PRIu64, expected_val, obj.via.u64);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_BOOLEAN:
+ if (obj.via.boolean) {
+ if(!TEST_CHECK(strncasecmp(expected_val, "true",4) == 0)) {
+ TEST_MSG("bool mismatch\nexpected=%s got=true", expected_val);
+ return -1;
+ }
+ }
+ else {
+ if(!TEST_CHECK(strncasecmp(expected_val, "false",5) == 0)) {
+ TEST_MSG("bool mismatch\nexpected=%s got=false", expected_val);
+ return -1;
+ }
+ }
+ break;
+
+ default:
+ TEST_MSG("unknown type %d", obj.type);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * https://github.com/fluent/fluent-bit/issues/5336
+ * Pack "valid JSON + partial JSON"
+ */
+#define JSON_BUG5336 "{\"int\":10, \"string\":\"hello\", \"bool\":true, \"array\":[0,1,2]}"
+void test_json_pack_bug5336()
+{
+ int ret;
+ char *json_valid = JSON_BUG5336;
+ size_t len = strlen(json_valid);
+
+ char *json_incomplete = JSON_BUG5336 JSON_BUG5336;
+ char *out = NULL;
+ int out_size;
+ struct flb_pack_state state;
+ int i;
+
+ msgpack_unpacked result;
+ msgpack_object obj;
+ size_t off = 0;
+
+ int loop_cnt = 0;
+
+ for (i=len; i<len*2; i++) {
+ loop_cnt++;
+
+ flb_pack_state_init(&state);
+
+ /* Pass small string size to create incomplete JSON */
+ ret = flb_pack_json_state(json_incomplete, i, &out, &out_size, &state);
+ if (!TEST_CHECK(ret != FLB_ERR_JSON_INVAL)) {
+ TEST_MSG("%ld: FLB_ERR_JSON_INVAL\njson=%.*s", i-len, i, json_incomplete);
+ exit(EXIT_FAILURE);
+ }
+ else if(!TEST_CHECK(ret != FLB_ERR_JSON_PART)) {
+ TEST_MSG("%ld: FLB_ERR_JSON_PART\njson=%.*s", i-len, i, json_incomplete);
+ exit(EXIT_FAILURE);
+ }
+
+ /* unpack parsed data */
+ msgpack_unpacked_init(&result);
+ off = 0;
+ TEST_CHECK(msgpack_unpack_next(&result, out, out_size, &off) == MSGPACK_UNPACK_SUCCESS);
+
+ TEST_CHECK(check_msgpack_val(result.data, MSGPACK_OBJECT_MAP, "4" /*map size*/) == 0);
+
+ /* "int":10 */
+ obj = result.data.via.map.ptr[0].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "int") == 0);
+ obj = result.data.via.map.ptr[0].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_POSITIVE_INTEGER, "10") == 0);
+
+ /* "string":"hello"*/
+ obj = result.data.via.map.ptr[1].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "string") == 0);
+ obj = result.data.via.map.ptr[1].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "hello") == 0);
+
+ /* "bool":true */
+ obj = result.data.via.map.ptr[2].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "bool") == 0);
+ obj = result.data.via.map.ptr[2].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_BOOLEAN, "true") == 0);
+
+ /* "array":[0,1,2] */
+ obj = result.data.via.map.ptr[3].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "array") == 0);
+ obj = result.data.via.map.ptr[3].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_ARRAY, "3" /*array size*/) == 0);
+ TEST_CHECK(check_msgpack_val(obj.via.array.ptr[0], MSGPACK_OBJECT_POSITIVE_INTEGER, "0") == 0);
+ TEST_CHECK(check_msgpack_val(obj.via.array.ptr[1], MSGPACK_OBJECT_POSITIVE_INTEGER, "1") == 0);
+ TEST_CHECK(check_msgpack_val(obj.via.array.ptr[2], MSGPACK_OBJECT_POSITIVE_INTEGER, "2") == 0);
+
+ msgpack_unpacked_destroy(&result);
+ flb_free(out);
+ flb_pack_state_reset(&state);
+ }
+
+ if(!TEST_CHECK(loop_cnt == len)) {
+ TEST_MSG("loop_cnt expect=%ld got=%d", len, loop_cnt);
+ }
+}
+
TEST_LIST = {
/* JSON maps iteration */
{ "json_pack" , test_json_pack },
@@ -644,6 +792,7 @@ TEST_LIST = {
{ "json_dup_keys" , test_json_dup_keys},
{ "json_pack_bug342" , test_json_pack_bug342},
{ "json_pack_bug1278" , test_json_pack_bug1278},
+ { "json_pack_bug5336" , test_json_pack_bug5336},
/* Mixed bytes, check JSON encoding */
{ "utf8_to_json", test_utf8_to_json},
diff --git a/tests/runtime/in_tcp.c b/tests/runtime/in_tcp.c
index 36aa07cc98d..75151c86a30 100644
--- a/tests/runtime/in_tcp.c
+++ b/tests/runtime/in_tcp.c
@@ -60,6 +60,28 @@ static void clear_output_num()
set_output_num(0);
}
+static int cb_count_msgpack(void *record, size_t size, void *data)
+{
+ msgpack_unpacked result;
+ size_t off = 0;
+
+ if (!TEST_CHECK(data != NULL)) {
+ flb_error("data is NULL");
+ }
+
+ /* Iterate each item array and apply rules */
+ msgpack_unpacked_init(&result);
+ while (msgpack_unpack_next(&result, record, size, &off) == MSGPACK_UNPACK_SUCCESS) {
+ pthread_mutex_lock(&result_mutex);
+ num_output++;
+ pthread_mutex_unlock(&result_mutex);
+ }
+ msgpack_unpacked_destroy(&result);
+
+ flb_free(record);
+ return 0;
+}
+
/* Callback to check expected results */
static int cb_check_result_json(void *record, size_t size, void *data)
{
@@ -354,10 +376,77 @@ void flb_test_format_none_separator()
test_ctx_destroy(ctx);
}
+/*
+ * Ingest 64k records.
+ * https://github.com/fluent/fluent-bit/issues/5336
+ */
+void flb_test_issue_5336()
+{
+ struct flb_lib_out_cb cb_data;
+ struct test_ctx *ctx;
+ flb_sockfd_t fd;
+ int ret;
+ int num;
+ ssize_t w_size;
+ int not_used;
+ int i;
+ int count = 65535;
+
+ char *buf = "{\"test\":\"msg\"}";
+ size_t size = strlen(buf);
+
+ clear_output_num();
+
+ cb_data.cb = cb_count_msgpack;
+ cb_data.data = ¬_used;
+
+ ctx = test_ctx_create(&cb_data);
+ if (!TEST_CHECK(ctx != NULL)) {
+ TEST_MSG("test_ctx_create failed");
+ exit(EXIT_FAILURE);
+ }
+
+ ret = flb_output_set(ctx->flb, ctx->o_ffd,
+ "match", "*",
+ NULL);
+ TEST_CHECK(ret == 0);
+
+ /* Start the engine */
+ ret = flb_start(ctx->flb);
+ TEST_CHECK(ret == 0);
+
+ /* use default host/port */
+ fd = connect_tcp(NULL, -1);
+ if (!TEST_CHECK(fd >= 0)) {
+ exit(EXIT_FAILURE);
+ }
+
+ for (i=0; i<count; i++) {
+ w_size = send(fd, buf, size, 0);
+ if (!TEST_CHECK(w_size == size)) {
+ TEST_MSG("failed to send, count=%d errno=%d",i, errno);
+ flb_socket_close(fd);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* waiting to flush */
+ flb_time_msleep(2500);
+
+ num = get_output_num();
+ if (!TEST_CHECK(num == count)) {
+ TEST_MSG("got %d, expected: %d", num, count);
+ }
+
+ flb_socket_close(fd);
+ test_ctx_destroy(ctx);
+}
+
TEST_LIST = {
{"tcp", flb_test_tcp},
{"format_none", flb_test_format_none},
{"format_none_separator", flb_test_format_none_separator},
+ {"65535_records_issue_5336", flb_test_issue_5336},
{NULL, NULL}
};
|
TCP input plugin dropping records
## Bug Report
**Describe the bug**
The 1.9.x releases contain a regression that makes TCP input plugin dropping records. The actual breaking commit is [f3ac138b0](https://github.com/fluent/fluent-bit/commit/f3ac138b0)
**To Reproduce**
1. Create a test data set having 64k records:
```
for i in $(seq 1 65535); do echo '{"foo":"bar"}'; done > tcp.log
```
2. Create `fluent-bit.conf`:
```
[SERVICE]
Flush 10
Log_Level debug
Daemon off
[INPUT]
Name tcp
Listen 0.0.0.0
Port 5170
Chunk_Size 32
Buffer_Size 64
Format json
Mem_Buf_Limit 30MB
[OUTPUT]
Name stdout
Match *
```
3. Start **working** 1.8.15 daemon:
```
docker run -it --rm -p 5170:5170 -v /path/to/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf fluent/fluent-bit:1.8.15
```
4. Send test data:
```
cat tcp.log | nc localhost 5170
```
```
Fluent Bit v1.8.15
* Copyright (C) 2015-2021 The Fluent Bit Authors
...
[2022/04/21 15:42:58] [debug] [input chunk] update output instances with new chunk size diff=46800
[2022/04/21 15:42:58] [debug] [input chunk] update output instances with new chunk size diff=14920
[2022/04/21 15:43:05] [debug] [task] created task=0x7fea70637280 id=0 OK
[2022/04/21 15:43:05] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] tcp.0: [1650555777.674115534, {"foo"=>"bar"}]
[1] tcp.0: [1650555777.674137953, {"foo"=>"bar"}]
...
[65533] tcp.0: [1650555778.342504882, {"foo"=>"bar"}]
[65534] tcp.0: [1650555778.342512844, {"foo"=>"bar"}]
[2022/04/21 15:43:06] [debug] [out coro] cb_destroy coro_id=0
```
> All records reach the output!
5. Start **non-working** 1.9.2 daemon:
```
docker run -it --rm -p 5170:5170 -v /path/to/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf fluent/fluent-bit:1.9.2
```
6. Send test data:
```
cat tcp.log | nc localhost 5170
```
```
Fluent Bit v1.9.2
* Copyright (C) 2015-2022 The Fluent Bit Authors
...
[2022/04/21 15:46:36] [debug] [tcp:tcp.0] created event channels: read=21 write=22
[2022/04/21 15:46:36] [ info] [input:tcp:tcp.0] listening on 0.0.0.0:5170
[2022/04/21 15:46:36] [debug] [stdout:stdout.0] created event channels: read=24 write=25
[2022/04/21 15:46:36] [debug] [router] match rule tcp.0:stdout.0
[2022/04/21 15:46:36] [ info] [sp] stream processor started
[2022/04/21 15:46:36] [ info] [output:stdout:stdout.0] worker #0 started
[2022/04/21 15:47:11] [debug] [input:tcp:tcp.0] JSON incomplete, waiting for more data...
[2022/04/21 15:47:11] [debug] [input:tcp:tcp.0] JSON incomplete, waiting for more data...
[2022/04/21 15:47:11] [debug] [input:tcp:tcp.0] JSON incomplete, waiting for more data...
[2022/04/21 15:47:11] [debug] [input:tcp:tcp.0] JSON incomplete, waiting for more data...
```
> I've seen processed record count varying between 0, 512, 1024, but never the amount of input.
7. Revert the mentioned commit and rebuild image
```
git checkout -b v1.9.2-patched v1.9.2
git revert f3ac138b0
docker buildx build --no-cache --load --platform "linux/amd64" --target=production -f dockerfiles/Dockerfile -t fluent/fluent-bit:1.9.2-patched .
```
8. Start **patched** 1.9.2 daemon:
```
docker run -it --rm -p 5170:5170 -v /path/to/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf fluent/fluent-bit:1.9.2-patched
```
9. Send test data:
```
cat tcp.log | nc localhost 5170
```
```
Fluent Bit v1.9.2
* Copyright (C) 2015-2022 The Fluent Bit Authors
...
[2022/04/21 15:56:29] [debug] [tcp:tcp.0] created event channels: read=21 write=22
[2022/04/21 15:56:29] [ info] [input:tcp:tcp.0] listening on 0.0.0.0:5170
[2022/04/21 15:56:29] [debug] [stdout:stdout.0] created event channels: read=24 write=25
[2022/04/21 15:56:29] [debug] [router] match rule tcp.0:stdout.0
[2022/04/21 15:56:29] [ info] [sp] stream processor started
[2022/04/21 15:56:29] [ info] [output:stdout:stdout.0] worker #0 started
[2022/04/21 15:56:34] [debug] [input chunk] update output instances with new chunk size diff=21940
[2022/04/21 15:56:34] [debug] [input chunk] update output instances with new chunk size diff=46800
...
[2022/04/21 15:56:34] [debug] [input chunk] update output instances with new chunk size diff=46800
[2022/04/21 15:56:34] [debug] [input chunk] update output instances with new chunk size diff=46800
[2022/04/21 15:56:34] [debug] [input chunk] update output instances with new chunk size diff=25160
[2022/04/21 15:56:38] [debug] [task] created task=0x7f7a05e423f0 id=0 OK
[2022/04/21 15:56:38] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] tcp.0: [1650556594.057870047, {"foo"=>"bar"}]
[1] tcp.0: [1650556594.057911742, {"foo"=>"bar"}]
...
[65533] tcp.0: [1650556594.703312414, {"foo"=>"bar"}]
[65534] tcp.0: [1650556594.703320516, {"foo"=>"bar"}]
[2022/04/21 15:56:39] [debug] [out flush] cb_destroy coro_id=0
[2022/04/21 15:56:39] [debug] [task] destroy task=0x7f7a05e423f0 (task_id=0)
```
> Works again just like in 1.8 releases!
**Expected behavior**
1.9 releases should behave in a similar way as the earlier 1.8 releases.
**Additional context**
Especially systems using TCP keepalive sessions with TCP input plugin are badly misbehaving at the moment.
The following patch is enough to fix the issue (but it might have some other issues):
```
diff --git a/src/flb_pack.c b/src/flb_pack.c
index 40e1bde5d..e7f33a1bd 100644
--- a/src/flb_pack.c
+++ b/src/flb_pack.c
@@ -364,9 +364,13 @@ int flb_pack_json_state(const char *js, size_t len,
int i;
int found = 0;
- for (i = 1; i < state->tokens_count; i++) {
+ for (i = 1; i < state->tokens_size; i++) {
t = &state->tokens[i];
+ if (t->start < (state->tokens[i - 1]).start) {
+ break;
+ }
+
if (t->parent == -1 && (t->end != 0)) {
found++;
delim = i;
```
|
@edsiper any comments?
@edsiper I think below line causes this issue.
https://github.com/fluent/fluent-bit/commit/f3ac138b0#diff-7228b3553f609319f8501a9d8815f08fbb6c451a69dbccb9faec6bdaff57cbdeR368
If jsmn API returns `JSMN_ERROR_PART`, `state->tokens_count` doesn't increase.
https://github.com/fluent/fluent-bit/blob/v1.9.3/src/flb_pack.c#L77
Then fluent-bit tries to iterate below loop.
https://github.com/fluent/fluent-bit/blob/v1.9.3/src/flb_pack.c#L367
However it doesn't iterate since `state->tokens_count` is 0.
Then `found` never increase and the function returns `FLB_ERR_JSON_PART`.
https://github.com/fluent/fluent-bit/blob/v1.9.3/src/flb_pack.c#L380
`in_tcp` reports `JSON incomplete` since the API(`flb_pack_json_state`) returns `FLB_ERR_JSON_PART`.
|
@edsiper any comments?
@edsiper I think below line causes this issue.
https://github.com/fluent/fluent-bit/commit/f3ac138b0#diff-7228b3553f609319f8501a9d8815f08fbb6c451a69dbccb9faec6bdaff57cbdeR368
If jsmn API returns `JSMN_ERROR_PART`, `state->tokens_count` doesn't increase.
https://github.com/fluent/fluent-bit/blob/v1.9.3/src/flb_pack.c#L77
Then fluent-bit tries to iterate below loop.
https://github.com/fluent/fluent-bit/blob/v1.9.3/src/flb_pack.c#L367
However it doesn't iterate since `state->tokens_count` is 0.
Then `found` never increase and the function returns `FLB_ERR_JSON_PART`.
https://github.com/fluent/fluent-bit/blob/v1.9.3/src/flb_pack.c#L380
`in_tcp` reports `JSON incomplete` since the API(`flb_pack_json_state`) returns `FLB_ERR_JSON_PART`.
|
[
"https://github.com/fluent/fluent-bit/commit/3dfa8b3abe2789794a8418993256249bbd6b22b3",
"https://github.com/fluent/fluent-bit/commit/8356b95eb64f5d417ebf78928a6c843645fcc578",
"https://github.com/fluent/fluent-bit/commit/174fb9caed262d63344535a8bb1584a8e5a4da99"
] | 2022-05-05T12:17:24
|
1.8
|
C
|
#!/usr/bin/env bash
set -e
cd /testbed
git reset --hard 26926608acf30e438ba0b84b1ed1dc3554c557b3
|
#!/usr/bin/env bash
set -euxo pipefail
# ========================================================
# 0️⃣ Basic Env Vars (independent of packages)
# ========================================================
export TZ=UTC
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# ========================================================
# 1️⃣ ONE-TIME APT INSTALL (ALL additional packages)
# ========================================================
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
curl \
ca-certificates \
libssl-dev \
libsasl2-dev \
pkg-config \
libsystemd-dev \
zlib1g-dev \
libpq-dev \
postgresql-server-dev-all \
flex \
bison \
libyaml-dev \
|| { echo "[FATAL] apt-get install failed"; exit 1; }
rm -rf /var/lib/apt/lists/*
# ========================================================
# 2️⃣ Compiler & Build Toolchain Setup
# ========================================================
export CC=gcc
# Force Unix Makefiles generator to avoid Ninja $-escape issues
export CMAKE_GENERATOR="Unix Makefiles"
export PATH=/usr/local/bin:/usr/bin:/bin:${PATH:-}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH:-}
# ========================================================
# 3️⃣ Directory Preparation
# ========================================================
mkdir -p /testbed
cd /testbed
git config --global --add safe.directory /testbed
# ========================================================
# 4️⃣ Dependency Rules (pip/vcpkg/conan/bazel etc.)
# ========================================================
# No external package managers required for Fluent Bit build
# ========================================================
# 5️⃣ Build Attempts (Test–Focused Mode)
# ========================================================
# Configure CMake with test flags enabled (fail fast on error)
cmake -S . -B build -G "${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE=Release \
-DFLB_TESTS_INTERNAL=On \
-DFLB_TESTS_RUNTIME=On \
-DFLB_STREAM_PROCESSOR=On
# Full project build to ensure all dependencies (LuaJIT etc.) are compiled
cmake --build build -- -j$(nproc)
# Build only stream processor test target (fail fast on error)
cmake --build build --target flb-it-stream_processor -- -j$(nproc)
# Wait for the binary to be present before continuing
while [ ! -f build/bin/flb-it-stream_processor ]; do
sleep 2
done
# ========================================================
# 6️⃣ Verification
# ========================================================
echo "[INFO] Compiler version:"
$CC --version
echo "[INFO] CMake version:"
cmake --version || true
echo "[INFO] Make version:"
make --version || true
# ========================================================
# 7️⃣ Completion Marker
# ========================================================
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
#!/usr/bin/env bash
set -euxo pipefail
# === Environment Setup ===
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
cd /testbed
git config --global --add safe.directory /testbed
# === Pre-Patch Info ===
echo "=== Repository Status Before Patch ==="
git status
git show --stat
cmake --version
ctest --version
if [ -d build ]; then
(cd build && cmake --build . --target help) || true
fi
# === Reset Target Test Files to Clean State ===
echo "=== Resetting Target Test Files to Clean State ==="
git checkout 26926608acf30e438ba0b84b1ed1dc3554c557b3 -- tests/internal/pack.c tests/runtime/in_tcp.c || true
# === Apply Test Patch ===
# [IMPORTANT NOTE]: The [test patch content] between EOF_114329324912 below is a fixed placeholder.
# DO NOT modify/delete it. The actual Git Patch content will be manually replaced in subsequent processes.
echo "=== Applying Test Patch ==="
git apply -v - <<'EOF_114329324912'
diff --git a/tests/internal/pack.c b/tests/internal/pack.c
index 4b635394c00..4b1ec0d6dc5 100644
--- a/tests/internal/pack.c
+++ b/tests/internal/pack.c
@@ -634,6 +634,154 @@ void test_json_pack_bug1278()
}
}
+static int check_msgpack_val(msgpack_object obj, int expected_type, char *expected_val)
+{
+ int len;
+
+ if (!TEST_CHECK(obj.type == expected_type)) {
+ TEST_MSG("type mismatch\nexpected=%d got=%d", expected_type, obj.type);
+ return -1;
+ }
+ switch(obj.type) {
+ case MSGPACK_OBJECT_MAP:
+ if(!TEST_CHECK(obj.via.map.size == atoi(expected_val))) {
+ TEST_MSG("map size mismatch\nexpected=%s got=%d", expected_val, obj.via.map.size);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_ARRAY:
+ if(!TEST_CHECK(obj.via.array.size == atoi(expected_val))) {
+ TEST_MSG("array size mismatch\nexpected=%s got=%d", expected_val, obj.via.array.size);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_STR:
+ len = strlen(expected_val);
+ if (!TEST_CHECK(obj.via.str.size == strlen(expected_val))) {
+ TEST_MSG("str size mismatch\nexpected=%d got=%d", len, obj.via.str.size);
+ return -1;
+ }
+ else if(!TEST_CHECK(strncmp(expected_val, obj.via.str.ptr ,len) == 0)) {
+ TEST_MSG("str mismatch\nexpected=%.*s got=%.*s", len, expected_val, len, obj.via.str.ptr);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_POSITIVE_INTEGER:
+ if(!TEST_CHECK(obj.via.u64 == (uint64_t)atoi(expected_val))) {
+ TEST_MSG("int mismatch\nexpected=%s got=%"PRIu64, expected_val, obj.via.u64);
+ return -1;
+ }
+ break;
+
+ case MSGPACK_OBJECT_BOOLEAN:
+ if (obj.via.boolean) {
+ if(!TEST_CHECK(strncasecmp(expected_val, "true",4) == 0)) {
+ TEST_MSG("bool mismatch\nexpected=%s got=true", expected_val);
+ return -1;
+ }
+ }
+ else {
+ if(!TEST_CHECK(strncasecmp(expected_val, "false",5) == 0)) {
+ TEST_MSG("bool mismatch\nexpected=%s got=false", expected_val);
+ return -1;
+ }
+ }
+ break;
+
+ default:
+ TEST_MSG("unknown type %d", obj.type);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * https://github.com/fluent/fluent-bit/issues/5336
+ * Pack "valid JSON + partial JSON"
+ */
+#define JSON_BUG5336 "{\"int\":10, \"string\":\"hello\", \"bool\":true, \"array\":[0,1,2]}"
+void test_json_pack_bug5336()
+{
+ int ret;
+ char *json_valid = JSON_BUG5336;
+ size_t len = strlen(json_valid);
+
+ char *json_incomplete = JSON_BUG5336 JSON_BUG5336;
+ char *out = NULL;
+ int out_size;
+ struct flb_pack_state state;
+ int i;
+
+ msgpack_unpacked result;
+ msgpack_object obj;
+ size_t off = 0;
+
+ int loop_cnt = 0;
+
+ for (i=len; i<len*2; i++) {
+ loop_cnt++;
+
+ flb_pack_state_init(&state);
+
+ /* Pass small string size to create incomplete JSON */
+ ret = flb_pack_json_state(json_incomplete, i, &out, &out_size, &state);
+ if (!TEST_CHECK(ret != FLB_ERR_JSON_INVAL)) {
+ TEST_MSG("%ld: FLB_ERR_JSON_INVAL\njson=%.*s", i-len, i, json_incomplete);
+ exit(EXIT_FAILURE);
+ }
+ else if(!TEST_CHECK(ret != FLB_ERR_JSON_PART)) {
+ TEST_MSG("%ld: FLB_ERR_JSON_PART\njson=%.*s", i-len, i, json_incomplete);
+ exit(EXIT_FAILURE);
+ }
+
+ /* unpack parsed data */
+ msgpack_unpacked_init(&result);
+ off = 0;
+ TEST_CHECK(msgpack_unpack_next(&result, out, out_size, &off) == MSGPACK_UNPACK_SUCCESS);
+
+ TEST_CHECK(check_msgpack_val(result.data, MSGPACK_OBJECT_MAP, "4" /*map size*/) == 0);
+
+ /* "int":10 */
+ obj = result.data.via.map.ptr[0].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "int") == 0);
+ obj = result.data.via.map.ptr[0].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_POSITIVE_INTEGER, "10") == 0);
+
+ /* "string":"hello"*/
+ obj = result.data.via.map.ptr[1].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "string") == 0);
+ obj = result.data.via.map.ptr[1].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "hello") == 0);
+
+ /* "bool":true */
+ obj = result.data.via.map.ptr[2].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "bool") == 0);
+ obj = result.data.via.map.ptr[2].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_BOOLEAN, "true") == 0);
+
+ /* "array":[0,1,2] */
+ obj = result.data.via.map.ptr[3].key;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_STR, "array") == 0);
+ obj = result.data.via.map.ptr[3].val;
+ TEST_CHECK(check_msgpack_val(obj, MSGPACK_OBJECT_ARRAY, "3" /*array size*/) == 0);
+ TEST_CHECK(check_msgpack_val(obj.via.array.ptr[0], MSGPACK_OBJECT_POSITIVE_INTEGER, "0") == 0);
+ TEST_CHECK(check_msgpack_val(obj.via.array.ptr[1], MSGPACK_OBJECT_POSITIVE_INTEGER, "1") == 0);
+ TEST_CHECK(check_msgpack_val(obj.via.array.ptr[2], MSGPACK_OBJECT_POSITIVE_INTEGER, "2") == 0);
+
+ msgpack_unpacked_destroy(&result);
+ flb_free(out);
+ flb_pack_state_reset(&state);
+ }
+
+ if(!TEST_CHECK(loop_cnt == len)) {
+ TEST_MSG("loop_cnt expect=%ld got=%d", len, loop_cnt);
+ }
+}
+
TEST_LIST = {
/* JSON maps iteration */
{ "json_pack" , test_json_pack },
@@ -644,6 +792,7 @@ TEST_LIST = {
{ "json_dup_keys" , test_json_dup_keys},
{ "json_pack_bug342" , test_json_pack_bug342},
{ "json_pack_bug1278" , test_json_pack_bug1278},
+ { "json_pack_bug5336" , test_json_pack_bug5336},
/* Mixed bytes, check JSON encoding */
{ "utf8_to_json", test_utf8_to_json},
diff --git a/tests/runtime/in_tcp.c b/tests/runtime/in_tcp.c
index 36aa07cc98d..75151c86a30 100644
--- a/tests/runtime/in_tcp.c
+++ b/tests/runtime/in_tcp.c
@@ -60,6 +60,28 @@ static void clear_output_num()
set_output_num(0);
}
+static int cb_count_msgpack(void *record, size_t size, void *data)
+{
+ msgpack_unpacked result;
+ size_t off = 0;
+
+ if (!TEST_CHECK(data != NULL)) {
+ flb_error("data is NULL");
+ }
+
+ /* Iterate each item array and apply rules */
+ msgpack_unpacked_init(&result);
+ while (msgpack_unpack_next(&result, record, size, &off) == MSGPACK_UNPACK_SUCCESS) {
+ pthread_mutex_lock(&result_mutex);
+ num_output++;
+ pthread_mutex_unlock(&result_mutex);
+ }
+ msgpack_unpacked_destroy(&result);
+
+ flb_free(record);
+ return 0;
+}
+
/* Callback to check expected results */
static int cb_check_result_json(void *record, size_t size, void *data)
{
@@ -354,10 +376,77 @@ void flb_test_format_none_separator()
test_ctx_destroy(ctx);
}
+/*
+ * Ingest 64k records.
+ * https://github.com/fluent/fluent-bit/issues/5336
+ */
+void flb_test_issue_5336()
+{
+ struct flb_lib_out_cb cb_data;
+ struct test_ctx *ctx;
+ flb_sockfd_t fd;
+ int ret;
+ int num;
+ ssize_t w_size;
+ int not_used;
+ int i;
+ int count = 65535;
+
+ char *buf = "{\"test\":\"msg\"}";
+ size_t size = strlen(buf);
+
+ clear_output_num();
+
+ cb_data.cb = cb_count_msgpack;
+ cb_data.data = ¬_used;
+
+ ctx = test_ctx_create(&cb_data);
+ if (!TEST_CHECK(ctx != NULL)) {
+ TEST_MSG("test_ctx_create failed");
+ exit(EXIT_FAILURE);
+ }
+
+ ret = flb_output_set(ctx->flb, ctx->o_ffd,
+ "match", "*",
+ NULL);
+ TEST_CHECK(ret == 0);
+
+ /* Start the engine */
+ ret = flb_start(ctx->flb);
+ TEST_CHECK(ret == 0);
+
+ /* use default host/port */
+ fd = connect_tcp(NULL, -1);
+ if (!TEST_CHECK(fd >= 0)) {
+ exit(EXIT_FAILURE);
+ }
+
+ for (i=0; i<count; i++) {
+ w_size = send(fd, buf, size, 0);
+ if (!TEST_CHECK(w_size == size)) {
+ TEST_MSG("failed to send, count=%d errno=%d",i, errno);
+ flb_socket_close(fd);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* waiting to flush */
+ flb_time_msleep(2500);
+
+ num = get_output_num();
+ if (!TEST_CHECK(num == count)) {
+ TEST_MSG("got %d, expected: %d", num, count);
+ }
+
+ flb_socket_close(fd);
+ test_ctx_destroy(ctx);
+}
+
TEST_LIST = {
{"tcp", flb_test_tcp},
{"format_none", flb_test_format_none},
{"format_none_separator", flb_test_format_none_separator},
+ {"65535_records_issue_5336", flb_test_issue_5336},
{NULL, NULL}
};
EOF_114329324912
echo "=== Verifying Patch Application ==="
git diff HEAD
# === Configure Build ===
echo "=== Configuring Build ==="
mkdir -p build
cd build
cmake -DFLB_TESTS_RUNTIME=On -DFLB_TESTS_INTERNAL=On .. || true
# === Detect Test Targets and Build Only Needed Ones ===
echo "=== Detecting Test Targets and Building Only Needed Ones ==="
# List all tests first
ctest -N -V | tee ctest_list.txt || true
# Extract test names related to our target files
grep -iE "(pack|in_tcp)" ctest_list.txt | tee target_tests.txt || true
# If we found specific tests, try building only needed targets
if [ -s target_tests.txt ]; then
echo "Found pack/in_tcp related tests, building only test targets"
cmake --build . --target flb-test-runtime flb-test-internal || \
cmake --build . --target $(cmake --build . --target help | grep -iE "test" | awk '{print $1}' | tr '\n' ' ') || \
cmake --build . || true
else
echo "No specific test targets mapped, building project"
cmake --build . || true
fi
# === Run Target Tests ===
echo "=== Running Target Tests: pack and in_tcp ==="
ctest -V -j$(nproc) -R "pack|in_tcp" --output-on-failure
rc_pack_in_tcp=$?
# === Compute Final Exit Code ===
final_rc=$rc_pack_in_tcp
# === Restore Target Test Files ===
cd /testbed
echo "=== Restoring Repository State ==="
git checkout 26926608acf30e84b1ed1dc3554c557b3 -- tests/internal/pack.c tests/runtime/in_tcp.c || true
echo "=== TEST EXECUTION COMPLETE ==="
echo "OMNIGRIL_EXIT_CODE=$final_rc"
# Print completion marker - DO NOT REMOVE
echo "=================================="
echo "COMMAND_EXECUTION_COMPLETE"
echo "=================================="
|
swe-images-c:fluent-fluent-bit-pr-5412
|
microsoft/ebpf-for-windows
| 3,793
|
microsoft__ebpf-for-windows-3793
|
[
3736
] |
7848d3790d905f011e650413fa16d3c57ff80ba1
| "diff --git a/docs/tutorial.md b/docs/tutorial.md\nindex dc9089a6bb..1606cd91ed 100644\n--- a/docs/t(...TRUNCATED)
| "diff --git a/tests/bpf2c_tests/expected/droppacket_dll.c b/tests/bpf2c_tests/expected/droppacket_dl(...TRUNCATED)
| "XDP header declarations belong in XDP-for-Windows repo, not eBPF-for-Windows\n### Describe the bug\(...TRUNCATED)
| "@mtfriesen I am assigning this bug to you for now. Please let me know if you want this to be re-ass(...TRUNCATED)
| "@mtfriesen I am assigning this bug to you for now. Please let me know if you want this to be re-ass(...TRUNCATED)
| ["https://github.com/microsoft/ebpf-for-windows/commit/4dd5e586b718210e4ff0012f2513b4f736d2e629","ht(...TRUNCATED)
| 2024-08-27T23:27:50
|
0.18
|
C
| "#!/usr/bin/env bash\nset -euxo pipefail\n\n# ======================================================(...TRUNCATED)
| "#!/usr/bin/env bash\nset -euxo pipefail\n\n# ======================================================(...TRUNCATED)
| "#!/bin/bash\nset -euxo pipefail\n\nexport LANG=en_US.UTF-8\nexport LC_ALL=en_US.UTF-8\nexport LANGU(...TRUNCATED)
|
swe-images-c:microsoft-ebpf-for-windows-pr-3793
|
systemd/systemd
| 22,972
|
systemd__systemd-22972
|
[
22957
] |
c0da575a0e94e7ecae7f5f0c72dea0be853af352
| "diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c\nindex e0dc47ecd8d52..66e0c01c2324(...TRUNCATED)
| "diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c\nindex c3206e1e7ab8b..9c(...TRUNCATED)
| "systemd fails to process a unit with a long line (but shorter than `LONG_LINE_MAX`)\n**systemd vers(...TRUNCATED)
| "065364920281e1cf59cab989e17aff21790505c4 is the first bad commit.\r\n\r\nHere's a test case for `te(...TRUNCATED)
| "065364920281e1cf59cab989e17aff21790505c4 is the first bad commit.\r\n\r\nHere's a test case for `te(...TRUNCATED)
|
[
"https://github.com/systemd/systemd/commit/11c35921a3fcb3423f4985ccbb7261793a42cfd6"
] | 2022-04-05T12:49:30
|
0.0
|
C
| "#!/usr/bin/env bash\nset -e\ncd /testbed\ngit reset --hard c0da575a0e94e7ecae7f5f0c72dea0be853af352(...TRUNCATED)
| "#!/usr/bin/env bash\nset -euxo pipefail\n\n# ======================================================(...TRUNCATED)
| "#!/bin/bash\nset -uxo pipefail\n\n# === Environment Setup ===\nexport LANG=en_US.UTF-8\nexport LC_A(...TRUNCATED)
|
swe-images-c:systemd-systemd-pr-22972
|
End of preview.