Re: [pcre-dev] A test for the memory mismatch problem

Pàgina inicial
Delete this message
Autor: Philip Hazel
Data:  
A: pcre-dev
Assumpte: Re: [pcre-dev] A test for the memory mismatch problem
On Thu, 29 Mar 2007, Sheri wrote:

> Here is what I get with your test:
>
> ================================================
>
> pcre_malloc set to 00401AF0
> address of gotten_store is 0040C0D0
> PCRE version 7.1-RC3 2007-03-26
>
> re> /(a)b|/I
> address of gotten_store is 0040C0D0
> regex_gotten_store = 0
> Size disagreement: pcre_fullinfo=62 call to malloc for 0
> Capturing subpattern count = 1
> No options
> No first char
> No need char
> ===========================================
>
> Hope it helps.


Well, it shows what is happening, or rather, what is not happening. The
first line shows that the variable pcre_malloc is indeed being set. This
should point to a function within pcretest that the PCRE library calls
when it wants to obtain some memory, instead of calling malloc()
directly.

However, it appears that it is not doing so, because I put some more
printing into that function, and that output is not appearing. Therefore
the recording of how much memory was asked for doesn't happen, and so we
get the mismatch. I suspect the two functions are "seeing" different
versions of pcre_malloc.

The variable pcre_malloc is declared in pcre.h as

PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);

and PCRE_DATA_SCOPE itself is also declared in that file, near the top.
I see that there's a Windows-specific version of it, keyed by the
definition of _WIN32. I wonder if something is going wrong there? How
can we test this? Ah, I know. Please insert these lines before the line
containing "/* Have to include stdlib.h in order to ensure that size_t
is defined;" (around lin 74) in pcre.h:

#ifdef _WIN32
#error _WIN32 is defined
#else
#error _WIN32 is not defined
#endif

Then try to build PCRE. It will fail, but you will get one or the other
of those messages. Hmm. I see that in pcretest.c, there is also a test
for WIN32 (without the underscore). Perhaps you could try the test
without the underscores as well.


Philip

--
Philip Hazel, University of Cambridge Computing Service.