coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new test fails on macOS


From: Pádraig Brady
Subject: Re: new test fails on macOS
Date: Tue, 25 Aug 2026 12:46:22 +0100
User-agent: Mozilla Thunderbird Beta

On 25/08/2026 03:02, Collin Funk wrote:
Bruno Haible via GNU coreutils General Discussion <coreutils@gnu.org>
writes:

This week, this test fails on FreeBSD 14.0:

FAIL: tests/env/env0-from
=========================

env: environment corrupt; missing value for opaque
env: cannot unset 'A': Bad address
--- exp-sorted  2026-08-24 19:26:18.994854000 +0000
+++ out 2026-08-24 19:26:18.997699000 +0000
@@ -0,0 +1,4 @@
+B=old
+C=operand
+D=new
+opaque
env: cannot unset '': Invalid argument
env: cannot unset 'A=B': Invalid argument
env: cannot unset '': Invalid argument
env: cannot unset 'A=B': Invalid argument
FAIL tests/env/env0-from.sh (exit status: 1)

Thats annoying. FreeBSD getenv, putenv, and friends just give up upon
seeing an environment variable without a value, instead of continuing
like everyone else [1].

I don't like the attached patch, but I don't see an alternative...

Collin

[1] 
https://github.com/freebsd/freebsd-src/blob/9496457f230f933afa78b0a60295d59828bff08c/lib/libc/stdlib/getenv.c#L354-L364

It seems that this validation is only done on unsetenv() on FreeBSD?

  $ printf 'A=1\0A=2\0foo\0' |
    src/env --env0-from=- src/env foo=bar | grep foo
  foo=bar
  foo

  $ printf 'A=1\0A=2\0foo\0' |
    src/env --env0-from=- src/env -u foo
  env: environment corrupt; missing value for foo
  env: cannot unset ‘foo’: Bad address

  $ printf 'A=1\0A=2\0foo\0' |
    src/env --env0-from=- src/env -u bar
  env: environment corrupt; missing value for foo
  env: cannot unset ‘bar’: Bad address

Anyway we can avoid the unsetenv() and putenv() in this case
as we're only re-execing env(1) to get a standard env list with possible 
implicit entries,
we can do our manipulations before that.
The attached passes on FreeBSD 15 at least (cfarm240).

cheers,
Padraig

Attachment: tests-env-freebsd.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]