What does the "pseudo-register number" argument to windbg StopOnException do? - windbg

Here's the help text for the windbg command StopOnException (aka soe for short):
0:000> !soe
usage: StopOnException [-derived] [-create | -create2] <type name>
[<pseudo-register number for result>]
ex: StopOnException -create System.OutOfMemoryException 1
What is the argument "pseudo-register number for result" for? The example uses the value 1 but without any follow up.
The only other documentation I can finds says just this:
StopOnException [-derived] [-create | -create2] <Exception> <Pseudo-register number>
Causes the debugger to stop when the specified exception is thrown,
but to continue running when other exceptions are thrown.
The -derived option catches the specified exception and every
exception that derives from the specified exception.
...no mention of this argument at all in the text. Nor any other use of the word "pseudo" on that page, or "register" with the same meaning.

There is additional help text within windbg that does explain it. Took me a while to realize this, maybe it will be useful to others new to windbg:
0:000> !help stoponexception
produces:
!StopOnException [-derived]
[-create | -create2]
<Exception>
[<Pseudo-register number>]
!StopOnException helps when you want the Windows Debugger to stop on a
particular managed exception, say a System.OutOfMemoryException, but
continue running if other exceptions are thrown. The command can be
used in two ways:
When you just want to stop on one particular CLR exception
At the debugger prompt, anytime after loading SOS, type:
!StopOnException -create System.OutOfMemoryException 1
The pseudo-register number (1) indicates that SOS can use register
$t1 for maintaining the breakpoint. The -create parameter allows
SOS to go ahead and set up the breakpoint as a first-chance
exception. -create2 would set it up as a 2nd-chance exception.
When you need more complex logic for stopping on a CLR exception
!StopOnException can be used purely as a predicate in a larger
expression. If you type:
!StopOnException System.OutOfMemoryException 3
then register $t3 will be set to 1 if the last thrown exception on
the current thread is a System.OutOfMemoryException. Otherwise,
$t3 will be set to 0. Using the Windows Debugger scripting
language, you could chain such calls together to stop on various
exception types. You'll have to manually create such predicates,
for example:
sxe -c "!soe System.OutOfMemoryException 3;
!soe -derived System.IOException 4;
.if(#$t3==1 || #$t4==1) { .echo 'stop' } .else {g}"
The -derived option will cause StopOnException to set the
pseudo-register to 1 even if the thrown exception type doesn't exactly
match the exception type given, but merely derives from it. So,
"-derived System.Exception" would catch every exception in the
System.Exception heirarchy.
The pseudo-register number is optional. If you don't pass a number,
SOS will use pseudo-register $t1.
I highlighted the relevant portions.
Essentially, this option allows you to specify which pseudo-register should be used to keep track of the breakpoint. Perhaps in some cases if you don't want to overwrite an existing important value, specifying your own register selection can avoid that.
More info on pseuo-register values: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/pseudo-register-syntax

Related

What is causing the error between these two .bindPopup?

The below popup works properly displaying "Neigh_Name" (a name such as "Main") and "2020 Total Population" (a string comprised of numbers '234273' etc).
layer.bindPopup(feature.properties.Neigh_Name+"<br>"+feature.properties["2020 Total Population"])
However, when using the below..
layer.bindPopup(feature.properties["2020 Total Population"])
I get the error: Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
Can someone explain what is happening in the backend and why these two lines of code differ and the latter ultimately fails? I'm trying to learn why certain things occur to avoid future issues.
Thanks!
Very probably the bindPopup method behaves unexpectedly when passing a number as content (your 2nd line), whereas it happily accepts a string argument (as in your 1st line).
Simply make sure to convert your argument into string, e.g. with "" + feature.properties["2020 Total Population"] or
`${feature.properties["2020 Total Population"]}`

What if there exists no matched rule in a Lex program because of REJECT?

I'm currently reading the documentation on Lex written by Lesk and Schmidt, and get confused by the REJECT action.
Consider the two rules
a[bc]+ { ... ; REJECT;}
a[cd]+ { ... ; REJECT;}
Input:
ab
Only the first matches, and see what we get from the material.
The action REJECT means ``go do the next alternative.'' It causes whatever rule was second choice after the current rule to be executed.
However, there is no second choice, will there comes a error?
There are really very few use cases for REJECT; I don't think I've ever seen an instance of it in use other than in examples.
Anyway, unless you specify %option nodefault (or the -s command-line flag), flex will add a default fallback action to your ruleset, equivalent to
.|\n ECHO;
In your case, that pattern will match after the REJECT.
However, it is possible to override the default action; for example, you could add the rule:
.|\n REJECT;
In that case, flex really will not have an alternative after the two REJECTs, and it will print an error message on stderr ("flex scanner jammed") and then call exit.

TRY..CATCH Error_Line()....line

I'm looking at this example provided by MS as I'm trying to learn Try...Catch. I understand the syntax and Output (for the most part) but I have one question:
The Output will show the Error_Line as '4'. This is fine but if I remove the line break between GO and BEGIN TRY it'll show the Error_Line as '3'. I just want to understand the logic here.
What I imagine is happening is that SQL Server is counting the lines by beginning the batch immediately after GO, even if that line is blank but I do not know this for certain. Can anyone clarify? If that theory is correct, wouldn't that make finding errors difficult if scripts are written with line breaks like this?
-- Verify that the stored procedure does not already exist.
IF OBJECT_ID ( 'usp_GetErrorInfo', 'P' ) IS NOT NULL
DROP PROCEDURE usp_GetErrorInfo;
GO
-- Create procedure to retrieve error information.
CREATE PROCEDURE usp_GetErrorInfo
AS
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
GO
--Line 1
BEGIN TRY --Line 2
-- Generate divide-by-zero error. --Line 3
SELECT 1/0; --Line 4
END TRY
BEGIN CATCH
-- Execute error retrieval routine.
EXECUTE usp_GetErrorInfo;
END CATCH;
You can't really rely on ERROR_LINE(), especially when the error is thrown in internal stored procedure or there is dynamic T-SQL statement which is executed.
But do you really need the exact error line?
in real production code, the fix for the line causing the error may not be so obvious as in your example;
it will be better to debug the stored procedure or the function with the corresponding input parameter in order to reproduce the error
In this way it will be easier to fix an issue. In order to debug a SQL routine:
just script it
remove the drop and create stuff
add declare in front of the input parameters and initialized them with the values causing the error
Basically, instead of the exact error line (which can be easily fine having the correct input parameters and executing the routine) you may found useful two things:
which routing is causing the error (for example, you can add additional parameter to user usp_GetErrorInfo SP which is yielding the SP name as well
the input parameters which are causing the error (this can be done using separated table for logging the errors in the CATCH clause - you simple insert the input parameters in the table and information about the error)
Having this information, it will be easy to reproduce and then fix an issue (in many cases).

In k8s reflector, DeltaFiFo.Replace function

In reflector framework, it will first exec 'LIST' request and then watch changes. Get the list result and put them into a queue(such as DeltaFiFo) by calling Replace function, however, when compute key error it will just return and listwatch will end to exec next round ListAndWatch.
(source on Github)
One drop of poison infects the whole tun of wine.
I don't know why deal with it in this way. When one of the items is in wrong state(so it will result in computing key error all the time), ListAndWatch will always fail. I think log the error instead of return is a better way.
Thanks.

Exception when exiting

I'm writing a chef recipe as shown below. I hope the recipe can stop to continue executing the resources after this, but without giving the exception.
Do you have any ideas about this except from doing exit(0)?
ruby_block "verify #{current_container_name}" do
block do
require "docker"
begin
container = Docker::Container.get(current_container_name)
rescue Docker::Error::NotFoundError => exception
container = nil
end
if container.nil?
exit(0)
end
end
end
You could use ignore_failure true in this ruby block instead of handling the exception. That way it would still output the error messages, but wouldn't treat it as a failure so would continue to execute subsequent resources.
If you want to abort a chef-run under a special circumstance - like the current Docker-container is not available - this is not possible. The solution is to rethink your problem - you want some code to be only run when a special condition is met.
You do this by either leaving the recipe (with a return true), encapsulating your configuration steps in a conditional-clause (like a if my_container.nil? then ... end) or you use node-attributes to step through conditions.
Let's say your cookbook x relies on three recipes, 1, 2 and 3. So if you'd like to define that 2 and 3 are only run if 1 was successful, you're able to to write the state of the 1st recipe into the node-attributes (f.e. node.normal['recipe1'] = 'successful').
In the other recipes you'll then define an entry-gate like:
return true if node['recipe1'] != 'succesful'
But be aware, if you're using node-attributes you'll need to use the ruby_block-resource (mostly) at the end of your first recipe because the bare-ruby-code is evaluated and run during the resource-compilation - which takes place before the converge-run.