views:

90

answers:

1

The application is developed in VC++ 6.0. When this is run in a multithreaded and multiprocessor environment along with its dependent services one of the dependent services crashes when attempting some string operations like string format or string copy. However this is not observed in a single processor environment and most often the call stack would look like this

mfc42u!CFixedAlloc::Alloc+82 005b5b64 00000038 005b5b64

mfc42u!CString::AllocBuffer+3f 00000038 00000038 005b5b64

mfc42u!CString::AllocBeforeWrite+31 00000038 0a5bfdbc 005b5b64

mfc42u!CString::AssignCopy+13 00000038 057cb83f 0a5bfe90

mfc42u!CString::operator=+4b

Anybody faced such problems.

+1  A: 

This is normal when an application that was not developed or tested for a multithreaded environment is suddenly placed into a multithreaded envirohment.

In fact, this is s simple matter of violating assumptions. The code was no doubt written on the assumption that only a single thread at a time would execute it. If you violate those assumptions, then things are not so good.

The solution is to not violate the assumption: make certain that only one thread at a time can execute the code.

John Saunders
LOL, strtok() anyone?
Dave Markle