Skip to content

DB::loadfile performs differently on threaded builds vs unthreaded #18098

@jkeenan

Description

@jkeenan

When I run the file lib/DB.t in the core distribution, it PASSes on both unthreaded and threaded builds. However, the test program behaves differently between the two builds. On threaded builds, 3 unit tests are SKIPped. On unthreaded builds, they are run.

The following were run at the same commit (02e314e) and on the same machine (FreeBSD-11).

Unthreaded build:

$ sh ./Configure -des -Dusedevel && make test_prep; cd t;./perl harness -v ../lib/DB.t; cd -
...
ok 42 - DB::lines() should return ref to @DB::dbline
ok 43 - DB::loadfile() should not find unloaded file
ok 44 - ... should find loaded file from partial name
ok 45 - ... should set *DB::dbline to associated glob
ok 46 - ... should set $DB::filename to file name
ok 47 - DB::lineevents() should pick up defined lines

Note that tests 44, 45, and 46 are run.

Threaded build:

$ sh ./Configure -des -Dusedevel -Dusethreads && make test_prep; cd t;./perl harness -v ../lib/DB.t; cd -
...
ok 42 - DB::lines() should return ref to @DB::dbline
ok 43 - DB::loadfile() should not find unloaded file
ok 44 # skip cannot find loaded file
ok 45 # skip cannot find loaded file
ok 46 # skip cannot find loaded file
ok 47 - DB::lineevents() should pick up defined lines

Note that tests 44 through 46 are not run.

Here is the section of lib/DB.t in question:

205 # test DB::loadfile()
206 SKIP: {
207         local (*DB::dbline, $DB::filename);
208         ok( ! defined DB->loadfile('notafile'),
209                 'DB::loadfile() should not find unloaded file' );
210         my $file = (grep { m|^_<.+\.pm| } keys %main:: )[0];
211         skip('cannot find loaded file', 3) unless $file;
212         $file =~ s/^_<..//;
213 
214         my $db = DB->loadfile($file);
215         like( $db, qr!$file\z!, '... should find loaded file from partial na    me');
216 
217         is( *DB::dbline, *{ "_<$db" } ,
218                 '... should set *DB::dbline to associated glob');
219         is( $DB::filename, $db, '... should set $DB::filename to file name'     );
220 
221         # test clients
222 }

The skip was at line 211 has been part of the file ever since it was first added to the core distro in this commit in 2001:

commit c95f170b203f0b24696b298b0782f4f4c204d444
Author:     chromatic <chromatic@wgz.org>
AuthorDate: Sat Nov 24 07:56:57 2001 -0700
Commit:     Jarkko Hietaniemi <jhi@iki.fi>
CommitDate: Sun Nov 25 19:44:38 2001 +0000

    [REPATCH lib/DB.pm MANIFEST lib/DB.t] Rework DB.pm tests
    Message-ID: <20011124220430.97697.qmail@onion.perl.org>
    
    plus a tweak for ithreads builds.

But AFAICT there was no explanation for why DB->loadfile would sometimes locate a file and sometimes not (the ostensible reason for the skip). Nor is there any discussion in the lib/DB.pm documentation that mentions that DB methods might perform differently on threaded builds versus unthreaded.

Does anyone know why these DB methods would perform differently on different builds?

Feature or bug?

Is a documentation patch needed?

This problem was originally encountered here.

Thank you very much.
Jim Keenan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions