Modify

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: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

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.erase(strValue.find(L'+'));

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. http://stdcxx.apache.org/doc/stdlibref/basic-string.html#idx349

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)
   strValue.erase(plusPos);

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 igaztanaga

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

http://www.boost.org/development/tests/release/developer/interprocess.html

In my machine the string returned from windows WMI is:

20100918163015.375199+120

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:

20100923072129.484625-300

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

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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain igaztanaga.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.