8000 Warnings on exit when DBI handle is global variable and there is assignment from subroutine · Issue #23306 · Perl/perl5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Warnings on exit when 8000 DBI handle is global variable and there is assignment from subroutine #23306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vvv2542 opened this issue May 19, 2025 · 70 comments

Comments

@vvv2542
Copy link
vvv2542 commented May 19, 2025

perl 5.40 prints warnings on exit when DBI handle is global variable and there is assignment from subroutine.

Module:
DBI 1.647

Description
The code below prints warnings on exit:

#!/usr/bin/env perl

use strict;
use warnings;
use DBI;

my $dbh = DBI->connect("dbi:Pg:dbname=db1", "user1", "password");
print "DONE\n";
exit 0;

sub sub1 {
    $dbh = "";
}

Result:

DONE
DBI dr handle 0x35f181.6477a42be8 cleared whilst still active during global destruction.
DBI dr handle 0x35f187a42be8 has 1 uncleared child handles during global destruction.
    dbih_clearcom (drh 0x35f187a42be8, com 0x35f1870ac000, imp DBD::Pg::dr):
       FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit
       PARENT undef
       KIDS 1 (1 Active)

The script completed without warnings with perl 5.36 and the same version of DBI. Not tested with 5.38.
No warnings if remove $dbh assignment in sub1() which never called.

Steps to Reproduce
Execute the script with perl 5.40.

Expected behavior
No warnings.

Perl configuration

Summary of my perl5 (revision 5 version 40 subversion 2) configuration:

  Platform:
    osname=freebsd
    osvers=14.2-release-p3
    archname=amd64-freebsd-thread-multi
    uname='freebsd 142amd64-default-job-01 14.2-release-p3 freebsd 14.2-release-p3 amd64 '
    config_args='-Darchlib=/usr/local/lib/perl5/5.40/mach -Dcc=cc -Dcf_by=mat -Dcf_email=mat@FreeBSD.org -Dcf_time=Sun Apr 13 13:07:13 UTC 2025 -Dinc_version_list=none -Dlibperl=libperl.so.5.40.2 -Dman1dir=/usr/local/lib/perl5/5.40/perl/man/man1 -Dman3dir=/usr/local/lib/perl5/5.40/perl/man/man3 -Dprefix=/usr/local -Dprivlib=/usr/local/lib/perl5/5.40 -Dscriptdir=/usr/local/bin -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.40 -Dsitelib=/usr/local/lib/perl5/site_perl -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dusenm=n -Duseshrplib -sde -Ui_iconv -Ui_malloc -Uinstallusrbinperl -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5.40/work/perl-5.40.2 -L/usr/local/lib/perl5/5.40/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5.40/work/perl-5.40.2:N-L/usr/local/lib/perl5/5.40/mach/CORE:N-lperl) -Wl,-soname,$(LIBPERL:R) -Doptimize=-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Dusedtrace -Ui_gdbm -Dusemultiplicity=y -Duse64bitint -Dusemymalloc=n -Dusethreads=y'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    optimize='-O2 -pipe -fstack-protector-strong -fno-strict-aliasing '
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='FreeBSD Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags ='-pthread -Wl,-E  -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /usr/lib/clang/18/lib
    libs=-ldl -lm -lcrypt -lutil
    perllibs=-ldl -lm -lcrypt -lutil
    libc=
    so=so
    useshrplib=true
    libperl=libperl.so.5.40.2
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.40/mach/CORE'
    cccdlflags='-DPIC -fPIC'
    lddlflags='-shared  -L/usr/local/lib/perl5/5.40/mach/CORE -lperl -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Built under freebsd
  @INC:
    /usr/local/lib/perl5/site_perl/mach/5.40# perl -V output goes here

    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.40/mach
    /usr/local/lib/perl5/5.40
@karenetheridge
Copy link
Member

This is a problem with DBI, which apparently needs to take more care to close down its connections in the right order during global destru 8000 ction.

@vvv2542
Copy link
Author
vvv2542 commented May 19, 2025

Why the same DBI version with perl 5.36 doesn't print the warning?
Why sub1() that do nothing and has no references in code causes the warning?

@Tux
Copy link
Contributor
Tux commented May 20, 2025

@karenetheridge suggestions on improvement welcome!
I know however from other DBD's that having structures that share connections are sometimes (very) hard to free. e.g. if freeing needs to wait for a database sync to disconnect

@iabyn
Copy link
Contributor
iabyn commented May 20, 2025 via email

@dlangille
Copy link

I've encountered a similar situation in my own code when moving from 5.38 to 5.40

What is interesting is that the errors are not reproducible. So far, I've been unable to reproduce the error by running the work load again. Not sure why yet.

Two nodes, running the same code, against similar databases, won't necessarily encounter the error when doing the same set of work. Again, not sure why. Given the data and work, if one node hits the error, everything running that same code should as well.

@dlangille
Copy link

Why the same DBI version with perl 5.36 doesn't print the warning? Why sub1() that do nothing and has no references in code causes the warning?

My testing on FreeBSD 14.2 with PostgreSQL 16 gives the same error

[23:53 dev-ingress01 dvl ~/scripts] % perl perl5-issue-23306
DONE
DBI dr handle 0x13b121641a68 cleared whilst still active during global destruction.
    dbih_clearcom (drh 0x13b121641a68, com 0x13b120cb12c0, imp DBD::Pg::dr):
       FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit 
       PARENT undef
       KIDS 0 (1 Active)
[23:53 dev-ingress01 dvl ~/scripts] % 

If I remove sub1 the error does not appear or comment out the $dbh = ""; line, the error does not appear.

@karenetheridge
Copy link
Member

During global destruction, the order in which resources are freed can be pretty random, so depending on the order in which things can happen, something can expect something to still exist which surprisingly does not.

Is there some graceful disconnecting or teardowns that you can do in an END{} block, or in the destructor for a particular object?

@vvv2542
Copy link
Author
vvv2542 commented May 28, 2025

I my case adding END{} solves the problem. But I don't understand why in different scripts helps $dbh->disconnect, or $dbh=undef, or both. The solution for a particular script is unpredictable. But the problem is always reproducible.

@dlangille
Copy link

What is this END{}? Am I doing it wrong?

[11:31 dev-ingress01 dvl ~/scripts] % perl perl5-issue-23306

DONE
DBI dr handle 0x3ab457c41ac8 cleared whilst still active during global destruction.
    dbih_clearcom (drh 0x3ab457c41ac8, com 0x3ab4572b12c0, imp DBD::Pg::dr):
       FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit 
       PARENT undef
       KIDS 0 (1 Active)

[11:31 dev-ingress01 dvl ~/scripts] % cat perl5-issue-23306

#!/usr/bin/env perl

use strict;
use warnings;
use DBI;



#require FreshPorts::config;
my $dbh = DBI->connect("dbi:Pg:dbname=freshports.dev;host=pg03.example.org", "redacted", 'redacted);

print "DONE\n";
exit 0;

sub sub1 {
    $dbh = "";
}

END{}

@vvv2542
Copy link
Author
vvv2542 commented May 28, 2025

Try

END {
    $dbh->disconnect;
    $dbh = undef;
}

@dlangille
Copy link

That resolves my test issue. In my case, I think it's a race condition, since the same test does not fail on all hosts every time.

@Leont
Copy link
Contributor
Leont commented May 28, 2025
END {
    $dbh->disconnect;
    $dbh = undef;
}

I would recommend changing that to $dbh->disconnect if $dbh, if you end the script before $dbh is connected you'll get a weird and confusing error otherwise.

I think it's a race condition, since the same test does not fail on all hosts every time.

No it's not a race condition, it's just unorderedness like @karenetheridge explained.

@dlangille
Copy link

I created perl5-dbi/dbi#171

dlangille added a commit to FreshPorts/ports that referenced this issue Jun 1, 2025
After moving from perl 5.38 to perl 5.40, DBI errors started to show up.

DBI db handle 0x86ba253f2a0 has 1 uncleared child handles during global destruction.
    dbih_clearcom (dbh 0x86ba253f2a0, com 0x86ba1ba90c0, imp DBD::Pg::db):
       FLAGS 0x580111: COMSET Warn PrintError PrintWarn
       PARENT DBI::dr=HASH(0x86ba2540480)
       KIDS 1 (0 Active)

It is not clear why or how to clean it up.

re: perl5-dbi/dbi#171
    Perl/perl5#23306

In my attempts to solve this problem, I've added many of these:

$sth->finish();

And some of thse:

undef $dbh;

And this to database.pm

$dbh_pg->{AutoInactiveDestroy} = 1;

Also added in this release:

* column alignments
dlangille added a commit to FreshPorts/ports that referenced this issue Jun 1, 2025
After moving from perl 5.38 to perl 5.40, DBI errors started to show up.

DBI db handle 0x86ba253f2a0 has 1 uncleared child handles during global destruction.
    dbih_clearcom (dbh 0x86ba253f2a0, com 0x86ba1ba90c0, imp DBD::Pg::db):
       FLAGS 0x580111: COMSET Warn PrintError PrintWarn
       PARENT DBI::dr=HASH(0x86ba2540480)
       KIDS 1 (0 Active)

It is not clear why or how to clean it up.

re: perl5-dbi/dbi#171
    Perl/perl5#23306

In my attempts to solve this problem, I've added many of these:

$sth->finish();

And a few of these (load_xml_into_db.pl, load_xml_into_db_git.pl):

END {
   $dbh->disconnect();
}

Also added in this release:

* Jail/upgrade-jail-via-replace.sh
  - re https://news.freshports.org/2025/03/27/updating-a-jail-by-replacing-it/

* archive-messages.sh
  - searched only one directory deep, so I can store failed results in subdirectories
@dlangille
Copy link

I had a package like this:

#!/usr/local/bin/perl -w
#
# Copyright (c) 2014 DVL Software
#

package FreshPorts::Branches;

...

sub SetBranchInDB($$) {
  my $dbh    = shift();
  my $branch = shift();

  $sql = 'select freshports_branch_set(' . $dbh->quote($branch) . ')';
  $sth = $dbh->prepare($sql);
  if (!$sth->execute())  {
    FreshPorts::Utilities::Report('warning', "SetBranchInDB: Could not set branch:" .  $dbh->errstr);
  }
  
  $sth->finish();

  undef $sth;
}

1;

Adding the undef $sth; removed this error for me:

DBI db handle 0x210727eb2090 has 1 uncleared child handles during global destruction.
    dbih_clearcom (dbh 0x210727eb2090, com 0x210727ab6780, imp DBD::Pg::db):
       FLAGS 0x500111: COMSET Warn PrintError PrintWarn 
       PARENT DBI::dr=HASH(0x210727eb3258)
       KIDS 1 (0 Active)

This changes my approach to cleaning up this error under Perl 5.40 - previously, I was looking mostly at $sth->finish();

@Tux
Copy link
Contributor
Tux commented Jun 2, 2025

IMHO it is the DBD that should guarantee the correct order of destruction, not the DBI.
If someone could point me at how the DBI should/could do that, I could steer towards a release.

See e.g.: https://github.com/perl5-dbi/DBD-Unify/blob/master/dbdimp.ic#L902

@esabol
Copy link
Contributor
esabol commented Jun 2, 2025

DBD::Pg hasn't had this problem with any version of Perl through Perl 5.38, but it's somehow DBI or the DBDs which are at fault here? Okaaaaaaayyy....

@vvv2542
Copy link
Author
vvv2542 commented Jun 2, 2025

The same problem with DBD::mysql also starting from perl 5.40. I still think that the reason is the change in perl's behavior.

@Leont
Copy link
Contributor
Leont commented Jun 3, 2025

Has someone tried to bisect the change in behavior? Right now we don't even know which development release was involved.

@richardleach
Copy link
Contributor

FWIW: I couldn't reproduce this using the OP test script and following combination, all built from source:

  • Perl 5.40.0
  • DBI 1.647
  • DBD:Pg 3.18.0

I'll do a 5.40.2 build, just in case it was something in a maint release.

@richardleach
Copy link
Contributor

I'll do a 5.40.2 build, just in case it was something in a maint release.

Nope, still can't reproduce with 5.40.2 built from source. Those were gcc builds, will try with clang, since that's what the OP's perl was built with.

# DBI                         Version 1.647
# DBD::Pg                     Version 3.18.0
# Perl                        Version 5.40.2
# OS                          linux
# PostgreSQL (compiled)       150013
# PostgreSQL (target)         150013
# PostgreSQL (reported)       PostgreSQL 15.13 (Debian 15.13-0+deb12u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit

@richardleach
Copy link
Contributor

I couldn't reproduce with clang on this VM either. No warnings from threaded or non-threaded builds.

Not sure if it's a build environment difference or what.

Summary of my perl5 (revision 5 version 40 subversion 2) configuration:
  Commit id: 2e0f6a60c12ff9b5fd18e5a18d350b4366ea12b7
  Platform:
    osname=linux
    osvers=6.1.0-35-amd64
    archname=x86_64-linux
    uname='linux perlporting 6.1.0-35-amd64 #1 smp preempt_dynamic debian 6.1.137-1 (2025-05-07) x86_64 gnulinux '
    config_args='-des -Dusethreds -Dcc=clang-14 -Dprefix=/home/rich/installs/5.40.2_clang'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='clang-14'
    ccflags ='-fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O2'
    cppflags='-fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='Debian Clang 14.0.6'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='clang-14'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib/llvm-14/lib/clang/14.0.6/lib /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /usr/lib64
    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/lib/x86_64-linux-gnu/libc.so.6
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.36'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under linux
  Compiled at Jun  3 2025 20:52:54
  @INC:
    /home/rich/installs/5.40.2_clang/lib/perl5/site_perl/5.40.2/x86_64-linux
    /home/rich/installs/5.40.2_clang/lib/perl5/site_perl/5.40.2
    /home/rich/installs/5.40.2_clang/lib/perl5/5.40.2/x86_64-linux
    /home/rich/installs/5.40.2_clang/lib/perl5/5.40.2
# DBI                         Version 1.647
# DBD::Pg                     Version 3.18.0
# Perl                        Version 5.40.2
# OS                          linux
# PostgreSQL (compiled)       150013
# PostgreSQL (target)         150013
# PostgreSQL (reported)       PostgreSQL 15.13 (Debian 15.13-0+deb12u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit

@esabol
Copy link
Contributor
esabol commented Jun 5, 2025

@richardleach wrote:

I couldn't reproduce with clang on this VM either. No warnings from threaded or non-threaded builds.

Not sure if it's a build environment difference or what.

Very interesting! Thanks for doing all that testing, @richardleach.

@vvv2542 : Can you provide additional details on your builds and host configuration?

Can you reproduce this error in a Docker container and share the Dockerfile? That would be unimpeachable, I think.

@vvv2542
Copy link
Author
vvv2542 commented Jun 5, 2025

I can reproduce it only on FreeBSD:

  1. Install FreeBSD 14.2-RELEASE.
  2. Replace "quarterly" to "latest" in /etc/pkg/FreeBSD.conf.
  3. Run "pkg install p5-DBD-Pg".
  4. Run scrip 6D40 t from the first message.

@guest20
Copy link
guest20 commented Jun 12, 2025

You need to tell git-bisect how to identify the issue, so you want to redirect / grep in the bisect script, bisect can actually do its bisecting. The bisect picks which side of the current commit to search based on the script exiting with success / failure.

You can your-thing 2>&1 | grep 'that warning' in your script ... it depends on who's grep you have as to which flags you need to make it exit with 1 when it doesn't match and 0 when it does.

Edit: That previous comment sounds confused about git-bisect chasing failure or success exits because I'm not sure if bisect wants to find the first commit where the script exits with non-success or success

@thesamesam
Copy link

because I'm not sure if bisect wants to find the first commit where the script exits with non-success or success

Non-success.

@jkeenan
Copy link
9E88
Contributor
jkeenan commented Jun 12, 2025

... because I'm not sure if bisect wants to find the first commit where the script exits with non-success or success

Porting/bisect.pl is a wrapper around git bisect. The latter tries the end commit first; if it exits 0 -- as is currently happening -- then there's nothing more to be done. If, as expected, it exits non-zero, then it tries the start commit, which is expected to pass. Assuming it does, the bisection algorithm then kicks in and commits are tried until the first failing commit is identified. Once you're past the startcommit, a series of files are created in the./.git` subdirectory that enable you to inspect the progress of the program. I frequently watch that progress with something like:

$ cd .git
$ watch -n 120 "cat BISECT_RUN; tail BISECT_LOG"

(On FreeBSD use cmdwatch.)

One of the challenges of bisecting a test program (as we're doing here) is writing something that unambiguously exits 0 of 1. I suspect that's the problem we're facing here. However, there's also a chance that the problem is not in the Perl core; it could be in DBI, DBD::Pg, Postgres, or the OS. (Unfortunately, I won't have more time to spend on this problem until next week.)

@guest20
Copy link
guest20 commented Jun 12, 2025

@thesamesam Exactly. Locating the failing commit indicates that you've succeeded.

@dlangille
Copy link

Using this:

perl540% perl Porting/bisect.pl \
--start=v5.40.0 \
--end=v5.40.2 \
--module=DBI,DBD::Pg \
-- ./perl -Ilib ../perl5-issue-23306 > ~/log.txt 2>&1
perl540% 

I found this:

perl540% grep 'global destruction' log.txt
	(in cleanup) dbih_getcom handle DBI::dr=HASH(0x351bdfca1090) is not a DBI handle (has no magic) during global destruction.
	(in cleanup) dbih_getcom handle DBI::dr=HASH(0x2c4558ac25a0) is not a DBI handle (has no magic) during global destruction.
# Not testing global destruction
perl540% 

Looking through the logs, I find this:

# --- Perl 5.040002 on amd64-freebsd
t/01basics.t .................... ok
        (in cleanup) dbih_getcom handle DBI::dr=HASH(0x351bdfca1090) is not a DBI handle (has no magic) during global destruction.
...
# --- Perl 5.040002 on amd64-freebsd
t/zvg_01basics.t ................ ok
        (in cleanup) dbih_getcom handle DBI::dr=HASH(0x2c4558ac25a0) is not a DBI handle (has no magic) during global destruction.

Does this help?

@Leont
Copy link
Contributor
Leont commented Jun 12, 2025

Does this help?

No, that range doesn't make sense. You mentioned you observed it in 5.38, so the correct range would be v5.36.0 to v5.38.0

@vvv2542
Copy link
Author
vvv2542 commented Jun 12, 2025

The problem appeared in 5.40. 5.38 works fine in the same environment.

@dlangille
Copy link

Does this help?

No, that range doesn't make sense. You mentioned you observed it in 5.38, so the correct range would be v5.36.0 to v5.38.0

The problem never occurred when I was using 5.38.

I first noticed the problem after installing 5.40 - now the problem happens randomly and is not repeatable with my code - however, it is repeatable every time with the small example shown at #23306 (comment)

@Leont
Copy link
Contributor
Leont commented Jun 12, 2025

The problem never occurred when I was using 5.38.

Sorry I misread. Then you need to bisect v5.38.0 to v5.40.0

@dlangille
Copy link

Latest test we're running is:

[Jun 12 17:15]  <dvl> perl540% perl Porting/bisect.pl --start=v5.38.0 --end=v5.40.2 --with-module=DBI,DBD::Pg --no-module-tests -- /tmp/test.sh

with

perl540% cat /tmp/test.sh
#!/bin/sh

# Invoke me with this script at /tmp/test.sh and run this in ~/perl5:
#  perl Porting/bisect.pl --start=v5.38.0 --end=v5.40.0  --module=DBI,DBD::Pg -- /tmp/test.sh
set -x

# ~/perl5/perl is the just-built Perl from Porting/bisect.pl
#
# ~/perl5-issue-23306 is the Perl script that is buggy with some Perl versions
# that we're testing.
~/perl5/perl -I~/perl5/lib ~/perl5-issue-23306 &> log.txt
if grep -q "cleared whilst still active during global destruction" log.txt ; then
        # It has the error message we're interested in, so bad.
        exit 1
fi

# If we got here, it's fine.
exit 0
perl540% 

@khwilliamson
Copy link
Contributor

Are you using MacOS 15 (Darwin 24) or higher.

@khwilliamson
Copy link
Contributor

On irc, it was pointed out that we turned of Darwin locale collation in 9e3a653 due to a bug in Apple.

Apple took its locale handling code from FreeBSD many fixes ago, and has not kept up with FreBSD fixes. I have at least one bug report submitted to FreeBSD with no sign of their being interested in fixing it/them.

@Leont
Copy link
Contributor
Leont commented Jun 13, 2025

On irc, it was pointed out that we turned of Darwin locale collation in 9e3a653 due to a bug in Apple.

Apple took its locale handling code from FreeBSD many fixes ago, and has not kept up with FreBSD fixes. I have at least one bug report submitted to FreeBSD with no sign of their being interested in fixing it/them.

I'm guessing this response belongs in #23368 instead?

@khwilliamson
Copy link
Contributor
10000 khwilliamson commented Jun 13, 2025

Yes. sorry

@dlangille
Copy link

Now testing with:

perl540% export PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT=1
perl540% perl Porting/bisect.pl --no-clean --start=v5.40.2 --end=v5.40.2 --with-module=DBI,DBD::Pg,Mozilla::CA --no-module-tests -- /tmp/test.sh

@dlangille
Copy link

By request via IRC:

perl540% DBI_TRACE=10 perl ./perl5-issue-23306 
    DBI 1.647-ithread default trace level set to 0x0/10 (pid 48935 pi 28dca7e1d000) at DBI.pm line 298 via perl5-issue-23306 line 5
install_method DBI::st::bind_columns
install_method DBI::st::finish      
install_method DBI::st::blob_read   
install_method DBI::st::bind_param_array
install_method DBI::st::fetchrow    
install_method DBI::st::fetchall_hashref
install_method DBI::st::fetchrow_arrayref
install_method DBI::st::cancel      , flags 0x0800
install_method DBI::st::blob_copy_to_file
install_method DBI::st::execute_for_fetch, flags 0x5040
install_method DBI::st::bind_param_inout_array
install_method DBI::st::rows        , flags 0x0004
install_method DBI::st::fetchrow_array
install_method DBI::st::fetchall_arrayref
install_method DBI::st::fetchrow_hashref
install_method DBI::st::_set_fbav   , T 0x00000006
install_method DBI::st::bind_param  
install_method DBI::st::more_results
install_method DBI::st::execute     , flags 0x1040
install_method DBI::st::execute_array, flags 0x5040
install_method DBI::st::fetch       
install_method DBI::st::dump_results
install_method DBI::st::_get_fbav   
install_method DBI::st::last_insert_id, flags 0x2800
install_method DBI::st::bind_col    
install_method DBI::st::bind_param_inout
install_method DBI::db::selectcol_arrayref, flags 0x2000
install_method DBI::db::take_imp_data, flags 0x10000
install_method DBI::db::primary_key , flags 0x2200
install_method DBI::db::selectrow_arrayref, flags 0x2000
install_method DBI::db::tables      , flags 0x2200
install_method DBI::db::selectall_arrayref, flags 0x2000
install_method DBI::db::rows        , flags 0x0004
install_method DBI::db::selectall_array, flags 0x2000
install_method DBI::db::selectrow_array, flags 0x2000
install_method DBI::db::primary_key_info, flags 0xaa00
install_method DBI::db::data_sources, flags 0x0200
install_method DBI::db::rollback    , flags 0x0c80, T 0x00001000
install_method DBI::db::preparse    
install_method DBI::db::foreign_key_info, flags 0xaa00
install_method DBI::db::disconnect  , flags 0x10c00, T 0x00000200
install_method DBI::db::do          , flags 0x3200
install_method DBI::db::type_info   , flags 0x2200
install_method DBI::db::last_insert_id, flags 0x2800
install_method DBI::db::get_info    , flags 0x2a00
install_method DBI::db::prepare_cached, flags 0xa200
install_method DBI::db::clone       , T 0x00000200
install_method DBI::db::selectrow_hashref, flags 0x2000
install_method DBI::db::selectall_hashref, flags 0x2000
install_method DBI::db::type_info_all, flags 0x2a00
install_method DBI::db::connected   , flags 0x0004, T 0x00000200, H 3
install_method DBI::db::begin_work  , flags 0x0400, T 0x00001000
install_method DBI::db::table_info  , flags 0xaa00
install_method DBI::db::ping        , flags 0x0404
install_method DBI::db::quote       , flags 0x0430, T 0x00000002
install_method DBI::db::commit      , flags 0x0c80, T 0x00001000
install_method DBI::db::statistics_info, flags 0xaa00
install_method DBI::db::column_info , flags 0xaa00
install_method DBI::db::quote_identifier, flags 0x0430, T 0x00000002
install_method DBI::db::prepare     , flags 0xa200
install_method DBI::dr::disconnect_all, flags 0x0800, T 0x00000200
install_method DBI::dr::dbixs_revision, flags 0x0004
install_method DBI::dr::data_sources, flags 0x0800, T 0x00000200
install_method DBI::dr::default_user, T 0x00000200
install_method DBI::dr::connect     , flags 0x8000, T 0x00000200, H 3
install_method DBI::dr::connect_cached, flags 0x8000, T 0x00000200, H 3
install_method DBI::common::DELETE  , flags 0x0404
install_method DBI::common::FETCH_many, flags 0x0404
install_method DBI::common::FETCH   , flags 0x0404
install_method DBI::common::can     , flags 0x0100
install_method DBI::common::private_data, flags 0x0004
install_method DBI::common::visit_child_handles, flags 0x0404, T 0x00000004
install_method DBI::common::swap_inner_handle
install_method DBI::common::parse_trace_flags, flags 0x0404, T 0x00000008
install_method DBI::common::dump_handle, flags 0x0004
install_method DBI::common::CLEAR   , flags 0x0004
install_method DBI::common::errstr  , flags 0x0004
install_method DBI::common::STORE   , flags 0x041c
install_method DBI::common::err     , flags 0x0004
install_method DBI::common::trace_msg, flags 0x0004, T 0x00000008
install_method DBI::common::trace   , flags 0x0004
install_method DBI::common::parse_trace_flag, flags 0x0404, T 0x00000008
install_method DBI::common::FIRSTKEY, flags 0x0004
install_method DBI::common::EXISTS  , flags 0x0004
install_method DBI::common::DESTROY , flags 0x10004
install_method DBI::common::NEXTKEY , flags 0x0004
install_method DBI::common::state   , flags 0x0004
install_method DBI::common::set_err , flags 0x0010
install_method DBI::common::debug   , flags 0x0004
install_method DBI::common::private_attribute_info
install_method DBI::common::func    , flags 0x0006
    -> DBI->connect(dbi:Pg:dbname=template1;, postgres, ****)
    -> DBI->install_driver(Pg) for freebsd perl=5.040002 pid=48935 ruid=1001 euid=1001
       install_driver: DBD::Pg version 3.18.0 loaded from /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm
    New 'DBI::dr' (for DBD::Pg::dr, parent='', id=undef)
    dbih_setup_handle(DBI::dr=HASH(0x28dca8843b70)=>DBI::dr=HASH(0x28dca8843ae0), DBD::Pg::dr, 0, Null!)
    dbih_make_com(Null!, 0, DBD::Pg::dr, 152, 0) thr#28dca7e1d000
    dbih_setup_attrib(DBI::dr=HASH(0x28dca8843ae0), Err, Null!) SCALAR(0x28dca87bfa80) (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x28dca8843ae0), State, Null!) SCALAR(0x28dca87bfb40) (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x28dca8843ae0), Errstr, Null!) SCALAR(0x28dca87bfae0) (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x28dca8843ae0), TraceLevel, Null!) 0 (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x28dca8843ae0), FetchHashKeyName, Null!) 'NAME' (already defined)
install_method DBI::db::pg_cancel   
install_method DBI::db::pg_endcopy  
install_method DBI::db::pg_error_field
install_method DBI::db::pg_getline  
install_method DBI::db::pg_getcopydata
install_method DBI::db::pg_getcopydata_async
install_method DBI::db::pg_notifies 
install_method DBI::db::pg_putcopydata
install_method DBI::db::pg_putcopyend
install_method DBI::db::pg_ping     
install_method DBI::db::pg_putline  
install_method DBI::db::pg_ready    
install_method DBI::db::pg_release  
install_method DBI::db::pg_result   
install_method DBI::db::pg_rollback_to
install_method DBI::db::pg_savepoint
install_method DBI::db::pg_server_trace
install_method DBI::db::pg_server_untrace
install_method DBI::db::pg_type_info
install_method DBI::st::pg_cancel   
install_method DBI::st::pg_result   
install_method DBI::st::pg_ready    
install_method DBI::st::pg_canonical_ids
install_method DBI::st::pg_canonical_names
install_method DBI::db::pg_lo_creat 
install_method DBI::db::pg_lo_open  
install_method DBI::db::pg_lo_write 
install_method DBI::db::pg_lo_read  
install_method DBI::db::pg_lo_lseek 
install_method DBI::db::pg_lo_lseek64
install_method DBI::db::pg_lo_tell  
install_method DBI::db::pg_lo_tell64
install_method DBI::db::pg_lo_truncate
install_method DBI::db::pg_lo_truncate64
install_method DBI::db::pg_lo_close 
install_method DBI::db::pg_lo_unlink
install_method DBI::db::pg_lo_import
install_method DBI::db::pg_lo_import_with_oid
install_method DBI::db::pg_lo_export
    <- install_driver= DBI::dr=HASH(0x28dca8843b70)
    >> default_user DISPATCH (DBI::dr=HASH(0x28dca8843b70) rc1/3 @4 g3 ima1 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 671 via  at ./perl5-issue-23306 line 10
    !! The warn '0' was CLEARED by call to default_user method
    -> default_user in DBD::_::dr for DBD::Pg::dr (DBI::dr=HASH(0x28dca8843b70)~0x28dca8843ae0 'postgres' undef HASH(0x28dca86862b8)) thr#28dca7e1d000
    <- default_user= ( 'postgres' undef ) [2 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 671 via  at ./perl5-issue-23306 line 10
    >> connect     DISPATCH (DBI::dr=HASH(0x28dca8843b70) rc2/3 @5 g2 ima8001 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 683
    -> connect for DBD::Pg::dr (DBI::dr=HASH(0x28dca8843b70)~0x28dca8843ae0 'dbname=template1;' 'postgres' **** HASH(0x28dca86862b8)) thr#28dca7e1d000
    New 'DBI::db' (for DBD::Pg::db, parent=DBI::dr=HASH(0x28dca8843ae0), id=undef)
    dbih_setup_handle(DBI::db=HASH(0x28dca8842768)=>DBI::db=HASH(0x28dca8842858), DBD::Pg::db, 28dca7f8a228, Null!)
    dbih_make_com(DBI::dr=HASH(0x28dca8843ae0), 28dca7ead2c0, DBD::Pg::db, 272, 0) thr#28dca7e1d000
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), Err, DBI::dr=HASH(0x28dca8843ae0)) SCALAR(0x28dca7f8a480) (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), State, DBI::dr=HASH(0x28dca8843ae0)) SCALAR(0x28dca7f8a510) (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), Errstr, DBI::dr=HASH(0x28dca8843ae0)) SCALAR(0x28dca7f8a4c8) (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), TraceLevel, DBI::dr=HASH(0x28dca8843ae0)) 0 (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), FetchHashKeyName, DBI::dr=HASH(0x28dca8843ae0)) 'NAME' (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), HandleSetErr, DBI::dr=HASH(0x28dca8843ae0)) undef (not defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), HandleError, DBI::dr=HASH(0x28dca8843ae0)) undef (not defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), ReadOnly, DBI::dr=HASH(0x28dca8843ae0)) undef (not defined)
    dbih_setup_attrib(DBI::db=HASH(0x28dca8842858), Profile, DBI::dr=HASH(0x28dca8843ae0)) undef (not defined)
Begin dbd_db_login
Login connection string: (dbname=template1  user='postgres')
PQconnectdb
Connection complete
PQstatus
PQsetNoticeProcessor
PQprotocolVersion
PQserverVersion
End dbd_db_login
    >> FETCH       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @2 g2 ima404 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 266 via  at ./perl5-issue-23306 line 10
    -> FETCH for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'pg_server_version') thr#28dca7e1d000
Begin dbd_db_FETCH (key: pg_server_version)
End dbd_db_FETCH_attrib
    <- FETCH= ( 170005 ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 266 via  at ./perl5-issue-23306 line 10
    >> FETCH       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @2 g2 ima404 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 267 via  at ./perl5-issue-23306 line 10
    -> FETCH for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'private_dbdpg') thr#28dca7e1d000
Begin dbd_db_FETCH (key: private_dbdpg)
End dbd_db_FETCH_attrib
    .. FETCH DBI::db=HASH(0x28dca8842858) 'private_dbdpg' = undef
    <- FETCH= ( undef ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 267 via  at ./perl5-issue-23306 line 10
    >> STORE       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @3 g2 ima41c pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 267 via  at ./perl5-issue-23306 line 10
    -> STORE for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'private_dbdpg' HASH(0x28dca8842498) (magic-r:p)) thr#28dca7e1d000
Begin dbd_db_STORE (key: private_dbdpg newval: 1 kl:13)
End dbd_db_STORE_attrib
    STORE DBI::db=HASH(0x28dca8842858) 'private_dbdpg' => HASH(0x28dca8842498) (magic-r:p)
    <- STORE= ( 1 ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 267 via  at ./perl5-issue-23306 line 10
    >> FETCH       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @2 g2 ima404 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 267 via  at ./perl5-issue-23306 line 10
    <> FETCH= ( HASH(0x28dca8842498)0keys ) [1 items] ('private_dbdpg' from cache) at /usr/local/lib/perl5/site_perl/mach/5.40/DBD/Pg.pm line 267 via  at ./perl5-issue-23306 line 10
    <- connect= ( DBI::db=HASH(0x28dca8842768) ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 683
    >> STORE       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @3 g2 ima41c pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 735
    -> STORE for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'PrintError' 1 (magic-r:p)) thr#28dca7e1d000
Begin dbd_db_STORE (key: PrintError newval: 1 kl:10)
End dbd_db_STORE_attrib
    STORE DBI::db=HASH(0x28dca8842858) 'PrintError' => 1 (magic-r:p)
    <- STORE= ( 1 ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 735
    >> STORE       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @3 g2 ima41c pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 735
    -> STORE for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'AutoCommit' 1 (magic-r:p)) thr#28dca7e1d000
Begin dbd_db_STORE (key: AutoCommit newval: 1 kl:10)
Begin dbd_db_commit
Begin pg_db_rollback_commit (action: commit AutoCommit: 0 BegunWork: 0)
Begin PGTransactionStatusType
PQtransactionStatus
dbd_db_commit txn_status is 0
End pg_db_rollback_commit (result: 1)
Setting AutoCommit to 'on' forced a commit
End dbd_db_STORE_attrib
    <- STORE= ( 1 ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 735
    >> STORE       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @3 g2 ima41c pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 738 via  at ./perl5-issue-23306 line 10
    -> STORE for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'Username' 'postgres' (magic-r:p)) thr#28dca7e1d000
Begin dbd_db_STORE (key: Username newval: 1 kl:8)
End dbd_db_STORE_attrib
    STORE DBI::db=HASH(0x28dca8842858) 'Username' => 'postgres' (magic-r:p)
    <- STORE= ( 1 ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 738 via  at ./perl5-issue-23306 line 10
    >> connected   DISPATCH (DBI::db=HASH(0x28dca8842768) rc1/1 @3 g1 ima5 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 745
    -> connected in DBD::_::db for DBD::Pg::db (DBI::db=HASH(0x28dca8842768)~0x28dca8842858 'dbi:Pg:dbname=template1;' 'postgres') thr#28dca7e1d000
    <- connected= ( undef ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 745
    <- connect= DBI::db=HASH(0x28dca8842768)
    >> STORE       DISPATCH (DBI::db=HASH(0x28dca8842858) rc2/1 @3 g2 ima41c pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 754 via  at ./perl5-issue-23306 line 10
    -> STORE for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER 'dbi_connect_closure' CODE(0x28dca7e9abb8) (magic-r:p)) thr#28dca7e1d000
Begin dbd_db_STORE (key: dbi_connect_closure newval: 1 kl:19)
End dbd_db_STORE_attrib
    STORE DBI::db=HASH(0x28dca8842858) 'dbi_connect_closure' => CODE(0x28dca7e9abb8) (magic-r:p)
    <- STORE= ( 1 ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 754 via  at ./perl5-issue-23306 line 10
DONE
    -- DBI::END ($@: , $!: )
    >> disconnect_all DISPATCH (DBI::dr=HASH(0x28dca8843b70) rc1/4 @1 g1 ima801 pid#48935) at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 762 via  at ./perl5-issue-23306 line 0
    -> disconnect_all for DBD::Pg::dr (DBI::dr=HASH(0x28dca8843b70)~0x28dca8843ae0) thr#28dca7e1d000
Begin dbd_discon_all
End dbd_discon_all
    <- disconnect_all= ( '' ) [1 items] at /usr/local/lib/perl5/site_perl/mach/5.40/DBI.pm line 762 via  at ./perl5-issue-23306 line 0
    >> DESTROY     DISPATCH (DBI::db=HASH(0x28dca8842858) rc1/1 @1 g1 ima10004 pid#48935)
    -> DESTROY for DBD::Pg::db (DBI::db=HASH(0x28dca8842858)~INNER) thr#28dca7e1d000
Begin dbd_db_disconnect
Begin dbd_db_rollback
Begin pg_db_rollback_commit (action: rollback AutoCommit: 1 BegunWork: 0)
End pg_db_rollback_commit (result: 0)
PQfinish
Disconnection complete
End dbd_db_disconnect
Begin dbd_db_destroy
End dbd_db_destroy
    <- DESTROY= ( ) [0 items]
    DESTROY (dbih_clearcom) (dbh 0x28dca8842768, com 0x28dca7ebda80, imp DBD::Pg::db):
       FLAGS 0x100311: COMSET Warn PrintError PrintWarn AutoCommit 
       PARENT undef
       KIDS 0 (0 Active)
    dbih_clearcom 0x28dca8842768 (com 0x28dca7ebda80, type 2) done.

    >> DESTROY     DISPATCH (DBI::dr=HASH(0x28dca8843b70) rc1/1 @1 g1 ima10004 pid#48935)
    <> DESTROY(DBI::dr=HASH(0x28dca8843b70)) ignored for outer handle (inner DBI::dr=HASH(0x28dca8843ae0) has ref cnt 1)
    >> DESTROY     DISPATCH (DBI::dr=HASH(0x28dca8843ae0) rc1/1 @1 g1 ima10004 pid#48935)
    -> DESTROY in DBD::_::common for DBD::Pg::dr (DBI::dr=HASH(0x28dca8843ae0)~INNER) thr#28dca7e1d000
    <- DESTROY= ( undef ) [1 items]
    DESTROY (dbih_clearcom) (drh 0x28dca8843ae0, com 0x28dca7ead2c0, imp DBD::Pg::dr):
       FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit 
       PARENT undef
       KIDS 0 (1 Active)
DBI dr handle 0x28dca8843ae0 cleared whilst still active during global destruction.
    dbih_clearcom 0x28dca8843ae0 (com 0x28dca7ead2c0, type 1) done.

    >> DESTROY     DISPATCH (DBI::db=HASH(0x28dca8842768) rc1/1 @1 g1 ima10004 pid#48935)
    <> DESTROY for DBI::db=HASH(0x28dca8842768) ignored (inner handle gone)

@dlangille
Copy link

Updated the script to not use ~

After hitting: Can't locate strict.pm despite strict.pm being in ./lib/strict.pm

perl540% cat /tmp/test.sh
#!/bin/sh
 
# Invoke me with this script at /tmp/test.sh and run this in ~/perl5:
#  perl Porting/bisect.pl --start=v5.38.0 --end=v5.40.0  --module=DBI,DBD::Pg -- /tmp/test.sh
set -x
 
# ~/perl5/perl is the just-built Perl from Porting/bisect.pl
#
# ~/perl5-issue-23306 is the Perl script that is buggy with some Perl versions
# that we're testing.
/home/dvl/perl5/perl -I/home/dvl/perl5/lib /home/dvl/perl5-issue-23306 &> log.txt
 
grep -q "cleared whilst still active during global destruction" log.txt && exit 1
 
# If we got here, it's fine.
exit 0

@dlangille
Copy link

Adjusted that script to log both STDIN and STDOUT: > log.txt 2>&1

Proceeding again, this time with:

git reset --hard HEAD ; git clean -fdx
export PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT=1
perl Porting/bisect.pl --no-clean --start=v5.40.2 --end=v5.40.2 --with-module=DBI,DBD::Pg,Mozilla::CA,warnings::register --no-module-tests -- /tmp/test.sh

@esabol
Copy link
Contributor
esabol commented Jun 13, 2025

@dlangille wrote:

--start=v5.40.2 --end=v5.40.2

That doesn't seem right...

@dlangille
Copy link
dlangille commented Jun 13, 2025

@dlangille wrote:

--start=v5.40.2 --end=v5.40.2

That doesn't seem right...

Right now, we are struggling to get a fully complete run of bisect, so we're concentrating on a single run of a version we know to be bad. Once we get that, we'll expand the range.

Thank you for pointing that out. Please continue doing that. It is appreciated.

@dlangille
Copy link

The most recent run, on perl 5.40.2, same as what's in my test host gives. Next goal: Compare perl configuration values for both host and the one created by bisect.

Appending installation info to /tmp/Cm5ezMFavv/lib/perl5/5.40.2/amd64-freebsd/perllocal.pod
  TODDR/IO-Tty-1.20.tar.gz
  /usr/bin/make install  -- OK
  TIMLEGGE/Module-Signature-0.90.tar.gz
  Has already been unwrapped into directory /tmp/YI05pYyNgk/Module-Signature-0.90-0
  TIMLEGGE/Module-Signature-0.90.tar.gz
  Has already been prepared
Running make for T/TI/TIMLEGGE/Module-Signature-0.90.tar.gz
cp lib/Module/Signature.pm blib/lib/Module/Signature.pm
cp script/cpansign blib/script/cpansign
"/tmp/Cm5ezMFavv/bin/perl" "-Iinc" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/cpansign
  TIMLEGGE/Module-Signature-0.90.tar.gz
  /usr/bin/make -- OK
  TIMLEGGE/Module-Signature-0.90.tar.gz
  Skipping test because of notest pragma
Running make install for TIMLEGGE/Module-Signature-0.90.tar.gz
Installing /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2/Module/Signature.pm
Installing /tmp/Cm5ezMFavv/bin/cpansign
Appending installation info to /tmp/Cm5ezMFavv/lib/perl5/5.40.2/amd64-freebsd/perllocal.pod
  TIMLEGGE/Module-Signature-0.90.tar.gz
  /usr/bin/make install  -- OK
warnings::register is up to date (1.06).
+ /home/dvl/perl5/perl -I/home/dvl/perl5/lib /home/dvl/perl5-issue-23306
+ grep -q 'cleared whilst still active during global destruction' log.txt
+ exit 0
good - zero exit from /tmp/test.sh
Runner returned 0 for end revision at Porting/bisect.pl line 233.
That took 5100 seconds.
perl540% cat log.txt 
DONE
perl540% 



perl540% cat /tmp/test.sh
#!/bin/sh

# Invoke me with this script at /tmp/test.sh and run this in ~/perl5:
#  perl Porting/bisect.pl --start=v5.38.0 --end=v5.40.0  --module=DBI,DBD::Pg -- /tmp/test.sh
set -x

# ~/perl5/perl is the just-built Perl from Porting/bisect.pl
#
# ~/perl5-issue-23306 is the Perl script that is buggy with some Perl versions
# that we're testing.
/home/dvl/perl5/perl -I/home/dvl/perl5/lib /home/dvl/perl5-issue-23306 > log.txt 2>&1

grep -q "cleared whilst still active during global destruction" log.txt && exit 1

# If we got here, it's fine.
exit 0



perl540% cat /home/dvl/perl5-issue-23306
#!/usr/bin/env perl

use strict;
use warnings;
use DBI;



#require FreshPorts::config;
my $dbh = DBI->connect("dbi:Pg:dbname=template1;", "postgres");

print "DONE\n";
exit 0;

sub sub1 {
    $dbh = "";
}

@dlangille
Copy link
dlangille commented Jun 14, 2025

perl, as built by the FreeBSD project. I also build my own packages and can easily change the configuration options for perl.

perl540% /usr/local/bin/perl -V
Summary of my perl5 (revision 5 version 40 subversion 2) configuration:
   
  Platform:
    osname=freebsd
    osvers=14.2-release-p3
    archname=amd64-freebsd-thread-multi
    uname='freebsd 142amd64-default-job-01 14.2-release-p3 freebsd 14.2-release-p3 amd64 '
    config_args='-Darchlib=/usr/local/lib/perl5/5.40/mach -Dcc=cc -Dcf_by=mat -Dcf_email=mat@FreeBSD.org -Dcf_time=Sun Apr 13 13:07:13 UTC 2025 -Dinc_version_list=none -Dlibperl=libperl.so.5.40.2 -Dman1dir=/usr/local/lib/perl5/5.40/perl/man/man1 -Dman3dir=/usr/local/lib/perl5/5.40/perl/man/man3 -Dprefix=/usr/local -Dprivlib=/usr/local/lib/perl5/5.40 -Dscriptdir=/usr/local/bin -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.40 -Dsitelib=/usr/local/lib/perl5/site_perl -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dusenm=n -Duseshrplib -sde -Ui_iconv -Ui_malloc -Uinstallusrbinperl -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5.40/work/perl-5.40.2 -L/usr/local/lib/perl5/5.40/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5.40/work/perl-5.40.2:N-L/usr/local/lib/perl5/5.40/mach/CORE:N-lperl) -Wl,-soname,$(LIBPERL:R) -Doptimize=-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Dusedtrace -Ui_gdbm -Dusemultiplicity=y -Duse64bitint -Dusemymalloc=n -Dusethreads=y'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    optimize='-O2 -pipe -fstack-protector-strong -fno-strict-aliasing '
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='FreeBSD Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags ='-pthread -Wl,-E  -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /usr/lib/clang/18/lib
    libs=-ldl -lm -lcrypt -lutil
    perllibs=-ldl -lm -lcrypt -lutil
    libc=
    so=so
    useshrplib=true
    libperl=libperl.so.5.40.2
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.40/mach/CORE'
    cccdlflags='-DPIC -fPIC'
    lddlflags='-shared  -L/usr/local/lib/perl5/5.40/mach/CORE -lperl -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Locally applied patches:
    FreeBSD:patch-Configure
    FreeBSD:patch-Makefile.SH
    FreeBSD:patch-cpan_ExtUtils-Install_lib_ExtUtils_Install.pm
    FreeBSD:patch-cpan_ExtUtils-Install_t_Install.t
    FreeBSD:patch-cpan_ExtUtils-MakeMaker_lib_ExtUtils_MM__Any.pm
    FreeBSD:patch-cpan_ExtUtils-MakeMaker_t_INST__PREFIX.t
    FreeBSD:patch-cpan_JSON-PP_bin_json__pp
    FreeBSD:patch-cpan_Pod-Perldoc_lib_Pod_Perldoc.pm
    FreeBSD:patch-cpan_Pod-Perldoc_lib_Pod_Perldoc_ToMan.pm
    FreeBSD:patch-cpan_Pod-Perldoc_lib_Pod_Perldoc_ToTerm.pm
    FreeBSD:patch-hints_freebsd.sh
    FreeBSD:patch-perl.c
    FreeBSD:patch-t_porting_customized.dat
  Built under freebsd
  %ENV:
    PERL5LIB="/home/dvl/perl5/lib/perl5"
    PERL_LOCAL_LIB_ROOT="/home/dvl/perl5"
    PERL_MB_OPT="--install_base "/home/dvl/perl5""
    PERL_MM_OPT="INSTALL_BASE=/home/dvl/perl5"
  @INC:
    /home/dvl/perl5/lib/perl5
    /usr/local/lib/perl5/site_perl/mach/5.40
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.40/mach
    /usr/local/lib/perl5/5.40
[8:20 pro04 dvl ~] % cat bisect
perl540% ./perl -V
Can't locate Config.pm in @INC (you may need to install the Config module) (@INC entries checked: /home/dvl/perl5/lib/perl5 /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2/amd64-freebsd /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2 /tmp/Cm5ezMFavv/lib/perl5/5.40.2/amd64-freebsd /tmp/Cm5ezMFavv/lib/perl5/5.40.2).
BEGIN failed--compilation aborted.
perl540% pwd                                                 
/home/dvl/perl5
perl540% ./perl -V -I/home/dvl/perl5/lib                     
Summary of my perl5 (revision 5 version 40 subversion 2) configuration:
  Commit id: 2e0f6a60c12ff9b5fd18e5a18d350b4366ea12b7
  Platform:
    osname=freebsd
    osvers=14.2-release-p1
    archname=amd64-freebsd
    uname='freebsd perl540 14.2-release-p1 freebsd 14.2-release-p1 generic amd64 '
    config_args='-dEs -Dcc=cc -Dld=cc -Doptimize=-g -Dusedevel -Dprefix=/tmp/Cm5ezMFavv -Uversiononly -Dinstallusrbinperl=n'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    optimize='-g'
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='FreeBSD Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags ='-Wl,-E  -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /usr/lib/clang/18/lib
    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags='-DPIC -fPIC'
    lddlflags='-shared  -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_DEVEL
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under freebsd
  Compiled at Jun 13 2025 19:23:25
  %ENV:
    PERL5LIB="/home/dvl/perl5/lib/perl5"
    PERL_LOCAL_LIB_ROOT="/home/dvl/perl5"
    PERL_MB_OPT="--install_base "/home/dvl/perl5""
    PERL_MM_OPT="INSTALL_BASE=/home/dvl/perl5"
  @INC:
    /home/dvl/perl5/lib
    /home/dvl/perl5/lib/perl5
    /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2/amd64-freebsd
    /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2
    /tmp/Cm5ezMFavv/lib/perl5/5.40.2/amd64-freebsd
    /tmp/Cm5ezMFavv/lib/perl5/5.40.2

@dlangille
Copy link

the bisect perl:

perl540% /home/dvl/perl5/perl -V -I/home/dvl/perl5/lib
Summary of my perl5 (revision 5 version 40 subversion 2) configuration:
  Commit id: 2e0f6a60c12ff9b5fd18e5a18d350b4366ea12b7
  Platform:
    osname=freebsd
    osvers=14.2-release-p1
    archname=amd64-freebsd
    uname='freebsd perl540 14.2-release-p1 freebsd 14.2-release-p1 generic amd64 '
    config_args='-dEs -Dcc=cc -Dld=cc -Doptimize=-g -Dusedevel -Dprefix=/tmp/Cm5ezMFavv -Uversiononly -Dinstallusrbinperl=n'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    optimize='-g'
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='FreeBSD Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags ='-Wl,-E  -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /usr/lib/clang/18/lib
    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags='-DPIC -fPIC'
    lddlflags='-shared  -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_DEVEL
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under freebsd
  Compiled at Jun 13 2025 19:23:25
  %ENV:
    PERL5LIB="/home/dvl/perl5/lib/perl5"
    PERL_LOCAL_LIB_ROOT="/home/dvl/perl5"
    PERL_MB_OPT="--install_base "/home/dvl/perl5""
    PERL_MM_OPT="INSTALL_BASE=/home/dvl/perl5"
  @INC:
    /home/dvl/perl5/lib
    /home/dvl/perl5/lib/perl5
    /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2/amd64-freebsd
    /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2
    /tmp/Cm5ezMFavv/lib/perl5/5.40.2/amd64-freebsd
    /tmp/Cm5ezMFavv/lib/perl5/5.40.2

@dlangille
Copy link

This is a diff of the two:

[8:23 pro04 dvl ~] % diff -ruN os bisect       
--- os	2025-06-14 08:17:21
+++ bisect	2025-06-14 08:23:39
@@ -1,19 +1,17 @@
-perl540% pkg which $(which perl)
-/usr/local/bin/perl was installed by package perl5-5.40.2_2
-perl540% /usr/local/bin/perl -V
+perl540% ./perl -V -I/home/dvl/perl5/lib                     
 Summary of my perl5 (revision 5 version 40 subversion 2) configuration:
-   
+  Commit id: 2e0f6a60c12ff9b5fd18e5a18d350b4366ea12b7
   Platform:
     osname=freebsd
-    osvers=14.2-release-p3
-    archname=amd64-freebsd-thread-multi
-    uname='freebsd 142amd64-default-job-01 14.2-release-p3 freebsd 14.2-release-p3 amd64 '
-    config_args='-Darchlib=/usr/local/lib/perl5/5.40/mach -Dcc=cc -Dcf_by=mat -Dcf_email=mat@FreeBSD.org -Dcf_time=Sun Apr 13 13:07:13 UTC 2025 -Dinc_version_list=none -Dlibperl=libperl.so.5.40.2 -Dman1dir=/usr/local/lib/perl5/5.40/perl/man/man1 -Dman3dir=/usr/local/lib/perl5/5.40/perl/man/man3 -Dprefix=/usr/local -Dprivlib=/usr/local/lib/perl5/5.40 -Dscriptdir=/usr/local/bin -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.40 -Dsitelib=/usr/local/lib/perl5/site_perl -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dusenm=n -Duseshrplib -sde -Ui_iconv -Ui_malloc -Uinstallusrbinperl -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5.40/work/perl-5.40.2 -L/usr/local/lib/perl5/5.40/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5.40/work/perl-5.40.2:N-L/usr/local/lib/perl5/5.40/mach/CORE:N-lperl) -Wl,-soname,$(LIBPERL:R) -Doptimize=-O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Dusedtrace -Ui_gdbm -Dusemultiplicity=y -Duse64bitint -Dusemymalloc=n -Dusethreads=y'
+    osvers=14.2-release-p1
+    archname=amd64-freebsd
+    uname='freebsd perl540 14.2-release-p1 freebsd 14.2-release-p1 generic amd64 '
+    config_args='-dEs -Dcc=cc -Dld=cc -Doptimize=-g -Dusedevel -Dprefix=/tmp/Cm5ezMFavv -Uversiononly -Dinstallusrbinperl=n'
     hint=recommended
     useposix=true
     d_sigaction=define
-    useithreads=define
-    usemultiplicity=define
+    useithreads=undef
+    usemultiplicity=undef
     use64bitint=define
     use64bitall=define
     uselongdouble=undef
@@ -22,7 +20,7 @@
   Compiler:
     cc='cc'
     ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
-    optimize='-O2 -pipe -fstack-protector-strong -fno-strict-aliasing '
+    optimize='-g'
     cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
     ccversion=''
     gccversion='FreeBSD Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)'
@@ -48,22 +46,22 @@
     prototype=define
   Linker and Libraries:
     ld='cc'
-    ldflags ='-pthread -Wl,-E  -fstack-protector-strong -L/usr/local/lib'
+    ldflags ='-Wl,-E  -fstack-protector-strong -L/usr/local/lib'
     libpth=/usr/lib /usr/local/lib /usr/lib/clang/18/lib
-    libs=-ldl -lm -lcrypt -lutil
-    perllibs=-ldl -lm -lcrypt -lutil
+    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
+    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
     libc=
     so=so
-    useshrplib=true
-    libperl=libperl.so.5.40.2
+    useshrplib=false
+    libperl=libperl.a
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dlopen.xs
     dlext=so
     d_dlsymun=undef
-    ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.40/mach/CORE'
+    ccdlflags=' '
     cccdlflags='-DPIC -fPIC'
-    lddlflags='-shared  -L/usr/local/lib/perl5/5.40/mach/CORE -lperl -L/usr/local/lib -fstack-protector-strong'
+    lddlflags='-shared  -L/usr/local/lib -fstack-protector-strong'
 
 
 Characteristics of this binary (from libperl): 
@@ -71,7 +69,6 @@
     HAS_LONG_DOUBLE
     HAS_STRTOLD
     HAS_TIMES
-    MULTIPLICITY
     PERLIO_LAYERS
     PERL_COPY_ON_WRITE
     PERL_DONT_CREATE_GVSV
@@ -80,10 +77,10 @@
     PERL_MALLOC_WRAP
     PERL_OP_PARENT
     PERL_PRESERVE_IVUV
+    PERL_USE_DEVEL
     PERL_USE_SAFE_PUTENV
     USE_64_BIT_ALL
     USE_64_BIT_INT
-    USE_ITHREADS
     USE_LARGE_FILES
     USE_LOCALE
     USE_LOCALE_COLLATE
@@ -92,30 +89,17 @@
     USE_LOCALE_TIME
     USE_PERLIO
     USE_PERL_ATOF
-    USE_REENTRANT_API
-  Locally applied patches:
-    FreeBSD:patch-Configure
-    FreeBSD:patch-Makefile.SH
-    FreeBSD:patch-cpan_ExtUtils-Install_lib_ExtUtils_Install.pm
-    FreeBSD:patch-cpan_ExtUtils-Install_t_Install.t
-    FreeBSD:patch-cpan_ExtUtils-MakeMaker_lib_ExtUtils_MM__Any.pm
-    FreeBSD:patch-cpan_ExtUtils-MakeMaker_t_INST__PREFIX.t
-    FreeBSD:patch-cpan_JSON-PP_bin_json__pp
-    FreeBSD:patch-cpan_Pod-Perldoc_lib_Pod_Perldoc.pm
-    FreeBSD:patch-cpan_Pod-Perldoc_lib_Pod_Perldoc_ToMan.pm
-    FreeBSD:patch-cpan_Pod-Perldoc_lib_Pod_Perldoc_ToTerm.pm
-    FreeBSD:patch-hints_freebsd.sh
-    FreeBSD:patch-perl.c
-    FreeBSD:patch-t_porting_customized.dat
   Built under freebsd
+  Compiled at Jun 13 2025 19:23:25
   %ENV:
     PERL5LIB="/home/dvl/perl5/lib/perl5"
     PERL_LOCAL_LIB_ROOT="/home/dvl/perl5"
     PERL_MB_OPT="--install_base "/home/dvl/perl5""
     PERL_MM_OPT="INSTALL_BASE=/home/dvl/perl5"
   @INC:
+    /home/dvl/perl5/lib
     /home/dvl/perl5/lib/perl5
-    /usr/local/lib/perl5/site_perl/mach/5.40
-    /usr/local/lib/perl5/site_perl
-    /usr/local/lib/perl5/5.40/mach
-    /usr/local/lib/perl5/5.40
+    /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2/amd64-freebsd
+    /tmp/Cm5ezMFavv/lib/perl5/site_perl/5.40.2
+    /tmp/Cm5ezMFavv/lib/perl5/5.40.2/amd64-freebsd
+    /tmp/Cm5ezMFavv/lib/perl5/5.40.2

@dlangille
Copy link

Now testing with -Dusemultiplicity:

git reset --hard HEAD ; git clean -fdx
export PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT=1
perl Porting/bisect.pl  -Dusemultiplicity --no-clean --start=v5.40.2 --end=v5.40.2 --with-module=DBI,DBD::Pg,Mozilla::CA,warnings::register --no-module-tests -- /tmp/test.sh

@dlangille
Copy link

Still failed to produce the problem. Next strategy, test by adding -DUSE_ITHREADS -DUSE_REENTRANT_API. If that still fails, I'll start to copy all the options except for the path stuff from the system perl -V.

For those following along at home, the current goal is to reproduce the error with a perl built by bisect - to date, we have been unable to build a perl-built-by-bisect which reproduces the problem.

@dlangille
Copy link

Still no failure.

Tried adding in -Doptimize=-O2 -Dusedtrace -Duse64bitint -Dusemymalloc=n -Dusethreads=y

got an eror, did not save it, something about not finding trace.h(?) - no trying again without -Dusedtrace

@bulk88
Copy link
Contributor
bulk88 commented Jun 14, 2025

Still no failure.

Tried adding in -Doptimize=-O2 -Dusedtrace -Duse64bitint -Dusemymalloc=n -Dusethreads=y

got an eror, did not save it, something about not finding trace.h(?) - no trying again without -Dusedtrace

This isn't my usual interest, but Ii will ask, is the shell %ENV state outside of the bisect runner script, and the shell %ENV state of a process started from the bisect runner script, along with the PP %ENV state state on perl proc startup outside of the bisect runner script, and the PP %ENV state state on a perl proc startup from inside the bisect runner script, are all 4 things 100% byte wise identical?

Something like en-us vs en-US, or any 1 directory added or removed from PATH, can affect reproduceability, or sneak its way into CCFLAGS, some way some how, EU::MM did it or /bin/make doesn't matter, but the final binary is now ABI/API different. 32 bit time_t vs 64 bit time_t. double vs long double. is the endianness of bit_fields : 1; going to be GNU endian, ISO endian, or Microsoft endian? Things like that.

Update:

make an strace log of a defective perl+DBI process run and a can't reproduce it perl+DBI process run and compare the 2 strace logs. strace solves 75% of my daily IT problems in 90 seconds or less.

@dlangille
Copy link

make an strace log of a defective perl+DBI process run and a can't reproduce it perl+DBI process run and compare the 2 strace logs. strace solves 75% of my daily IT problems in 90 seconds or less.

Is #23306 (comment) at all relevant to the above?

@dlangille
Copy link

Still no failure.

Tried adding in -Doptimize=-O2 -Dusedtrace -Duse64bitint -Dusemymalloc=n -Dusethreads=y

got an eror, did not save it, something about not finding trace.h(?) - no trying again without -Dusedtrace

That also did not fail.

...
Running make for T/TI/TIMLEGGE/Module-Signature-0.90.tar.gz
cp lib/Module/Signature.pm blib/lib/Module/Signature.pm
cp script/cpansign blib/script/cpansign
"/tmp/0FS_6ph6Lx/bin/perl" "-Iinc" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/cpansign
  TIMLEGGE/Module-Signature-0.90.tar.gz
  /usr/bin/make -- OK
  TIMLEGGE/Module-Signature-0.90.tar.gz
  Skipping test because of notest pragma
Running make install for TIMLEGGE/Module-Signature-0.90.tar.gz
Installing /tmp/0FS_6ph6Lx/lib/perl5/site_perl/5.40.2/Module/Signature.pm
Installing /tmp/0FS_6ph6Lx/bin/cpansign
Appending installation info to /tmp/0FS_6ph6Lx/lib/perl5/5.40.2/amd64-freebsd-thread-multi/perllocal.pod
  TIMLEGGE/Module-Signature-0.90.tar.gz
  /usr/bin/make install  -- OK
warnings::register is up to date (1.06).
+ /home/dvl/perl5/perl -I/home/dvl/perl5/lib /home/dvl/perl5-issue-23306
+ grep -q 'cleared whilst still active during global destruction' log.txt
+ exit 0
good - zero exit from /tmp/test.sh
Runner returned 0 for end revision at Porting/bisect.pl line 233.
That took 4975 seconds.

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

No branches or pull requests

0