Skip to content

coredump if untie is omitted #41

@hkoba

Description

@hkoba

Hi!

I tried LMDB_File 0.13 and found it dumps core in my test code: hkoba/LMDB_File@19f5a65

Below does similar thing:

#!/usr/bin/perl -w
use strict;
use warnings;
use LMDB_File qw(:flags);
$LMDB_File::DEBUG = 1;

{
  my $path = shift or die "usage: $0 LMDB_FILE\n";

  tie my %db, LMDB_File => $path, +{flags => MDB_NOSUBDIR | MDB_NOSYNC}
    or Carp::croak "LMDB_File failed: $!";

  print %db, "\n";

  untie %db if $ENV{USE_UNTIE};
}
END {
  print "In the END\n";
}

Here is the output:

Created LMDB::Env 94194999053552
BeginTxn 94194999053552(10156), deep: 0
Created LMDB::Txn 94195000152992 in 94194999053552
Opened dbi 1
Cursor opened for #1
foobarxxyy
In the END
Closed LMDB::Env 94194999053552 (remains 0)
LMDB: Destroying an active transaction, commiting 94195000152992...
zsh: segmentation fault (core dumped)  USE_UNTIE=0 perl ../mylmdbtest3.pl ../map.map

Although adding the code below in the end of LMDB_File.pm can stop this coredump, I'm not sure this is the right way to fix it. Do you have any idea to fix it?

END {
  undef %LMDB::Env::Envs;
  undef %LMDB::Txn::Txns;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions