Opened 13 years ago

Closed 13 years ago

#3895 closed Bugs (fixed)

Faulty output of tags by diagnostic_information() in G++ MinGW

Reported by: andrew mcardle <andrewmcardle1@…> Owned by: Emil Dotchevski
Milestone: Boost 1.43.0 Component: exception
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

When the diagnostic_information() function is called with a boost::exception the output of the tag information is faulty.

This can be seen in the output of example_io.cpp when compiled using g++ (TDM-2 mingw32) 4.4.1

Caught 'read_error' exception.
-------------------------------------------------
Source file name: tmp1.txt
Destination file name: tmp2.txt
File name: tmp1.txt
OS error: 0
Failed function: fread

Output from diagnostic_information():
example_io.cpp(78): Throw in function void my_fread(void*, size_t, size_t, const
 boost::shared_ptr<_iobuf>&)
Dynamic exception type: N5boost16exception_detail10clone_implI11fread_errorEE
std::exception::what: example_io error
[P17tag_file_name_dst] = tmp2.txt
[P17tag_file_name_src] = tmp1.txt
[PN5boost14errinfo_errno_E] = 0, "No error"
[PN5boost18errinfo_file_name_E] = tmp1.txt
[PN5boost20errinfo_file_handle_E] = [ type: N5boost10error_infoINS_20errinfo_fil
e_handle_ENS_8weak_ptrI6_iobufEEEE, size: 12, dump: 08 d5 48 00 b8 09 17 77 70 0
f 2d 00 ]
[PN5boost21errinfo_api_function_E] = fread

Caught 'open_error' exception.
-------------------------------------------------
File name: tmp1.txt
OS error: 2
Failed function: fopen

Output from diagnostic_information():
example_io.cpp(67): Throw in function boost::shared_ptr<_iobuf> my_fopen(const c
har*, const char*)
Dynamic exception type: N5boost16exception_detail10clone_implI11fopen_errorEE
std::exception::what: example_io error
[PN5boost14errinfo_errno_E] = 2, "No such file or directory"
[PN5boost18errinfo_file_name_E] = tmp1.txt
[PN5boost21errinfo_api_function_E] = fopen
[PN5boost23errinfo_file_open_mode_E] = rb

The operating system in use is Windows Vista

Change History (6)

in reply to:  description comment:1 by andrew mcardle <andrewmcardle1@…>, 13 years ago

On closer inspection it seems to be due to the fact that typeid().name returns a system specific name. To demonstrate this change tag_type_name() to call the typeid() function and print to stdout:

    template <class T>
    inline
    char const *
    tag_type_name()
        {
#ifdef BOOST_NO_TYPEID
        return BOOST_CURRENT_FUNCTION;
#else
		std::cout<<typeid(T*).name();
        return typeid(T*).name();
#endif
        }

If this counts as a bug or a feature, I am now unsure, however it does not seem to be a problem with the library itself.

comment:2 by Emil Dotchevski, 13 years ago

Yes, this is due to typeid.name(). Note that by design, the diagnostic_information string is not user-friendly and may not be pretty.

That said, since I don't have mingw handy, could you please run this code with the latest trunk version? It should look a lot better now.

comment:3 by andrew mcardle <andrewmcardle1@…>, 13 years ago

Recompiled example_io.cpp with the trunk version (59443), seems to be working perfectly:

Caught 'read_error' exception.
-------------------------------------------------
Source file name: tmp1.txt
Destination file name: tmp2.txt
File name: tmp1.txt
OS error: 0
Failed function: fread

Output from diagnostic_information():
example_io.cpp(78): Throw in function void my_fread(void*, size_t, size_t, const
 boost::shared_ptr<_iobuf>&)
Dynamic exception type: boost::exception_detail::clone_impl<fread_error>
std::exception::what: example_io error
[tag_file_name_dst*] = tmp2.txt
[tag_file_name_src*] = tmp1.txt
[boost::errinfo_errno_*] = 0, "No error"
[boost::errinfo_file_name_*] = tmp1.txt
[boost::errinfo_file_handle_*] = [ type: N5boost10error_infoINS_20errinfo_file_h
andle_ENS_8weak_ptrI6_iobufEEEE, size: 12, dump: 68 67 49 00 b8 09 17 77 58 0f 3
3 00 ]
[boost::errinfo_api_function_*] = fread

Caught 'open_error' exception.
-------------------------------------------------
File name: tmp1.txt
OS error: 2
Failed function: fopen

Output from diagnostic_information():
example_io.cpp(67): Throw in function boost::shared_ptr<_iobuf> my_fopen(const c
har*, const char*)
Dynamic exception type: boost::exception_detail::clone_impl<fopen_error>
std::exception::what: example_io error
[boost::errinfo_errno_*] = 2, "No such file or directory"
[boost::errinfo_file_name_*] = tmp1.txt
[boost::errinfo_api_function_*] = fopen
[boost::errinfo_file_open_mode_*] = rb

comment:4 by Emil Dotchevski, 13 years ago

Status: newassigned

Ah, not entirely perfect, a bit of mangling can be seen in the boost::errinfo_file_handle_ value. Should be good in trunk revision #59449.

comment:5 by andrew mcardle <andrewmcardle1@…>, 13 years ago

Tried with latest trunk version, all fine now:

Caught 'read_error' exception.
-------------------------------------------------
Source file name: tmp1.txt
Destination file name: tmp2.txt
File name: tmp1.txt
OS error: 0
Failed function: fread

Output from diagnostic_information():
example_io.cpp(78): Throw in function void my_fread(void*, size_t, size_t, const
 boost::shared_ptr<_iobuf>&)
Dynamic exception type: boost::exception_detail::clone_impl<fread_error>
std::exception::what: example_io error
[tag_file_name_dst*] = tmp2.txt
[tag_file_name_src*] = tmp1.txt
[boost::errinfo_errno_*] = 0, "No error"
[boost::errinfo_file_name_*] = tmp1.txt
[boost::errinfo_file_handle_*] = [ type: boost::error_info<boost::errinfo_file_h
andle_, boost::weak_ptr<_iobuf> >, size: 12, dump: 68 67 49 00 b8 09 17 77 58 0f
 25 00 ]
[boost::errinfo_api_function_*] = fread

Caught 'open_error' exception.
-------------------------------------------------
File name: tmp1.txt
OS error: 2
Failed function: fopen

Output from diagnostic_information():
example_io.cpp(67): Throw in function boost::shared_ptr<_iobuf> my_fopen(const c
har*, const char*)
Dynamic exception type: boost::exception_detail::clone_impl<fopen_error>
std::exception::what: example_io error
[boost::errinfo_errno_*] = 2, "No such file or directory"
[boost::errinfo_file_name_*] = tmp1.txt
[boost::errinfo_api_function_*] = fopen
[boost::errinfo_file_open_mode_*] = rb

comment:6 by Emil Dotchevski, 13 years ago

Resolution: fixed
Status: assignedclosed

Thanks, Andrew.

Note: See TracTickets for help on using tickets.