Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#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)

stdstringCommon.patch (9.0 KB ) - added by trevorwekel 14 years ago.
stdstringWeb.patch (1.2 KB ) - added by trevorwekel 14 years ago.
stdstringServer.patch (30.8 KB ) - added by trevorwekel 14 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 by trevorwekel, 14 years ago

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.

by trevorwekel, 14 years ago

Attachment: stdstringCommon.patch added

by trevorwekel, 14 years ago

Attachment: stdstringWeb.patch added

by trevorwekel, 14 years ago

Attachment: stdstringServer.patch added

comment:2 by trevorwekel, 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 trevorwekel, 14 years ago

Status: newassigned

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 brucedechant, 14 years ago

Cc: brucedechant added

comment:5 by trevorwekel, 14 years ago

Fixes for to branches/2.2 submitted in r5179, r5180, r5181

comment:6 by trevorwekel, 14 years ago

Resolution: fixed
Status: assignedclosed

Fixes for trunk submitted in r5183

comment:7 by hubu, 13 years ago

Fixes for trunk submitted in r5780

comment:8 by brucedechant, 13 years ago

Fixed for sandbox/adsk/2.2gp r5829

comment:9 by brucedechant, 13 years ago

Fixed for sandbox/adsk/2.3r r5731, r5734

Note: See TracTickets for help on using tickets.