#1423 closed defect (fixed)
Linux std::string not thread safe
Reported by: | trevorwekel | Owned by: | trevorwekel |
---|---|---|---|
Priority: | high | Milestone: | 2.2 |
Component: | Server | Version: | 2.2.0 |
Severity: | blocker | Keywords: | |
Cc: | brucedechant | External ID: |
Description
The std::string implementation on Linux uses a refcounted copy of the string data. Under certain circumstances, the implementation in not thread safe which causes "double free" errors and MapGuide server crashes under heavy load on Linux.
The MapGuide logs (access, error, etc) are especially susceptible to string thread safety because strings are queued to seperate thread before they are written to disk.
An effective way to test thread safety for std::string is to run a load test of 200+ concurrent users executing Http GETTILEIMAGE. This Http operation is very fast (<10 ms) and puts huge stress on the basic request processing and logging infrastructure. For maximum effectiveness, this test should be run on an 8 way box.
Attachments (3)
Change History (12)
comment:1 by , 14 years ago
by , 14 years ago
Attachment: | stdstringCommon.patch added |
---|
by , 14 years ago
Attachment: | stdstringWeb.patch added |
---|
by , 14 years ago
Attachment: | stdstringServer.patch added |
---|
comment:2 by , 14 years ago
Added patch files for std::string safety and other potential thread safety issues detected by Valgrind on Linux:
- Return a STRING type created from a c_str() call forces the std::string template to allocate a new copy of the string.
- Replace CREFSTRING with STRING return values for consistency. Additional c_str() calls may be required depending threading usage.
- Add refcount to MgUserInformation::GetCurrentUserInfo() to guarantee object lifetime in a multi-threaded environment.
- Null out various "Packet" variables to correct uninitialized references detected by Valgrind
comment:3 by , 14 years ago
Status: | new → assigned |
---|
On a 200 user GETTILEIMAGE test, the patches above did not generate a single "double free" error or crash during a two hour run. The server access.log grew to over 3GB in size and contained over 24 million log entries.
comment:4 by , 14 years ago
Cc: | added |
---|
comment:6 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixes for trunk submitted in r5183
With MapGuide 2.2 RC0, the 200 user GETTILEIMAGE test will typically throw a "double free" error within the first 5 minutes of the test run on Linux. A fatal crash can be expected within the first hour.