Hello Heikki,

30.09.2026 14:43, Heikki Linnakangas wrote:
Ok, I picked a mix of these test changes that I liked the best, and committed 
:-). Thank you both!


Please look at a failure of 001_late_shmem_alloc.pl, produced recently by
mamba [1]:
# +++ tap check in src/test/modules/test_shmem +++
# die: ack Broken pipe: write( 13, '
# -- allocate
# SELECT test_shmem_register('test_shmem after startup', 25, 1);
# -- attach
# SELECT test_shmem_register('test_shmem after startup', 25, 2);
# -- attach with SHMEM_ATTACH_UNKNOWN_SIZE
# SELECT test_shmem_register('test_shmem after startup', -1, 3);
# ' ) at /usr/pkg/lib/perl5/vendor_perl/5.42.0/IPC/Run/IO.pm line 550.
# Looks like your test exited with 32 just after 12.
[05:53:14] t/001_late_shmem_alloc.pl ..
Dubious, test returned 32 (wstat 8192, 0x2000)
All 12 subtests passed
    (less 2 skipped subtests: 10 okay)
[05:53:14]

It looks like postmaster that is doomed to fail ("Cannot use
SHMEM_ATTACH_UNKNOWN_SIZE with a segment that doesn't exist") can exit
before it processes stdin from TAP test. I've managed to reproduce it with
slow_write.c attached as below:
LD_PRELOAD=.../slow_write.so PROVE_TESTS='t/001*' make -s check -C 
src/test/modules/test_shmem
# +++ tap check in src/test/modules/test_shmem +++
t/001_late_shmem_alloc.pl .. 11/? # die: ack Broken pipe: write( 13, '
...
# Looks like your test exited with 32 just after 12.
t/001_late_shmem_alloc.pl .. Dubious, test returned 32 (wstat 8192, 0x2000)
All 12 subtests passed

Without this test,
LD_PRELOAD=.../slow_write.so make -s check-world
passes for me.

Note that mamba has
# IPC::Run::VERSION: 20250809.0
This issue is not reproduced with 20260402.0.

[1] 
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=mamba&dt=2026-10-01%2006%3A10%3A51

Best regards,
Alexander
#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <errno.h>
#if defined(__NetBSD__)||defined(__FreeBSD__)||defined(__DragonFly__)||defined(__APPLE__)
#define PN getprogname()
#else
#define PN program_invocation_short_name
#endif
static ssize_t (*rw)(int,const void*,size_t);
__attribute__((constructor)) static void ini(void)
{
  rw = (ssize_t(*)(int, const void*, size_t)) dlsym(RTLD_NEXT,"write");
}

#define SLEEP_US 10000
ssize_t write(int fd,const void*b,size_t n)
{
    if (!rw)
    {
        errno = ENOSYS;
        return -1;
    }

    struct stat s;
    struct timeval t = {0, SLEEP_US};
    if (PN && strstr(PN, "perl") && fstat(fd, &s) == 0 && S_ISFIFO(s.st_mode))
        select(0, 0, 0, 0, &t);

    return rw(fd, b, n);
}

Reply via email to