Squid aufs crashes under 10.0
Dimitry Andric
dim at FreeBSD.org
Sun Feb 9 19:57:18 UTC 2014
On 09 Feb 2014, at 20:16, Dennis Glatting <freebsd at pki2.com> wrote:
> On Sun, 2014-02-09 at 19:37 +0100, Dimitry Andric wrote:
...
>> Very bad coding practice, obviously. It should call Find() first, and
>> if that returns NULL, it should abort in some sort of controlled way.
>>
>
> Found that too but not the reason why:
>
> (lldb) run -d -z -F -f /root/squid.conf
> Process 23598 launched: './src/squid' (x86_64)
> Find(): Mmapped
> Find(): IpcIo
> Find(): DiskDaemon
> Find(): Blocking
> Find(): AIO
> Returning NULL
>
> There's a lot of faulty (i.e., a lack thereof) checking in Squid. For
> example, I replaced strlen() with a custom version that first checks for
> NULL and returns 0 if that is the case (strlen() was often called by
> std::cstring::c_str() that was not yet initialized). That small code
> fragment resolved a lot of SEGVs.
There are a bunch of places where they use std::ostream::operator<< to
output e.g. configuration strings to the debug stream, for example in
uniqueHostname(), in src/tools.cc:
const char *
uniqueHostname(void)
{
debugs(21, 3, HERE << " Config: '" << Config.uniqueHostname << "'");
return Config.uniqueHostname ? Config.uniqueHostname : getMyHostname();
}
The problem case is when Config.uniqueHostname is NULL: this gets
converted into a std::string first (which is _undefined behavior_), then
it gets streamed to the debug stream.
However, there is a difference between libstdc++ and libc++ here: the
former silently accepts NULL arguments passed to the std::string
constructor, creating a sort of "empty" string for you, which seems to
work as normal. The latter just stores your NULL pointer, and if you
actually try to do anything with it, the program will crash.
To fix at least two places where this is done, drop the attached patches
in www/squid33/files.
-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-src-acl-Acl.cc
Type: application/octet-stream
Size: 322 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20140209/cd5afcb4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-src-tools.cc
Type: application/octet-stream
Size: 445 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20140209/cd5afcb4/attachment-0001.obj>
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20140209/cd5afcb4/attachment.sig>
More information about the freebsd-stable
mailing list