release only bug?

Started by
5 comments, last by mfawcett 16 years, 1 month ago
okay im upgrading my project from vc2005 to vc2008 and my app works fine in debug mode, but now in release mode i get a crash. i've tracked it down to some code like this:

cmatch match;
	regex expression("\\(([^\\)]*)\\)");
	char* line = "[game]";
	if (regex_search(line, match, expression))
	{
...


the crash is in 'regex_search' now the weird thing is, i copied this code in to the main project, and it worked, but still continues to crash in this code that is in a seperate project (which compiles to a lib). any thoughts? the call stack ends up in: _invalid_parameter_noinfo called from from boost::match_results by the way my boost libs were compiled in vc2005
Advertisement
Boost is "untested" on vc2008. You should be getting compiler warning about it. I've had no problems, but I don't use boost::regex.

This doesn't look like a "crash," but rather an unchecked exception. Use the stack trace to find which function threw the exception and look at the documentation (or if you're brave enough, the source code) for that function and find out why it threw it.
Sometimes bugs that appear in release conf only are caused by non unitialized memory (debug initializes allocated memory IIRC).
Quote:Original post by supagu
	char* line = "[game]"; // this line is the problem


Change to this:
	char line[] = "[game]"; // fixed

--Michael Fawcett
The difference is assigning a string literal to a char* will assign the address of the literal in a string table, while assigning it to a char[] will copy the string from the table to an array on the stack. Apparently you're able to write to strings in the string table in debug mode, but not release mode? I know you're not able to write to the string table at all on Linux/GCC, not sure about MSVC.
Why would a regex_search write to the searched string, though? o_O
Quote:Original post by Zahlman
Why would a regex_search write to the searched string, though? o_O


You're right, I spoke too soon. The problem lies elsewhere. regex_search() takes a const char * as the first parameter.
--Michael Fawcett

This topic is closed to new replies.

Advertisement