[Boost-bugs] [Boost C++ Libraries] #1443: deserialization from text_iarchive is not thread-safe

Subject: [Boost-bugs] [Boost C++ Libraries] #1443: deserialization from text_iarchive is not thread-safe
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-11-15 13:16:12


#1443: deserialization from text_iarchive is not thread-safe
------------------------------+---------------------------------------------
 Reporter: stas_at_[hidden] | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: release 1.34.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 Here is an example of code which fails under windows with unhandled
 "access violation" exception when running on machine with two processors.

 Code was compiled with MS VS 8.0.

 #include "stdafx.h"
 #include <list>
 #include <string>
 #include <sstream>
 #include <boost\archive\text_iarchive.hpp>
 #include <boost\serialization\list.hpp>
 #include <atlsync.h>

 char Serialized[] = { 0x32, 0x32, 0x20, 0x73, 0x65, 0x72, 0x69, 0x61,
 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3A, 0x3A, 0x61, 0x72,
 0x63, 0x68, 0x69, 0x76, 0x65, 0x20, 0x33, 0x20, 0x30, 0x20, 0x30, 0x20,
 0x35, 0x20, 0x37, 0x20, 0x53, 0x00, 0x74, 0x00, 0x72, 0x00, 0x69, 0x00,
 0x6E, 0x00, 0x67, 0x00, 0x31, 0x00, 0x20, 0x37, 0x20, 0x53, 0x00, 0x74,
 0x00, 0x72, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x32, 0x00, 0x20,
 0x37, 0x20, 0x53, 0x00, 0x74, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6E, 0x00,
 0x67, 0x00, 0x33, 0x00, 0x20, 0x37, 0x20, 0x53, 0x00, 0x74, 0x00, 0x72,
 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x34, 0x00, 0x20, 0x37, 0x20,
 0x53, 0x00, 0x74, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x67, 0x00,
 0x35, 0x00 };
 CEvent hStart;

 static void Deserialize()
 {
         std::string str(Serialized, sizeof(Serialized) /
 sizeof(Serialized[0]));
         std::list<std::wstring> Data;
         std::stringstream stream(str);
         boost::archive::text_iarchive ar(stream);

         ar & Data;
 }

 static DWORD WINAPI ThreadProc(LPVOID)
 {
         WaitForSingleObject(hStart, INFINITE);

         try
         {
                 Deserialize();
         } catch (std::exception& ex)
         {
                 wprintf(L"exception: %S\n", ex.what());
         } catch(...)
         {
                 wprintf(L"unkn exception\n");
         }

         return 0;
 }

 int wmain(int argc, wchar_t* argv[])
 {
 // Uncomment Deserialize() call to avoid exception
 // Deserialize();

         hStart.Create(NULL, TRUE, FALSE, NULL);

         HANDLE hThreads[2];

         for(size_t i = 0; i < _countof(hThreads); ++i)
                 hThreads[i] = CreateThread(NULL, 0, &ThreadProc, NULL, 0,
 NULL);

         Sleep(100);
         hStart.Set();

         WaitForMultipleObjects(_countof(hThreads), hThreads, TRUE,
 INFINITE);

         return 0;
 }

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1443>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:57 UTC