[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-dev
Subject:    Re: [sqlite-dev] SQLite : unixRemapfile() at line 5047
From:       Martijn Blaauw <martijn81 () ziggo ! nl>
Date:       2019-05-27 16:20:38
Message-ID: 927326a5-4fd0-8baf-13fc-de553c228e94 () ziggo ! nl
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

If the extent of an existing mapping failed then pNew
becomes equal to MAP_FAILED (for mremap() or mmap()).
Thats here: http://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5026-5029

The existing mapping is free'ed on line 5042.
But pNew is equal to MAP_FAILED so we never go into
this if statement: 
https://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5046-5049

The comment that you refer to says the above mmap() call failed, but it 
is not called.
Because pNew == MAP_FAILED.


On 27-05-19 17:02, Dan Kennedy wrote:
>
>
> On 26/5/62 16:41, Martijn Blaauw wrote:
>>
>> Hello,
>>
>> I was looking at the unixRemapfile() function
>> and i found something   strange on line 5047.
>> See: https://github.com/mackyle/sqlite/blob/master/src/os_unix.c
>>
>> *That if statement is now:*
>> if( pNew==0 ) {
>> *I think it must be:*
>> if( pNew==MAP_FAILED || pNew==0 ) {
>>
>> I am probably missing something important here...
>> If for example osMmap() on line 5029 returns MAP_FAILED then the 
>> entire mapping is free'ed but SQLite falls back to xRead/xWrite.
>> At it doesn't create a new mapping on line 5048..
>>
>
> Thanks for reviewing the code.
>
> It seems Ok to me. Once we see MAP_FAILED we do not make any further 
> attempts to map the file. As per this:
>
> http://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5056-5058
>
> Dan.
>
>
>
> _______________________________________________
> sqlite-dev mailing list
> sqlite-dev@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev

[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,<br>
    </p>
    <p>If the extent of an existing mapping failed then pNew <br>
      becomes equal to MAP_FAILED (for mremap() or mmap()). <br>
      Thats here: <a class="moz-txt-link-freetext"
        href="http://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5026-5029">http://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5026-5029</a><br>
  </p>
    <p>The existing mapping is free'ed on line 5042.<br>
      But pNew is equal to MAP_FAILED so we never go into <br>
      this if statement: <a class="moz-txt-link-freetext"
        href="https://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5046-5049">https://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5046-5049</a></p>
  <p>The comment that you refer to says the above mmap() call failed,
      but it is not called.<br>
      Because pNew == MAP_FAILED.</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 27-05-19 17:02, Dan Kennedy wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:b2bc2916-62bc-ad2f-13e6-8fe84a8fb483@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p><br>
      </p>
      <div class="moz-cite-prefix">On 26/5/62 16:41, Martijn Blaauw
        wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:d0ea3c8a-d3c3-60d9-6001-8a4d793a8ac8@ziggo.nl">
        <meta http-equiv="content-type" content="text/html;
          charset=UTF-8">
        <p>Hello,</p>
        <p>I was looking at the unixRemapfile() function<br>
          and i found something  strange on line 5047.<br>
          See: <a class="moz-txt-link-freetext"
            href="https://github.com/mackyle/sqlite/blob/master/src/os_unix.c"
            moz-do-not-send="true">https://github.com/mackyle/sqlite/blob/master/src/os_unix.c</a></p>
  <p><b>That if statement is now:</b><br>
          if( pNew==0 ) {<br>
          <b>I think it must be:</b><br>
          if( pNew==MAP_FAILED || pNew==0 ) {</p>
        <p>I am probably missing something important here...<br>
          If for example osMmap() on line 5029 returns MAP_FAILED then
          the entire mapping is free'ed but SQLite falls back to
          xRead/xWrite.<br>
          At it doesn't create a new mapping on line 5048..<br>
        </p>
      </blockquote>
      <p><br>
      </p>
      <p>Thanks for reviewing the code.<br>
      </p>
      <p>It seems Ok to me. Once we see MAP_FAILED we do not make any
        further attempts to map the file. As per this:</p>
      <p>  <a class="moz-txt-link-freetext"
          href="http://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5056-5058"
          moz-do-not-send="true">http://www.sqlite.org/src/artifact/f6e91b8fd82af?ln=5056-5058</a> \
  <br>
      </p>
      <p>Dan.</p>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" \
wrap="">_______________________________________________ sqlite-dev mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:sqlite-dev@mailinglists.sqlite.org">sqlite-dev@mailinglists.sqlite.org</a>
 <a class="moz-txt-link-freetext" \
href="http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev">http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev</a>
 </pre>
    </blockquote>
  </body>
</html>


[Attachment #6 (text/plain)]

_______________________________________________
sqlite-dev mailing list
sqlite-dev@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic