Zlib: Segfault when in action code. Same code works fine outside

Asked by Igor

I'm trying to write a squid-plugin that unpacks gzip-encoded content.
Here's a piece of code that kills squid:
    testlog("Service started 1");
    z_stream zs;
    memset(&zs, 0, sizeof(z_stream));
    inflateInit2(&zs, 15+16);
    testlog("Service started 2");

In a simple console application it works, when put in XService::start() from the example, it kills squid. My guess is that with segmentation fault.
I.e. I see multiple "Service started 1" in logfile which means that service gets restarted twice on every request.
And when executing it in console app I see both lines.

I've simplified code down to this when tracking down the error. Can you please suggest what could cause it?

Also, when I put this line of from vigo's gzip ecap instead of inflateInit:
   const int rc = deflateInit2(&zs, 9, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);

service dies as well. I'm using squid 3.2.0.11 with ecap 0.2.0
Can you please give me a hint on what's killing zlib? Or maybe there's an existing ungzipper ecap module for 0.2.0?

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Igor
Solved:
Last query:
Last reply:
Revision history for this message
Igor (i-um) said :
#1

I redirected stderr and caught the error - forgot -lz in linker, inflateInit2 was not resolved.
Sorry, not ecap-related