C# application crashes due exception in exception_ptr.hpp
Hi there, I´m new to boost so this might be a silly question. We have a simulation that is written in C++ and compiled as a static lib. It uses a few boost (v1.56) functions like thread. My job is to create a WPF GUI, that uses this lib. For that, I created a C++ CLR DLL which interacts as a wrapper between .NET GUI and the unmanaged libs. Everything works fine but closing my program results in a crash. This crash is described here: http://stackoverflow.com/questions/8144630/mixed-mode-c- cli-dll-throws-exception-on-exit And someone replied, that the reason for this lies in the exception_ptr.hpp beacause a "static exception_ptr ep" is being used instead of "exception_ptr ep". When I delete the static attribute, my program ends normally without the crash. My understanding of C++ is not that big, so I can´t say why it crashes here. But the boost programmers have a reason to do so. I also followed These advices (http://thread.gmane.org/gmane.comp.lib.boost.user/44515) but with no further luck. Best regards, Markus
On 2015-06-12 1:09 AM, Markus Pieper wrote:
Hi there,
I´m new to boost so this might be a silly question.
We have a simulation that is written in C++ and compiled as a static lib. It uses a few boost (v1.56) functions like thread.
My job is to create a WPF GUI, that uses this lib. For that, I created a C++ CLR DLL which interacts as a wrapper between .NET GUI and the unmanaged libs.
Everything works fine but closing my program results in a crash. This crash is described here: http://stackoverflow.com/questions/8144630/mixed-mode-c- cli-dll-throws-exception-on-exit And someone replied, that the reason for this lies in the exception_ptr.hpp beacause a "static exception_ptr ep" is being used instead of "exception_ptr ep". When I delete the static attribute, my program ends normally without the crash.
My understanding of C++ is not that big, so I can´t say why it crashes here. But the boost programmers have a reason to do so.
I also followed These advices (http://thread.gmane.org/gmane.comp.lib.boost.user/44515) but with no further luck.
Best regards, Markus _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I'd like to make a suggestion based on experience. I've had to do exactly what you're describing and build a WPF UI on a C++ simulation application. Use .Net's System.Runtime.InteropServices with DllImport and wrap your C++ lib in a plain C DLL. It doesn't take as long as you might think but it is more work. You'll have better separation of responsibilities and it doesn't prevent the use of Boost. Damien
Thank you for the input.
We chose to use a clr dll because we can easily instantiate objects and
don't need the "old" dllimport and dllexport syntax.
As we already put a lot of effort in this dll I don't think I couldn't
rewrite everything.
Best regards,
Markus
Gesendet mit AquaMail für Android
http://www.aqua-mail.com
Am 12. Juni 2015 17:16:18 schrieb Damien
On 2015-06-12 1:09 AM, Markus Pieper wrote:
Hi there,
I´m new to boost so this might be a silly question.
We have a simulation that is written in C++ and compiled as a static lib. It uses a few boost (v1.56) functions like thread.
My job is to create a WPF GUI, that uses this lib. For that, I created a C++ CLR DLL which interacts as a wrapper between .NET GUI and the unmanaged libs.
Everything works fine but closing my program results in a crash. This crash is described here: http://stackoverflow.com/questions/8144630/mixed-mode-c- cli-dll-throws-exception-on-exit And someone replied, that the reason for this lies in the exception_ptr.hpp beacause a "static exception_ptr ep" is being used instead of "exception_ptr ep". When I delete the static attribute, my program ends normally without the crash.
My understanding of C++ is not that big, so I can´t say why it crashes here. But the boost programmers have a reason to do so.
I also followed These advices (http://thread.gmane.org/gmane.comp.lib.boost.user/44515) but with no further luck.
Best regards, Markus _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I'd like to make a suggestion based on experience. I've had to do exactly what you're describing and build a WPF UI on a C++ simulation application. Use .Net's System.Runtime.InteropServices with DllImport and wrap your C++ lib in a plain C DLL. It doesn't take as long as you might think but it is more work. You'll have better separation of responsibilities and it doesn't prevent the use of Boost.
Damien _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Fri, Jun 12, 2015 at 12:09 AM, Markus Pieper
My job is to create a WPF GUI, that uses this lib. For that, I created a C++ CLR DLL which interacts as a wrapper between .NET GUI and the unmanaged libs.
Thank you for reporting this -- the person replying on stack overflow is right to think it looks suspicious, I put that static exception_ptr object in there and it looks suspicious to me too. :) At first glance it seems that the "static" in get_static_exception is there by mistake, probably it was important in an earlier version of the code but now the only place it's called is in the initialization of static objects so it does seem redundant. Please open a ticket for this, I'll investigate closer. That said, it is very suspicious that removing that "static" fixes your problem. Perhaps it's a good idea for you to investigate that too, it may be a symptom of something else going wrong in your program. -- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Thank you, I opened ticket #11403 with this issue.
Markus
Gesendet mit AquaMail für Android
http://www.aqua-mail.com
Am 12. Juni 2015 21:56:11 schrieb Emil Dotchevski
On Fri, Jun 12, 2015 at 12:09 AM, Markus Pieper
wrote: My job is to create a WPF GUI, that uses this lib. For that, I created a C++ CLR DLL which interacts as a wrapper between .NET GUI and the unmanaged libs.
Thank you for reporting this -- the person replying on stack overflow is right to think it looks suspicious, I put that static exception_ptr object in there and it looks suspicious to me too. :)
At first glance it seems that the "static" in get_static_exception is there by mistake, probably it was important in an earlier version of the code but now the only place it's called is in the initialization of static objects so it does seem redundant. Please open a ticket for this, I'll investigate closer.
That said, it is very suspicious that removing that "static" fixes your problem. Perhaps it's a good idea for you to investigate that too, it may be a symptom of something else going wrong in your program.
-- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
---------- _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Damien
-
Emil Dotchevski
-
Markus Pieper