<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Aptos;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#467886;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I could not find any issue-tracker for the <a href="https://pypi.org/project/berkeleydb/">
https://pypi.org/project/berkeleydb/</a> project, so I am communicating about a bug in this mailing list. If there is an issue-tracker, please let me know and I will raise it there.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The issue is in the `DBEnv_memp_stat` function. When calling the `memp_stat`function, we are expecting that the value of `fsp` variable is non NULL. However as per the official documentation, `fsp` can be NULL when “<i>If no individual
files currently exist in the cache</i>”. For example when `db_env_create` has been done, but we have not yet done a `db_create` followed by a `db->open`. This will cause a NULL pointer reference when looping over `fsp` further down the code and causes a crash.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The following program reproduces the issue –<o:p></o:p></p>
<p class="MsoNormal">```<o:p></o:p></p>
<p class="MsoNormal">def run():<o:p></o:p></p>
<p class="MsoNormal"> # Create env<o:p></o:p></p>
<p class="MsoNormal"> env = db.DBEnv(0)<o:p></o:p></p>
<p class="MsoNormal"> eflags = db.DB_CREATE | db.DB_INIT_MPOOL<o:p></o:p></p>
<p class="MsoNormal"> env.open('/some/path/to/dbenv', flags=eflags)<o:p></o:p></p>
<p class="MsoNormal"> # Don't create a db yet<o:p></o:p></p>
<p class="MsoNormal"> #x = db.DB(env)<o:p></o:p></p>
<p class="MsoNormal"> #x.open('mydb_from_py.db', flags=db.DB_CREATE, dbtype=db.DB_BTREE)<o:p></o:p></p>
<p class="MsoNormal"> # memp state<o:p></o:p></p>
<p class="MsoNormal"> print(env.memp_stat())<o:p></o:p></p>
<p class="MsoNormal">```<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please let me know how this issue will be handled.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Rishin Goswami<o:p></o:p></p>
<p class="MsoNormal">`<o:p></o:p></p>
</div>
</body>
</html>