tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Saegesser <>
Subject [j-t-c] Thread problem in jk_uri_worker_map.c
Date Fri, 15 Aug 2003 22:11:50 GMT
I've run into a threading problem in
/j-t-c/native/jk/common/jk_uri_worker_map.c.  The problem has been around
for a long time, but I believe the changes checked in for version 1.15 on
June, 27, 2003 made the problem worse.  I have only been able to reproduce
the problem on multi-processor machines running under a fairly heavy load.
Unfortunately, I don't have a good solution, yet.

The worker map contains a temp pool ( that is used in
the map_uri_to_worker() function.  The temp pool is used to store a copy of
the incoming URI so that it can be altered to remove any jsessionid and to
remove multiple adjacent / characters.

The problem is that this single pool is shared by all the worker threads so
if multiple threads are executing map_uri_to_worker() simultaneously there
is a chance that the pool will get corrupted.  This can happen in two ways.
The jk_pool code is not thread safe so the internal state of the pool may be
corrupted.  Second, the map_uri_to_worker() function always calls
jk_pool_reset() after mapping the URI.  This means that if multiple URIs did
get allocated into the pool without corruption, when the first thread
finishes it will reset the pool.  This may not create a noticeable problem
because the memory in the pools isn't overwritten by a reset.  If the other
threads finish before another thread enters map_uri_to_worker() then nothing
will fail.  However, if another thread does enter map_uri_to_worker() then
its call to jk_pool_strdup() will overwrite some of the previous contents of
the pool and really bad things may happen.

As I said, I don't have a solution, yet.  Any solution would have to be
platform independent and also work with all the Web servers that use the JK
plugin (e.g. Apache 1.3, Apache 2.0, ISAPI, Netscape, ...).


-- Marc

View raw message