Opened 7 years ago

Closed 7 years ago

#4685 closed Bugs (fixed)

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

Reported by: Jim Bell <jim@…> Owned by: Ion Gaztañaga
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.

Attachments (0)

Change History (6)

comment:1 Changed 7 years ago by Ion Gaztañaga

¿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 Ion Gaztañaga

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 Ion Gaztañaga

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ion Gaztañaga.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.