I use the __try __finally pattern quite often. I also regularly use the goto abortNN pattern and the choice depends mostly on the kind of function being written.
when writing a function that acquires a resource that must be freed in the same context, the __try __finally pattern works quite well. usually, the inner block is simply a function call so the ability to optimize the code by the compiler is quite irrelevant for example
pResouce = LookupXWithReferencebyY(y)
if(pResource == NULL)
{
Sent from Outlookhttp:
From: xxxxx@lists.osr.com on behalf of Doron Holan
Sent: October 6, 2016 12:46:57 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] should i use try/finally or not
This is an implementation detail. The entire block will not be optimized as the compiler can’t know which instruction will raise an exception, so it plays it safe.
Get Outlook for Androidhttps:
From: xxxxx@lists.osr.com on behalf of Jeremy Hurren
Sent: Wednesday, October 5, 2016 8:58:11 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] should i use try/finally or not
Doron, do you have any more information about this? A link or something? Does it prevent any optimization for the entire block, or certain optimizations? I haven’t heard of this before, and was just adding some SEH to my driver after reading some parts of Rajeev Nagar’s book.
On Wed, Oct 5, 2016 at 9:31 AM, Doron Holan > wrote:
Yes SEH does prevent the optimizer from working on code in the block
From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.commailto:xxxxx] On Behalf Of Mark Roddy
Sent: Wednesday, October 5, 2016 3:46 AM
To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] should i use try/finally or not
I looked yesterday. _try/ finally consumes an entire 16 bytes of stack. I suppose that might be super critical in some situation.
Mark Roddy
On Wed, Oct 5, 2016 at 2:36 AM, > wrote:
Thanks All,
@peter - how try/finally is a terrible programming practice?, Did you mean that try __finally will consume more stack and it is wrong, so use of SEH should be limited to for API’s which throws exception.
Or is there any other reasons as well?
Does SEH prohibit the compiler from making optimizations to the code?
—
NTDEV is sponsored by OSR
Visit the list online at: http:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:
To unsubscribe, visit the List Server section of OSR Online at http:
— NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at To unsubscribe, visit the List Server section of OSR Online at
—
NTDEV is sponsored by OSR
Visit the list online at: http:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:
To unsubscribe, visit the List Server section of OSR Online at http:
— NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at To unsubscribe, visit the List Server section of OSR Online at
—
NTDEV is sponsored by OSR
Visit the list online at: http:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:
To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></http:></http:></http:></http:></http:></http:></mailto:xxxxx></mailto:xxxxx></https:></http:>