Ticket #4685 (closed Bugs: fixed)

Opened 7 years ago

Last modified 7 years ago

boost::interprocess::winapi::get_last_bootup_time( std::wstring&)

Reported by: Jim Bell <jim@…> Owned by: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:


boost::interprocess::winapi::get_last_bootup_time( std::wstring& strValue )

This line is wrong and is crashing most of the win32 regression tests (both release and trunk):


strValue doesn't have '+', so .find() returns std::wstring::npos, but that causes std::wstring::erase() to crash. npos isn't a valid parameter to erase() and will cause an out_of_range exception to be thrown.

I think this is causing many regression test failures both the release and trunk branches for win32.

The fix would be to split it out:

std::wstring::size_type plusPos = strValue.find(L'+');
if (plusPos != std::wstring::npos)

I can't speak to why you're looking for a '+' and the significance of not finding it.


Change History

comment:1 Changed 7 years ago by igaztanaga

¿Which failures? I see in trunk that some msvc tests are fine:

In my machine the string returned from windows WMI is:


Maybe depending on the time zone, the offset part (+120 or whatever) is not present. Could you please print string contents to see what is windows WMI returning?

I will applying the patch but I wanted to be sure that it fixes the problem.

comment:2 Changed 7 years ago by Jim Bell <jim@…>

My machine returns:


60% of the interprocess release tests fail under msvc-8.0 and some other win32 platforms. I think this one bug is causing many of them.

The above npos-check made my test code run. Without it, it crashed.

comment:3 Changed 7 years ago by Jim Bell <jim@…>

For the record, I think std::string::erase() ought to handle npos, and I'm disappointed that it doesn't. Your code is more elegant than the fix: it's clear that you don't want to erase anything if you don't find what you're looking for.

comment:4 Changed 7 years ago by igaztanaga

I've committed some changes to trunk, does this solve the problem?

comment:5 Changed 7 years ago by jim@…

All trunk tests now pass under msvc-8.0, as you can see from last night's test. Good job!

comment:6 Changed 7 years ago by igaztanaga

  • Status changed from new to closed
  • Resolution set to fixed

Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.