Hi thanks for answers,

Initially , I first checked for leaks when USE_ZEND_ALLOC=1 , and I have found 
some leaks I cleared them
however still was crashing due to corruption. (p->next_free_slot not readable 
during an emalloc )

As advised, I also checked things with USE_ZEND_ALLOC=0 , here things got weird 
as now it is also
crashes at this point with a different call stack. ( zend_assign_to_variable )

For USE_ZEND_ALLOC=0 case,  I called  _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | 
_CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF ) in php_cli.c main function . 
CRT  didn`t report anything in this case.

From: Pierre Joye [mailto:pierre....@gmail.com]
Sent: 26 December 2015 07:07
To: Laruence
Cc: Ocal, Akin; PHP internals
Subject: Re: [PHP-DEV] PHP7 Zend Heap validation


On Dec 26, 2015 12:30 PM, "Xinchen Hui" 
<larue...@php.net<mailto:larue...@php.net>> wrote:
>
> Hey:
>
> On Sat, Dec 26, 2015 at 1:01 PM, 
> <akin.o...@thomsonreuters.com<mailto:akin.o...@thomsonreuters.com>> wrote:
>
> > Hi everyone,
> >
> > I am working on porting a pre-PHP7 database driver extension to PHP7 for
> > Windows platforms.
> > ( I am using PHP 7.0.1 master branch code and targeting non-ZTS 32 bit
> > PHP7 on Windows Server 2012 R2 )
> > And currently as I did mechanical bits of porting ( compilation issues,
> > getting functionality working
> > mostly followed 
> > https://wiki.php.net/phpng-upgrading<https://urldefense.proofpoint.com/v2/url?u=https-3A__wiki.php.net_phpng-2Dupgrading&d=AwMFaQ&c=4ZIZThykDLcoWk-GVjSLm9hvvvzvGv0FLoWSRuCSs5Q&r=WNZrBw1Z15H_TIydi6wrAnQBZ6J3iZSKUpRWgdkYc54&m=8fmgrfX7MfZRLEX6JNcuqL0Dx-z5YQ1mOw_jjdclIAg&s=ic30D9tCrQWw3yQXhqDXBYyZGtG8pS_EyHVNRFAkwsI&e=>
> >  ) , my extension is
> > only crash-free if I run it with
> > USE_ZEND_ALLOC=0.
> >
> > However with USE_ZEND_ALLOC=1 , I am getting crashes inside
> > zend_mm_alloc_small. As checked with Windbg :
> > ...
> > if (EXPECTED(heap->free_slot[bin_num] != NULL) )
> >                 {
> >                                 zend_mm_free_slot *p =
> > heap->free_slot[bin_num];
> >                                 if ( p->next_free_slot != NULL )
>
>
> > Above , p->next_free_slot is not readable. I believe , currently I am
> > getting the Zend heap corrupt.
> > I am running a test script and  I tried disabling many things ,and
> > enabling one by one to have an idea, from the looks of it , I am getting
> > this issue
> > around a zend_register_resource call but to me that one looks legitimate
> > so I can`t easily pinpoint where the Zend heap gets corrupt.
> >
> > Diffrently from pre-PHP7 where we had full_mem_check , now I can see
> > ZEND_MM_CHECK is placed in memory manager functions.
> >
> > I wanted to ask if there is any chance if we can have a heap integrity
> > checker function , or what would you advise
> > regarding to track down the places in our code corrupting the Zend MM ?
> >
> I am not familar with windows, but if it can be run in linux
>
> you could try with "USE_ZEND_ALLOC=0 valgrind --tool=memcheck "
>
> not sure if there is similar tool on windows
>
>
> thanks
>

On windows you can use a couple of tools to try to find them:
- 
http://www.softwareverify.com/<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.softwareverify.com_&d=AwMFaQ&c=4ZIZThykDLcoWk-GVjSLm9hvvvzvGv0FLoWSRuCSs5Q&r=WNZrBw1Z15H_TIydi6wrAnQBZ6J3iZSKUpRWgdkYc54&m=8fmgrfX7MfZRLEX6JNcuqL0Dx-z5YQ1mOw_jjdclIAg&s=Bo1i7yRldERDK_blhtnvasYKfauEXCgNzUyX9dN-B5o&e=>
 (commercial)
- the debugger tools (the standalone tools) contain some limited valgrind like 
features
- not directly related but adding --with-static-analyzer=vs is quite useful 
too. Latest version is Very effective

Cheers,

Reply via email to