#1230 closed Bugs (fixed)
mbstate uninitialized
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | Boost 1.35.0 | Component: | filesystem |
Version: | Boost 1.34.1 | Severity: | Problem |
Keywords: | Cc: |
Description
In boost_1_34_1/libs/filesystem/src/path.cpp the functions to_internal and to_external both call the converter without initializing the state. The type mbstate_t is a POD so state must be initialized before the call.
Change History (4)
comment:1 by , 15 years ago
Component: | None → filesystem |
---|---|
Owner: | set to |
comment:2 by , 15 years ago
Milestone: | To Be Determined → Boost 1.35.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:3 by , 15 years ago
It needs to be initialized. As the name implies the mbstate tracks the state of a multibyte access, e.g. if the previous access or conversion only was a partial translation (this can happen if the previous read operation only got half the multibyte character and the other half comes in the current read).
If we start with an uninitialized mbstate the current access can accidentally be performed as a continuation of a partial access. That will produce unexpected results.
comment:4 by , 14 years ago
Hello[[BR]]
It really must be initialized. We have a crash inside boost due to this bug in 1.34.1. I found corresponding bug to gcc (but left as "not a bug") where the reason of crash was also unitizalized state (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28059)
Stack of crash:
#0 0xb7f6c410 in kernel_vsyscall ()
#1 0xb6c66085 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb6c67a01 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb6e86480 in gnu_cxx::verbose_terminate_handler () from ../lib32/libstdc++.so.6
#4 0xb6e83d05 in std::set_unexpected () from ../lib32/libstdc++.so.6
#5 0xb6e83d42 in std::terminate () from ../lib32/libstdc++.so.6
#6 0xb6e83e6a in cxa_throw () from ../lib32/libstdc++.so.6
#7 0xb7be2220 in boost::throw_exception<boost::filesystem::basic_filesystem_error<boost::filesystem::basic_path<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::filesystem::wpath_traits> > > (e=@0xbf9a6fac)
at throw_exception.hpp:39[[BR]]
#8 0xb7be159e in boost::filesystem::wpath_traits::to_external (ph=@0xbf9a7138, src=@0xbf9a701c)
at boost/boost/libs/filesystem/src/path.cpp:94[[BR]]
#9 0xb76b8b43 in boost::filesystem::basic_path<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, boost::filesystem::wpath_traits>::external_directory_string (this=0xbf9a7138) at path.hpp:303[[BR]] ...
It isn't clear to me mbstate needs to be initialized. But doing so is harmless, so it now does so.
Thanks for the report,
--Beman