[sqlite-dev] SQLite : unixRemapfile() at line 5047

3 views
Skip to first unread message

Martijn Blaauw

unread,
May 26, 2019, 5:41:37 AM5/26/19
to sqlit...@mailinglists.sqlite.org

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..


Martijn.

Dan Kennedy

unread,
May 27, 2019, 11:02:28 AM5/27/19
to sqlit...@mailinglists.sqlite.org

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.


Martijn Blaauw

unread,
May 27, 2019, 12:20:43 PM5/27/19
to sqlit...@mailinglists.sqlite.org

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.

_______________________________________________
sqlite-dev mailing list
sqlit...@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev
Reply all
Reply to author
Forward
0 new messages