Sysprogs forums › Forums › Other tools & products › BazisLib STLPort exception handling disabled
- This topic has 4 replies, 2 voices, and was last updated 14 years, 9 months ago by airmax.
-
AuthorPosts
-
February 7, 2010 at 16:02 #158airmaxParticipant
BazisLib uses STLPort with exception handling disabled.
What happens if map::insert fails to allocate memory?February 7, 2010 at 16:07 #1322supportKeymasterIf I remember correctly, a call to exit(), that is equivalent to KeBugCheck(). You need to patch STLPort to handle such cases correctly.
February 7, 2010 at 17:02 #1323airmaxParticipantYes, you correct.
_alloc.h:# define __THROW_BAD_ALLOC puts("out of memoryn"); exit(1)
stlsup.cpp:
void _cdecl exit(int _Code) { KeBugCheck(STATUS_INTERNAL_ERROR); }
Also, i want to ask non BazisLib related question 🙂
I start using C++ and STLPort in NDIS driver, where most of calls on DISPATCH_LEVEL, so, memory must be allocated from NonPaged pool. When allocating memory from NonPaged pool frequently (for example, for packet modifying) chances to have out of memory are high.Exception handling support will help in this case. Lets assume, that exceptions stack usage overhead isn’t a problem.
What you think about this implementation http://code.google.com/p/ontl/source/browse/trunk/ntl/rtl/eh.cppMaybe another ideas?
February 7, 2010 at 17:51 #1324supportKeymasterUnfortunately, I don’t have much time to look into details right now. However, I don’t think that relying on undocumented _CxxThrowException(), that can be changed in future versions, is a good idea. Moreover, I don’t explicitly see whether your example is compatible with x64.
I would suggest redefining __THROW_BAD_ALLOC using SEH. As SEH is already supported by WDK, that should not be a problem. We won’t get a full equivalent of C++ exceptions, however, this particular problem (handle npagednew() for STL containers) will be solved smoothly.February 7, 2010 at 19:11 #1325airmaxParticipant@bazis wrote:
Unfortunately, I don’t have much time to look into details right now. However, I don’t think that relying on undocumented _CxxThrowException(), that can be changed in future versions, is a good idea.
Yes, but this is another question, lets assume this is not problem.
@bazis wrote:
Moreover, I don’t explicitly see whether your example is compatible with x64.
Oh, i give incorrect link. Actual branch is x64. So, as i see from eh.cpp and ehsup.asm code, its will work on x64 too:
http://code.google.com/p/ontl/source/browse/branches/x64/ntl/rtl/eh.cpp
When you will have some time, plz have a look and tell your opinion.@bazis wrote:
I would suggest redefining __THROW_BAD_ALLOC using SEH. As SEH is already supported by WDK, that should not be a problem. We won’t get a full equivalent of C++ exceptions, however, this particular problem (handle npagednew() for STL containers) will be solved smoothly.
Thanks for suggestion! I like this idea too. Going to use it.
Also will research on EH implementation above. Support for local objects destruction very important, so RAII principles are not broken. -
AuthorPosts
- You must be logged in to reply to this topic.