Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-10305

race condition in global ini cache generation

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 3.9.2
    • 3.7.2
    • Misc
    • None
    • Operating System: Debian GNU/Linux 3.1
      PHP Version: 4.4.3 (dotdeb version)
      Database and version: Postgresql 7.4.7
      Browser (and version): any

    Description

      We ran a large site under ezpublish and occasionnaly have display problem: some php code appear verbatim on the top on the page, for example:

      $groupPlacementArray["DefaultVersion"] = "settings/site.ini"; $blockValuesPlacement["RSSSettings"] =& $groupPlacementArray; unset( $groupPlacementArray );...

      The problem disappear when we clear the caches.

      I have been able to track down the cause of this bug to a corrupted ini cache files problem. I have attached two example of corrupted ini cache file we found on our server.

      Lookig at the code, I think the problem is a race condition in the following part of the ini cache save function (in lib/ezutils/classes/ezini.php):

          function saveCache( $cachedDir, $cachedFile )
          {
              if ( !file_exists( $cachedDir ) )
              {
                  include_once( 'lib/ezfile/classes/ezdir.php' );
                  if ( !eZDir::mkdir( $cachedDir, 0777, true ) )
                  {
                      eZDebug::writeError( "Couldn't create cache directory $cachedDir, perhaps wrong permissions", "eZINI" );
                  }
              }
              // save the data to a cached file
              $buffer = "";
              $i = 0;
              if ( is_array( $this->BlockValues )  )
              {
                  $fp = @fopen( $cachedFile, "w+" );
      

      There some time between the file test existence and the file creation, so if two processes tries to generate the same cache simultaneously, they can both write in the same file at the same time which should results in the kind of file I attached.

      Am I right in my conclusion ?

      Steps to reproduce

      I don't have an easy way to reproduce this bug.

      Attachments

        Activity

          People

            kk kk
            yann.rouillard yann.rouillard
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: