bitwiseworks / libcx

kLIBC Extension Library
GNU Lesser General Public License v2.1
11 stars 1 forks source link

Reading from a read-only mapping bound to file causes crash #15

Closed dmik closed 8 years ago

dmik commented 8 years ago

If an application creates a mapping that has PROT_READ protection and is bound to a regular file, reading data from such a mapping will cause an unexpected access violation exception like this one (followed by a program termination):

 Exception C0000005 - Access Violation
______________________________________________________________________

 Process:  D:\CODING\LIBCX\MASTER-BUILD-DEBUG\STAGE\BIN\TST-MMAP3.EXE (09/26/2016 03:27:05 16,199)
 PID:      12FB (4859)
 TID:      01 (1)
 Priority: 200

 Filename: C:\OS2\DLL\DOSCALL1.DLL (01/17/2013 22:14:24 132,401)
 Address:  005B:1FFC2526 (0002:00002526)
 Cause:    Attempted to write to 21030000
           (read-only  memory allocated by LIBCX0)
dmik commented 8 years ago

The reason is that LIBCx attempts to read data from a bound file and store it in the mapped page but crashes since the page is read-only. Interesting that @psmedley found it when testing Opcache in PHP5.

dmik commented 8 years ago

Fixed this in 4e3d75418050404d371fcf30eb1ea9876f74c2e5, @psmedley confirms Opcache works now for him.

dmik commented 8 years ago

The test builds of the new LIBCx are here: