Re: [pcre-dev] [Bug 1121] Infinite recursive + crash

Kezdőlap
Üzenet törlése
Szerző: Petr Pisar
Dátum:  
Címzett: pcre-dev
CC: 1121
Tárgy: Re: [pcre-dev] [Bug 1121] Infinite recursive + crash
On Mon, Jun 13, 2011 at 04:38:45PM +0100, Philip Hazel wrote:
> On Mon, 13 Jun 2011, Petr Pisar wrote:
>
> > May I have a question? If I compile pcre to use stack and then to use heap,
> > will be the two libraries binary compatible?
>
> I'm not quite sure what you are asking here. The two libraries will both
> contain the same set of functions with the same names and the same APIs.
> The pcre_exec() function will be different in the way it works; the
> other functions will be identical in both libraries.
>

I'm thinking about packaging libpcre twice (heap and stack variant) and let
users to decide which implementation they want to use. Because Fedora is
binary distribution the two variants must be compatible at ABI level.

Just for clarification: ABI depends e.g. on a size of public data structures,
so having following code in public pcre header file:

struct dst {
#ifdef STACK_IMPLEMENTATION
    int foo;
#else
    long int foo;
#endif
    int bar;
};


would break ABI as application compiled against one version would assume
different size of foo and struct dst or different offset of bar.

If you wonder why somebody wants slower heap variant, it's because the heap
one can be limited on memory size whereas the stack one on recursion level
only. And if user has a public service that operates on unknown input, a bad
guy could supply such input the stack implementation would crash while heap
variant would refuse processing gracefully. (There is unkown relation between
recursion depth and consumed stack size.)

-- Petr