boost::any_cast gives build errors with VS2022, boost v1.82 and C++17

Hi, I was using VS2019, boost v1.78, and C++14 version and the below code was working well. Same code gives build error with VS2022, boost v1.82, and C++17 due to "o << *boost::any_cast<T>(&a); " Instruction. I wanted to know why it behaves differently. Code : class any_out { struct streamer { virtual void print(std::ostream& o, const boost::any& a) = 0; virtual streamer* clone() = 0; virtual ~streamer() {} }; public: any_out() : m_streamer(nullptr) { } ~any_out() { delete m_streamer; } template <typename T> any_out(const T& value) : m_streamer(new streamer_imp<T>), m_object(value) { } any_out(const any_out& a) : m_streamer(a.m_streamer ? a.m_streamer->clone() : nullptr), m_object(a.m_object) { } template <typename T> any_out& operator=(const T& r) { any_out(r).swap(*this); return *this; } any_out& operator=(const any_out& r) { any_out(r).swap(*this); return *this; } any_out& swap(any_out& r) noexcept { std::swap(m_streamer, r.m_streamer); std::swap(m_object, r.m_object); return *this; } friend std::ostream& operator<<(std::ostream& o, const any_out& a) { if(a.m_streamer) { a.m_streamer->print(o, a.m_object); } return o; } boost::any& get() { return m_object; } const boost::any get()const { return m_object; } bool empty() const { return m_object.empty(); } private: template <typename T> struct streamer_imp : public streamer { virtual void print(std::ostream& o, const boost::any& a) { try { if (a.empty()) { o << "<empty>"; } else { o << *boost::any_cast<T>(&a); } } } virtual streamer* clone() { return new streamer_imp<T>(); } }; // Members streamer* m_streamer; boost::any m_object; }; I have migrated to VS2022, boost v1.82, and C++17, and due to a build error, I have changed the code below. virtual void print(std::ostream& o, const boost::any& a) { try { if (a.empty()) { o << "<empty>"; } else { o << boost::any_cast<T*>(a); } } } any_out anyTest; anyTest = 100; std::string actualStr; actualStr = make_string() << anyTest; actualStr prints nullptr (0000000) instated of value 100 for VS2022, boost v1.82 and C++17 Best Regards, Jyotideep (JD) Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment. Confidential - Company Proprietary

On Fri, Sep 29, 2023, 23:41 Bhuyan, Jyotideep via Boost < boost@lists.boost.org> wrote:
Hi,
I was using VS2019, boost v1.78, and C++14 version and the below code was working well. Same code gives build error with VS2022, boost v1.82, and C++17 due to "o << *boost::any_cast<T>(&a); " Instruction. I wanted to know why it behaves differently.
Code :
class any_out { struct streamer { virtual void print(std::ostream& o, const boost::any& a) = 0; virtual streamer* clone() = 0; virtual ~streamer() {} };
public: any_out() : m_streamer(nullptr) { }
~any_out() { delete m_streamer; }
template <typename T> any_out(const T& value) : m_streamer(new streamer_imp<T>), m_object(value) { }
any_out(const any_out& a) : m_streamer(a.m_streamer ? a.m_streamer->clone() : nullptr), m_object(a.m_object) { }
template <typename T> any_out& operator=(const T& r) { any_out(r).swap(*this); return *this; }
any_out& operator=(const any_out& r) { any_out(r).swap(*this); return *this; }
any_out& swap(any_out& r) noexcept { std::swap(m_streamer, r.m_streamer); std::swap(m_object, r.m_object); return *this; }
friend std::ostream& operator<<(std::ostream& o, const any_out& a) { if(a.m_streamer) { a.m_streamer->print(o, a.m_object); } return o; }
boost::any& get() { return m_object; } const boost::any get()const { return m_object; } bool empty() const { return m_object.empty(); }
private:
template <typename T> struct streamer_imp : public streamer { virtual void print(std::ostream& o, const boost::any& a) { try { if (a.empty()) { o << "<empty>"; } else { o << *boost::any_cast<T>(&a); }
} } virtual streamer* clone() { return new streamer_imp<T>(); } };
// Members streamer* m_streamer; boost::any m_object;
};
I have migrated to VS2022, boost v1.82, and C++17, and due to a build error, I have changed the code below.
virtual void print(std::ostream& o, const boost::any& a) { try { if (a.empty()) { o << "<empty>"; } else { o << boost::any_cast<T*>(a); }
} }
any_out anyTest; anyTest = 100; std::string actualStr; actualStr = make_string() << anyTest;
actualStr prints nullptr (0000000) instated of value 100 for VS2022, boost v1.82 and C++17
It looks like you are using boost::any incorrectly. You cannot know ahead of time that an any is golding a T. If you want to use a T, you have to check it. An any my be non-empty, but may be storing some other type U. any_cast allows you to chech it. If it retuns a null pointer, it means you are storing some other type than T. Maybe you need boost:optional<T> rather than boost::any? Regards, &rzej;
Best Regards, Jyotideep (JD)
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.
Confidential - Company Proprietary
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Bhuyan, Jyotideep wrote:
Hi,
I was using VS2019, boost v1.78, and C++14 version and the below code was working well. Same code gives build error with VS2022, boost v1.82, and C++17 due to "o << *boost::any_cast<T>(&a); " Instruction. I wanted to know why it behaves differently.
Your code compiles and works for me with VS2022 and C++17 (after adding a `catch` clause after the `try`, e.g. https://godbolt.org/z/eWv9sjYzz.) What errors do you get?
Code :
class any_out { struct streamer { virtual void print(std::ostream& o, const boost::any& a) = 0; virtual streamer* clone() = 0; virtual ~streamer() {} };
public: any_out() : m_streamer(nullptr) { }
~any_out() { delete m_streamer; }
template <typename T> any_out(const T& value) : m_streamer(new streamer_imp<T>), m_object(value) { }
any_out(const any_out& a) : m_streamer(a.m_streamer ? a.m_streamer->clone() : nullptr), m_object(a.m_object) { }
template <typename T> any_out& operator=(const T& r) { any_out(r).swap(*this); return *this; }
any_out& operator=(const any_out& r) { any_out(r).swap(*this); return *this; }
any_out& swap(any_out& r) noexcept { std::swap(m_streamer, r.m_streamer); std::swap(m_object, r.m_object); return *this; }
friend std::ostream& operator<<(std::ostream& o, const any_out& a) { if(a.m_streamer) { a.m_streamer->print(o, a.m_object); } return o; }
boost::any& get() { return m_object; } const boost::any get()const { return m_object; } bool empty() const { return m_object.empty(); }
private:
template <typename T> struct streamer_imp : public streamer { virtual void print(std::ostream& o, const boost::any& a) { try { if (a.empty()) { o << "<empty>"; } else { o << *boost::any_cast<T>(&a); }
} } virtual streamer* clone() { return new streamer_imp<T>(); } };
// Members streamer* m_streamer; boost::any m_object;
};
I have migrated to VS2022, boost v1.82, and C++17, and due to a build error, I have changed the code below.
virtual void print(std::ostream& o, const boost::any& a) { try { if (a.empty()) { o << "<empty>"; } else { o << boost::any_cast<T*>(a); }
} }
any_out anyTest; anyTest = 100; std::string actualStr; actualStr = make_string() << anyTest;
actualStr prints nullptr (0000000) instated of value 100 for VS2022, boost v1.82 and C++17
Best Regards, Jyotideep (JD)
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.
Confidential - Company Proprietary
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

This is strange ☹ By mistake, I removed the catch block from the example code. This was present in the original piece of code. I am getting the compilation error with the new boost 1.82 and the VS2022 (v143 ) + C++17 is as follows at this line. o << *boost::any_cast<T>(&a); //which was running with boost version 1.78 + VS2019 (v142) + C++14 Severity Code Description Error C2679 binary '<<': no operator found which takes a right-hand operand of type 'const ValueType' (or there is no acceptable conversion) Best Regards, Jyotideep (JD) Confidential - Company Proprietary From: Boost <boost-bounces@lists.boost.org> On Behalf Of Peter Dimov via Boost Sent: Saturday, September 30, 2023 12:55 PM To: boost@lists.boost.org Cc: Peter Dimov <pdimov@gmail.com> Subject: Re: [boost] boost::any_cast gives build errors with VS2022, boost v1.82 and C++17 Bhuyan, Jyotideep wrote: > Hi, > > I was using VS2019, boost v1. 78, and C++14 version and the below code was > working well. Same code gives build error with VS2022, boost v1. 82, and > C++17 due to "o << *boost: : any_cast<T>(&a); ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization. Use caution when opening. ZjQcmQRYFpfptBannerEnd Bhuyan, Jyotideep wrote:
Hi,
I was using VS2019, boost v1.78, and C++14 version and the below code was
working well. Same code gives build error with VS2022, boost v1.82, and
C++17 due to "o << *boost::any_cast<T>(&a);
" Instruction. I wanted to know why it behaves differently.
Your code compiles and works for me with VS2022 and C++17 (after adding a `catch` clause after the `try`, e.g. https://urldefense.proofpoint.com/v2/url?u=https-3A__godbolt.org_z_eWv9sjYzz&d=DwICAg&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=nKjmvhl-FVZt-1iD5Ea7mULt--dNphU4qGuhbCJsO90&m=phs2270IlMJnrkY8KPgf3575O_9O78a6bb347nW4R28oRm_nFrGGqsw3BpqiTWZ4&s=hynNTB7tJ605xXLfaD7lhvL1xAyZ7JlB7RRwzxtQq0I&e=.) What errors do you get?
Code :
class any_out
{
struct streamer
{
virtual void print(std::ostream& o, const boost::any& a) = 0;
virtual streamer* clone() = 0;
virtual ~streamer() {}
};
public:
any_out() : m_streamer(nullptr)
{
}
~any_out()
{
delete m_streamer;
}
template <typename T> any_out(const T& value)
: m_streamer(new streamer_imp<T>), m_object(value)
{
}
any_out(const any_out& a)
: m_streamer(a.m_streamer ? a.m_streamer->clone() : nullptr),
m_object(a.m_object)
{
}
template <typename T> any_out& operator=(const T& r)
{
any_out(r).swap(*this);
return *this;
}
any_out& operator=(const any_out& r)
{
any_out(r).swap(*this);
return *this;
}
any_out& swap(any_out& r) noexcept
{
std::swap(m_streamer, r.m_streamer);
std::swap(m_object, r.m_object);
return *this;
}
friend std::ostream& operator<<(std::ostream& o, const any_out& a)
{
if(a.m_streamer)
{
a.m_streamer->print(o, a.m_object);
}
return o;
}
boost::any& get() { return m_object; }
const boost::any get()const { return m_object; }
bool empty() const { return m_object.empty(); }
private:
template <typename T> struct streamer_imp : public streamer
{
virtual void print(std::ostream& o, const boost::any& a)
{
try {
if (a.empty()) {
o << "<empty>";
}
else {
o << *boost::any_cast<T>(&a);
}
}
}
virtual streamer* clone()
{
return new streamer_imp<T>();
}
};
// Members
streamer* m_streamer;
boost::any m_object;
};
I have migrated to VS2022, boost v1.82, and C++17, and due to a build error,
I have changed the code below.
virtual void print(std::ostream& o, const boost::any& a)
{
try {
if (a.empty()) {
o << "<empty>";
}
else {
o << boost::any_cast<T*>(a);
}
}
}
any_out anyTest;
anyTest = 100;
std::string actualStr;
actualStr = make_string() << anyTest;
actualStr prints nullptr (0000000) instated of value 100 for VS2022, boost
v1.82 and C++17
Best Regards,
Jyotideep (JD)
Please be advised that this email may contain confidential information. If you
are not the intended recipient, please notify us by email by replying to the
sender and delete this message. The sender disclaims that the content of this
email constitutes an offer to enter into, or the acceptance of, any agreement;
provided that the foregoing does not invalidate the binding effect of any
digital or other electronic reproduction of a manual signature that is included
in any attachment.
Confidential - Company Proprietary
_______________________________________________
_______________________________________________ Unsubscribe & other changes: https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.boost.org_mailman_listinfo.cgi_boost&d=DwICAg&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=nKjmvhl-FVZt-1iD5Ea7mULt--dNphU4qGuhbCJsO90&m=phs2270IlMJnrkY8KPgf3575O_9O78a6bb347nW4R28oRm_nFrGGqsw3BpqiTWZ4&s=PmpOkIwy-jd3O0wS2fcKgI6GRM5c7a6g75F3Fo_jPhA&e= Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.

Hi, My application uses the boost version of 1.78. and it crashes after running for approximately 2 hours. When I created the dump file, I saw the below exceptions. Can anyone share some insight into what is happening here? How to debug and fix this issue? EXCEPTION_RECORD: (.exr -1) ExceptionAddress: 00007ffc2fece77e (ucrtbase!abort+0x000000000000004e) ExceptionCode: c0000409 (Security check failure or stack buffer overrun) ExceptionFlags: 00000001 NumberParameters: 1 Parameter[0]: 0000000000000007 Subcode: 0x7 FAST_FAIL_FATAL_APP_EXIT PROCESS_NAME: cytiva-aktaflux.exe ERROR_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application. EXCEPTION_CODE_STR: c0000409 EXCEPTION_PARAMETER1: 0000000000000007 FAULTING_THREAD: 00000d2c STACK_TEXT: 00000069`f24fe7a0 00007ffc`220a6c4a : 00007ff6`00000003 000001b4`00000003 00000069`f24fe860 00007ff6`33cc181f : ucrtbase!abort+0x4e 00000069`f24fe7d0 00007ff6`33c41272 : 00000069`f24ff180 00000000`00000000 00000069`00000001 000001b4`301fc3d8 : VCRUNTIME140!_purecall+0x1a 00000069`f24fe800 00007ff6`33cc2d42 : 000001b4`301ff8c0 00000069`f24fe890 00000069`f24fe9d0 00000000`ffffffff : cytiva_aktaflux!ILT+131690(?ReportWarningPumpControllerabbaEEAAXAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD+0x3 00000069`f24fe840 00007ff6`33dc38ad : 00000069`f24fe9d0 000001b4`301ff8c0 000001b4`4a725560 0000a9ff`85eb46dc : cytiva_aktaflux!boost::system::detail::system_category_message_win32+0x1b2 00000069`f24fe890 00007ff6`33dc2b22 : 000001b4`301ff8c0 00000000`ffffffff 000001b4`301ff8c0 00000000`ffffffff : cytiva_aktaflux!boost::date_time::microsec_clock<boost::posix_time::ptime>::create_time+0xfd 00000069`f24fe8d0 00007ff6`33cb9655 : 000001b4`4d1f8b40 000001b4`4d1f8b40 00000000`00000000 00000000`00000001 : cytiva_aktaflux!std::_Tree<std::_Tmap_traits<unsigned short,ViewDebugRegisterValuesFrame::RegisterTrack,std::less<unsigned short>,std::allocator<std::pair<unsigned short const ,ViewDebugRegisterValuesFrame::RegisterTrack> >,0> >::clear+0x72 00000069`f24fef90 00007ff6`33cb922d : 000001b4`4d1f8b78 000001b4`4d1f8b78 000001b4`4d1f8b40 0000000f`042da045 : cytiva_aktaflux!boost::exception_detail::clone_impl<boost::exception_detail::bad_alloc_>::clone+0xa5 00000069`f24ff060 00007ff6`33cbb200 : 00000069`f24ff1b0 00000000`00000000 000001b4`4ef19a80 00000069`f24ff3b0 : cytiva_aktaflux!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::begin+0xd 00000069`f24ff130 00007ff6`33cb16ff : 000001b4`4d4138f0 00000000`00000001 00000000`00000000 000001b4`4d4138f0 : cytiva_aktaflux!boost::system::error_code::equals+0x120 00000069`f24ff220 00007ff6`33cb1144 : 00000000`00000000 00000069`00000000 00000069`f24ff3b0 00000069`f24ff510 : cytiva_aktaflux!boost::exception_detail::clone_impl<boost::exception_detail::bad_exception_>::clone_impl<boost::exception_detail::bad_exception_>+0xaf 00000069`f24ff370 00007ff6`33cb2c4a : 00000000`00000000 00000000`ffffffff 00000000`00000000 000001b4`4d25dd10 : cytiva_aktaflux!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >+0x34 00000069`f24ff450 00007ff6`33cb2403 : 00000000`406d1388 000001b4`4d208718 000001b4`4d2086a0 00000000`00000000 : cytiva_aktaflux!std::bad_exception::bad_exception+0x3a 00000069`f24ffab0 00007ff6`33c70cd4 : 000001b4`4d208730 000001b4`4d208718 000001b4`4d2086a0 00000000`00000000 : cytiva_aktaflux!boost::wrapexcept<boost::property_tree::ptree_bad_path>::wrapexcept<boost::property_tree::ptree_bad_path>+0x53 00000069`f24ffcb0 00007ff6`33f0df8a : 000001b4`4d42b3e0 00000000`00000000 000001b4`4d42b3e0 00000000`00000000 : cytiva_aktaflux!boost::asio::error::`dynamic initializer for 'misc_category''+0x14 00000069`f24ffe40 00007ffc`2fe8268a : 00000000`00000000 000001b4`4d287670 00000000`00000000 00000000`00000000 : cytiva_aktaflux!boost::exception_detail::current_exception_std_exception<std::underflow_error>+0x9a 00000069`f24ffe70 00007ffc`32917ad4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ucrtbase!thread_start<unsigned int (__cdecl*)(void * __ptr64)>+0x3a 00000069`f24ffea0 00007ffc`333aa371 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14 00000069`f24ffed0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21 Best Regards, Jyotideep (JD) Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment. Confidential - Company Proprietary

Looks like a crash due to undefined behavior. Apparently ReportWarningPumpController::abba leads to invocation of a pure virtual function call. This usually indicates that a pointer is stale or refers to an instance of a virtual type that is not yet / no longer fully constructed. This, in turn seems to happen in response to an `std::underflow_error` being thrown. The standard library components do not throw this exception (mathematical functions report underflow errors as specified in https://en.cppreference.com/w/cpp/numeric/math/math_errhandling). Third-party libraries, however, use this. For example, boost.math throws std::underflow_error if boost::math::policies::throw_on_error is enabled (the default setting). That likely makes this an application domain bug. Or it should give you information to reduce to a minimal reproducer that leads to the exception being raised in case you think it is raised in error. More analysis will be pretty hard without source code. Hope this helps, Seth On Tue, Jun 18, 2024, at 2:55 PM, Bhuyan, Jyotideep via Boost wrote:
Hi, My application uses the boost version of 1.78. and it crashes after running for approximately 2 hours. When I created the dump file, I saw the below exceptions. Can anyone share some insight into what is happening here? How to debug and fix this issue?
EXCEPTION_RECORD: (.exr -1) ExceptionAddress: 00007ffc2fece77e (ucrtbase!abort+0x000000000000004e) ExceptionCode: c0000409 (Security check failure or stack buffer overrun) ExceptionFlags: 00000001 NumberParameters: 1 Parameter[0]: 0000000000000007 Subcode: 0x7 FAST_FAIL_FATAL_APP_EXIT
PROCESS_NAME: cytiva-aktaflux.exe
ERROR_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application.
EXCEPTION_CODE_STR: c0000409
EXCEPTION_PARAMETER1: 0000000000000007
FAULTING_THREAD: 00000d2c
STACK_TEXT: 00000069`f24fe7a0 00007ffc`220a6c4a : 00007ff6`00000003 000001b4`00000003 00000069`f24fe860 00007ff6`33cc181f : ucrtbase!abort+0x4e 00000069`f24fe7d0 00007ff6`33c41272 : 00000069`f24ff180 00000000`00000000 00000069`00000001 000001b4`301fc3d8 : VCRUNTIME140!_purecall+0x1a 00000069`f24fe800 00007ff6`33cc2d42 : 000001b4`301ff8c0 00000069`f24fe890 00000069`f24fe9d0 00000000`ffffffff : cytiva_aktaflux!ILT+131690(?ReportWarningPumpControllerabbaEEAAXAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD+0x3 00000069`f24fe840 00007ff6`33dc38ad : 00000069`f24fe9d0 000001b4`301ff8c0 000001b4`4a725560 0000a9ff`85eb46dc : cytiva_aktaflux!boost::system::detail::system_category_message_win32+0x1b2 00000069`f24fe890 00007ff6`33dc2b22 : 000001b4`301ff8c0 00000000`ffffffff 000001b4`301ff8c0 00000000`ffffffff : cytiva_aktaflux!boost::date_time::microsec_clock<boost::posix_time::ptime>::create_time+0xfd 00000069`f24fe8d0 00007ff6`33cb9655 : 000001b4`4d1f8b40 000001b4`4d1f8b40 00000000`00000000 00000000`00000001 : cytiva_aktaflux!std::_Tree<std::_Tmap_traits<unsigned short,ViewDebugRegisterValuesFrame::RegisterTrack,std::less<unsigned short>,std::allocator<std::pair<unsigned short const ,ViewDebugRegisterValuesFrame::RegisterTrack> >,0> >::clear+0x72 00000069`f24fef90 00007ff6`33cb922d : 000001b4`4d1f8b78 000001b4`4d1f8b78 000001b4`4d1f8b40 0000000f`042da045 : cytiva_aktaflux!boost::exception_detail::clone_impl<boost::exception_detail::bad_alloc_>::clone+0xa5 00000069`f24ff060 00007ff6`33cbb200 : 00000069`f24ff1b0 00000000`00000000 000001b4`4ef19a80 00000069`f24ff3b0 : cytiva_aktaflux!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::begin+0xd 00000069`f24ff130 00007ff6`33cb16ff : 000001b4`4d4138f0 00000000`00000001 00000000`00000000 000001b4`4d4138f0 : cytiva_aktaflux!boost::system::error_code::equals+0x120 00000069`f24ff220 00007ff6`33cb1144 : 00000000`00000000 00000069`00000000 00000069`f24ff3b0 00000069`f24ff510 : cytiva_aktaflux!boost::exception_detail::clone_impl<boost::exception_detail::bad_exception_>::clone_impl<boost::exception_detail::bad_exception_>+0xaf 00000069`f24ff370 00007ff6`33cb2c4a : 00000000`00000000 00000000`ffffffff 00000000`00000000 000001b4`4d25dd10 : cytiva_aktaflux!std::basic_string<char,std::char_traits<char>,std::allocator<char> ::basic_string<char,std::char_traits<char>,std::allocator<char> >+0x34 00000069`f24ff450 00007ff6`33cb2403 : 00000000`406d1388 000001b4`4d208718 000001b4`4d2086a0 00000000`00000000 : cytiva_aktaflux!std::bad_exception::bad_exception+0x3a 00000069`f24ffab0 00007ff6`33c70cd4 : 000001b4`4d208730 000001b4`4d208718 000001b4`4d2086a0 00000000`00000000 : cytiva_aktaflux!boost::wrapexcept<boost::property_tree::ptree_bad_path>::wrapexcept<boost::property_tree::ptree_bad_path>+0x53 00000069`f24ffcb0 00007ff6`33f0df8a : 000001b4`4d42b3e0 00000000`00000000 000001b4`4d42b3e0 00000000`00000000 : cytiva_aktaflux!boost::asio::error::`dynamic initializer for 'misc_category''+0x14 00000069`f24ffe40 00007ffc`2fe8268a : 00000000`00000000 000001b4`4d287670 00000000`00000000 00000000`00000000 : cytiva_aktaflux!boost::exception_detail::current_exception_std_exception<std::underflow_error>+0x9a 00000069`f24ffe70 00007ffc`32917ad4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ucrtbase!thread_start<unsigned int (__cdecl*)(void * __ptr64)>+0x3a 00000069`f24ffea0 00007ffc`333aa371 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14 00000069`f24ffed0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21
Best Regards, Jyotideep (JD) Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.
Confidential - Company Proprietary
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Attachments: * windbg.txt

Hi Seth, Further investigating on the same line as you have pointed out, We could see in the call stack it is pointing to any.hpp (Boost version 1.78 ) clone() function which is a pure virtual method. It is causing a crash since it is leading to the call __purecall() method of ucrtbase.dll (windows 10) which in turn calls the abort method to terminate the process. Can you please advise on how to resolve this issue? Additionally, just wanted to understand why a pure virtual method call is happening from the constructor. [cid:image001.png@01DAC891.53E09050] Best Regards, Jyotideep (JD) Confidential - Company Proprietary From: Boost <boost-bounces@lists.boost.org> On Behalf Of Seth via Boost Sent: Tuesday, June 25, 2024 6:09 AM To: Boost List <boost@lists.boost.org> Cc: Seth <bugs@sehe.nl> Subject: Re: [boost] Application crash due to boost Looks like a crash due to undefined behavior. Apparently ReportWarningPumpController: : abba leads to invocation of a pure virtual function call. This usually indicates that a pointer is stale or refers to an instance of a virtual type that is ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization. Use caution when opening. ZjQcmQRYFpfptBannerEnd Looks like a crash due to undefined behavior. Apparently ReportWarningPumpController::abba leads to invocation of a pure virtual function call. This usually indicates that a pointer is stale or refers to an instance of a virtual type that is not yet / no longer fully constructed. This, in turn seems to happen in response to an `std::underflow_error` being thrown. The standard library components do not throw this exception (mathematical functions report underflow errors as specified in https://urldefense.com/v3/__https://en.cppreference.com/w/cpp/numeric/math/math_errhandling__;!!G8Er-fQLpA!PFdqC80cipChB5rIkDH1aktGE0i6XEEjdFsAZu85skLdRBti21XVgU7V68UMon1l2Z7yNyDxDNa4EfQgPSmPlBno$<https://urldefense.com/v3/__https:/en.cppreference.com/w/cpp/numeric/math/math_errhandling__;!!G8Er-fQLpA!PFdqC80cipChB5rIkDH1aktGE0i6XEEjdFsAZu85skLdRBti21XVgU7V68UMon1l2Z7yNyDxDNa4EfQgPSmPlBno$>). Third-party libraries, however, use this. For example, boost.math throws std::underflow_error if boost::math::policies::throw_on_error is enabled (the default setting). That likely makes this an application domain bug. Or it should give you information to reduce to a minimal reproducer that leads to the exception being raised in case you think it is raised in error. More analysis will be pretty hard without source code. Hope this helps, Seth On Tue, Jun 18, 2024, at 2:55 PM, Bhuyan, Jyotideep via Boost wrote:
Hi,
My application uses the boost version of 1.78. and it crashes after
running for approximately 2 hours. When I created the dump file, I saw
the below exceptions. Can anyone share some insight into what is
happening here? How to debug and fix this issue?
EXCEPTION_RECORD: (.exr -1)
ExceptionAddress: 00007ffc2fece77e (ucrtbase!abort+0x000000000000004e)
ExceptionCode: c0000409 (Security check failure or stack buffer overrun)
ExceptionFlags: 00000001
NumberParameters: 1
Parameter[0]: 0000000000000007
Subcode: 0x7 FAST_FAIL_FATAL_APP_EXIT
PROCESS_NAME: cytiva-aktaflux.exe
ERROR_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a
stack-based buffer in this application. This overrun could potentially
allow a malicious user to gain control of this application.
EXCEPTION_CODE_STR: c0000409
EXCEPTION_PARAMETER1: 0000000000000007
FAULTING_THREAD: 00000d2c
STACK_TEXT:
00000069`f24fe7a0 00007ffc`220a6c4a : 00007ff6`00000003
000001b4`00000003 00000069`f24fe860 00007ff6`33cc181f :
ucrtbase!abort+0x4e
00000069`f24fe7d0 00007ff6`33c41272 : 00000069`f24ff180
00000000`00000000 00000069`00000001 000001b4`301fc3d8 :
VCRUNTIME140!_purecall+0x1a
00000069`f24fe800 00007ff6`33cc2d42 : 000001b4`301ff8c0
00000069`f24fe890 00000069`f24fe9d0 00000000`ffffffff :
cytiva_aktaflux!ILT+131690(?ReportWarningPumpControllerabbaEEAAXAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD+0x3
00000069`f24fe840 00007ff6`33dc38ad : 00000069`f24fe9d0
000001b4`301ff8c0 000001b4`4a725560 0000a9ff`85eb46dc :
cytiva_aktaflux!boost::system::detail::system_category_message_win32+0x1b2
00000069`f24fe890 00007ff6`33dc2b22 : 000001b4`301ff8c0
00000000`ffffffff 000001b4`301ff8c0 00000000`ffffffff :
cytiva_aktaflux!boost::date_time::microsec_clock<boost::posix_time::ptime>::create_time+0xfd
00000069`f24fe8d0 00007ff6`33cb9655 : 000001b4`4d1f8b40
000001b4`4d1f8b40 00000000`00000000 00000000`00000001 :
cytiva_aktaflux!std::_Tree<std::_Tmap_traits<unsigned
short,ViewDebugRegisterValuesFrame::RegisterTrack,std::less<unsigned
short>,std::allocator<std::pair<unsigned short const
,ViewDebugRegisterValuesFrame::RegisterTrack> >,0> >::clear+0x72
00000069`f24fef90 00007ff6`33cb922d : 000001b4`4d1f8b78
000001b4`4d1f8b78 000001b4`4d1f8b40 0000000f`042da045 :
cytiva_aktaflux!boost::exception_detail::clone_impl<boost::exception_detail::bad_alloc_>::clone+0xa5
00000069`f24ff060 00007ff6`33cbb200 : 00000069`f24ff1b0
00000000`00000000 000001b4`4ef19a80 00000069`f24ff3b0 :
cytiva_aktaflux!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::begin+0xd
00000069`f24ff130 00007ff6`33cb16ff : 000001b4`4d4138f0
00000000`00000001 00000000`00000000 000001b4`4d4138f0 :
cytiva_aktaflux!boost::system::error_code::equals+0x120
00000069`f24ff220 00007ff6`33cb1144 : 00000000`00000000
00000069`00000000 00000069`f24ff3b0 00000069`f24ff510 :
cytiva_aktaflux!boost::exception_detail::clone_impl<boost::exception_detail::bad_exception_>::clone_impl<boost::exception_detail::bad_exception_>+0xaf
00000069`f24ff370 00007ff6`33cb2c4a : 00000000`00000000
00000000`ffffffff 00000000`00000000 000001b4`4d25dd10 :
cytiva_aktaflux!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::basic_string<char,std::char_traits<char>,std::allocator<char> >+0x34
00000069`f24ff450 00007ff6`33cb2403 : 00000000`406d1388
000001b4`4d208718 000001b4`4d2086a0 00000000`00000000 :
cytiva_aktaflux!std::bad_exception::bad_exception+0x3a
00000069`f24ffab0 00007ff6`33c70cd4 : 000001b4`4d208730
000001b4`4d208718 000001b4`4d2086a0 00000000`00000000 :
cytiva_aktaflux!boost::wrapexcept<boost::property_tree::ptree_bad_path>::wrapexcept<boost::property_tree::ptree_bad_path>+0x53
00000069`f24ffcb0 00007ff6`33f0df8a : 000001b4`4d42b3e0
00000000`00000000 000001b4`4d42b3e0 00000000`00000000 :
cytiva_aktaflux!boost::asio::error::`dynamic initializer for
'misc_category''+0x14
00000069`f24ffe40 00007ffc`2fe8268a : 00000000`00000000
000001b4`4d287670 00000000`00000000 00000000`00000000 :
cytiva_aktaflux!boost::exception_detail::current_exception_std_exception<std::underflow_error>+0x9a
00000069`f24ffe70 00007ffc`32917ad4 : 00000000`00000000
00000000`00000000 00000000`00000000 00000000`00000000 :
ucrtbase!thread_start<unsigned int (__cdecl*)(void * __ptr64)>+0x3a
00000069`f24ffea0 00007ffc`333aa371 : 00000000`00000000
00000000`00000000 00000000`00000000 00000000`00000000 :
kernel32!BaseThreadInitThunk+0x14
00000069`f24ffed0 00000000`00000000 : 00000000`00000000
00000000`00000000 00000000`00000000 00000000`00000000 :
ntdll!RtlUserThreadStart+0x21
Best Regards,
Jyotideep (JD)
Please be advised that this email may contain confidential information.
If you are not the intended recipient, please notify us by email by
replying to the sender and delete this message. The sender disclaims
that the content of this email constitutes an offer to enter into, or
the acceptance of, any agreement; provided that the foregoing does not
invalidate the binding effect of any digital or other electronic
reproduction of a manual signature that is included in any attachment.
Confidential - Company Proprietary
_______________________________________________
Attachments:
* windbg.txt
_______________________________________________ Unsubscribe & other changes: https://urldefense.com/v3/__http://lists.boost.org/mailman/listinfo.cgi/boost__;!!G8Er-fQLpA!PFdqC80cipChB5rIkDH1aktGE0i6XEEjdFsAZu85skLdRBti21XVgU7V68UMon1l2Z7yNyDxDNa4EfQgPUSdv5Z3$<https://urldefense.com/v3/__http:/lists.boost.org/mailman/listinfo.cgi/boost__;!!G8Er-fQLpA!PFdqC80cipChB5rIkDH1aktGE0i6XEEjdFsAZu85skLdRBti21XVgU7V68UMon1l2Z7yNyDxDNa4EfQgPUSdv5Z3$> Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.

On Thu, Jun 27, 2024, at 9:25 AM, Bhuyan, Jyotideep wrote:
Hi Seth, Further investigating on the same line as you have pointed out, We could see in the call stack it is pointing to any.hpp (Boost version 1.78 ) clone() function which is a pure virtual method. It is causing a crash since it is leading to the call __purecall() method of ucrtbase.dll (windows 10) which in turn calls the abort method to terminate the process. Can you please advise on how to resolve this issue?
I already gave all the analysis I could give. You may be able to create a minimal reproducer and post that. Then we can help. Sometimes creating a minimal reproducer allows you to spot the problem yourself.
Additionally, just wanted to understand why a pure virtual method call is happening from the constructor.
FWIW it's not caused by the `any` constructor, which merely calls the clone of the object being copied. Again, my best analysis is in my first message.
participants (3)
-
Andrzej Krzemienski
-
Bhuyan, Jyotideep
-
Peter Dimov
-
Seth