Opened 12 years ago

Closed 11 years ago

#182 closed defect (fixed)

templates garbled when xcache.stat = On

Reported by: corinl@… Owned by: moo
Priority: major Milestone: 1.2.2
Component: cacher Version: 1.2.2
Keywords: stat, garbled, cache Cc:
Application: PHP Version: 5.2.6
Other Exts: SAPI: Irrelevant
Probability: Always Blocked By:


I'm running a big site on a debian system where php uses a lot of smarty templates.

I now upgraded to:

PHP 5.2.6-1 with Suhosin-Patch (cli) (built: May 4 2008 19:41:04)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

with XCache v1.2.2, Copyright (c) 2005-2007, by mOo

After the upgrade I saw some templates being wrongly composed. It seems that some templates are chosen at places where others should be. The problem disappered when I either disable xcache completey or change xcache.stat from On to Off!

With having xcache.stat set to Off my site works fine, but after changes I always have to reload apache, which is really annoying :-(

Change History (4)

comment:1 Changed 11 years ago by moo

i really don't get why this is happening. could be some race condition?

in xcache.c, try to change

            if (p->type == XC_TYPE_VAR || /* PHP */ p->data.php->mtime == xce->data.php->mtime) {


            if (p->type == XC_TYPE_VAR || /* PHP */ p->mtime == xce->mtime && p->data.php->sourcesize == xce->data.php->sourcesize) {

comment:2 Changed 11 years ago by gucki

WOW - finally the reply button is here, after email-address has been verified.

I don't think there's a race condition, at least not at the filesystem level. All files get synced using rsync using atomic "rename" syscall. Also templates not touched at all get garbled after some time when this flag is turned on.

With garbled I don't mean the templates contain invalid characters, are truncated etc. But assume one templates includes other templates (using smarty, so templates compiled to php files). After some time, template A is included where normally template B should be included etc. So guess some internal lists of xcache get corrupted? May be it's worth noting that I'm using thousands of templates, so may be there's an overrun or garbage collection bug?

I just switched to APC some days ago and everything works fine. But APC has no late binding support, that's why I'd prefer using xcache.... :-)

comment:3 Changed 11 years ago by moo

it is possible that when a compiled tpl (php) file is stat() by XCache, smarty updates(recompile) the file again before XCache/php compile it. but i don't see any reason why smarty will recompile it, so this statement could be false.

stat() -> got inode 1 -> file replaced, inode is 2 -> compile -> cache as $XCache[$filenode=1 not 2] = $compiled_result

adding && p->data.php->sourcesize == xce->data.php->sourcesize may fix the problem, or may not

see [571] which was later refix as [572]. i will backport this changeset to 1.3 from trunk if this fix your problem

comment:4 Changed 11 years ago by moo

  • Milestone changed from 1.3.1 to 1.2.2
  • Resolution set to fixed
  • Status changed from new to closed

fixed in 1.3

Note: See TracTickets for help on using tickets.