Configuration file with UCS-2 encoding causes crash on windows
coinnail opened this issue · comments
Hi,
If I try to load a configuration file with the UCS-2 LE BOM encoding libbitcoin-server crashes instead of the regular error message output.
Steps:
PS C:\testbitcoin> Get-CimInstance Win32_OperatingSystem | Select-Object -Property Caption, OSArchitecture | Format-List
Caption : Microsoft Windows 10 Home
OSArchitecture : 64-bit
PS C:\testbitcoin> .\bs-windows-x64.exe -vVersion Information:
libbitcoin-server: 3.2.0
libbitcoin-protocol: 3.1.0
libbitcoin-node: 3.2.0
libbitcoin-blockchain: 3.2.0
libbitcoin: 3.2.0
PS C:\testbitcoin> .\bs-windows-x64.exe -s > test.cfg
PS C:\testbitcoin> .\bs-windows-x64.exe -c test.cfg
** Launches Windows Error Report Window **
Some debug information gathered from attached VS:
Exception thrown at 0x00007FFE131E3FB8 in bs-windows-x64.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::program_options::invalid_config_file_syntax > at memory location 0x00000046E44FED30.
Exception thrown at 0x00007FFE131E3FB8 in bs-windows-x64.exe: Microsoft C++ exception: boost::locale::conv::conversion_error at memory location 0x00000046E44FC500.
Exception thrown at 0x00007FFE131E3FB8 in bs-windows-x64.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x00000046E44FC5F8.
Unhandled exception at 0x00007FFE131E3FB8 in bs-windows-x64.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x00000046E44FC5F8.
I was trying to generate default configuration file, to edit so it would connect to testnet when I encountered this situation. Issue overcome converting the file to UTF-8 without BOM.
Yes, thanks for reporting. That is the correct resolution. Libbitcoin uses UTF-8 for all file formats and all internal operations. The only exception is console I/O, which requires wide encoding to support Unicode. It also provides no accommodation for the BOM, which allows configuration files to remain portable across platforms. I'll add a section to the config documentation.
The crash presumably results from failure to handle a boost exception on the failed parse. We have a similar issue with the boost parsing of command line options, which may be the same issue as this is the same boost parser. The fix to this is to handle the failure more gracefully by capturing the boost parser exception.