-
Notifications
You must be signed in to change notification settings - Fork 10
Exception handling in template RPC calls #125
Exception handling in template RPC calls #125
Conversation
Considering asking UW to bake a new PetaLinux distributive: we can ask, but I'm quite sceptical whether it will ever be done... |
Indeed, but if we outline our strict requirements, we might get some support (or we can push to basically be allowed to control our own destiny viz the linux core, and blow a
I am really not in favour of using |
One concern/question I have is why do we need something that seemingly has a lot of added code and overhead, when at a minimum, I think what we need is just something that can:
At this point, the code that executed the call to the remote function simply handles the exception as it normally would. I'd even be in favour of adding some exception classe(s) here (more than the two you have added) since this will be included by both What is the use case for the complicated design pattern? |
I'll also |
4f2bbcf
to
02836fd
Compare
Rebased on top of Will look into build system integration next. |
Also added an example backtrace to the summary above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite good, mostly questions about details of the implementation and about the style.
As told in the first post, the issue lies in About CC7, do you know if an ARM release is provided? If yes, is it fully compatible with the kernel provided by Xilinx. If no, a more recent PetaLinux releases with more mainstream technology (such as overlay filesystems) would help.
I fear defining more exception types would defeat the abstraction implemented in the templated RPC framework. If they were defined here, it would increase the difficulty to create standalone tools and if they were defined in the |
This is probably possible, but the primary issue might be that UW are not really supporting CTP7s, and have moved resources to future boards, so they really only provide some limited support. Again, it can't hurt to ask, and for something like this, I'd be optimistic (unlike say for the inclusion of a version with
I only know that there are other groups working on LHC projects who are putting
To be clear, I'm not saying we should have arbitrary exceptions, rather, specific named exceptions inheriting from these two basic types (even on-the-fly exception creation macros, a la |
@lmoureaux, you've
|
All exceptions thrown by RPC methods are caught, and an error message is sent via the "error" key. In order to help debugging, the type of the exception is also sent back to the client. Build system support is left for later.
The error key is set on the message when an exception is thrown by the RPC method. Throw an exception on the calling side when it is present.
b006432
to
a720e22
Compare
The Wisconsin RPC messaging layer can throw a family of exceptions that need to be enumerated in catch() statements. Replace them with a common type deriving from std::runtime_error.
a720e22
to
27a8049
Compare
Still no build system integration. |
Blocker |
49dbb54
to
98d3e87
Compare
98d3e87
to
f577bf2
Compare
Added build system integration. Symbols are added to
|
xhalcore/Makefile
Outdated
SRCS_XHAL = $(shell echo $(SrcLocation)/*.cpp) | ||
SRCS_XHALPY = $(shell echo $(SrcLocation)/python_wrappers/*.cpp) | ||
SRCS_RPC_MAN = $(shell echo $(SrcLocation)/rpc_manager/*.cpp) | ||
SRCS_XHAL = $(wildcard $(PackageSourceDir)/*.cpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question for @mexanick, what is/was the rationale for separating *_XHAL
and *_UTILS
?
In this Makefile
they all simply feed into the XHAL_LIB
shared object.
Makefile
Outdated
xhalcore: xhalarm | ||
xhalcore: | ||
|
||
xhalcore.RPM: xhalarm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be xhalcore.rpm
, typo was in my stuff.
I also made a few further optimizations to these as well as the templates in config
.
I don't think you need to include them in this PR, but I'll work them in during the release prep (they also impact other packages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can edit your commit if you want stuff to be fixed. Just push fixes to #129 and ping me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config
submodule was updated to cms-gem-daq-project/gembuild#4, and I'll fix the xhal
commit with the merged hash of this, this afternoon (currently it's pushed with the hash of the pending PR if you want to test everything except the final submodule hash)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hotfix/simplify-makefiles
is now updated to the merged hash of the config
submodule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You rebased it on top of a WIP commit that I removed yesterday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Not really (the same commit message appears twice in history):
7eb3190 Clean up Makefiles -- Fixes #128
055b8aa Fix typo in rpc/register.h header guard
f577bf2 Compile rpc/exceptions.cpp into libxhal.so
9d9df61 Clean up Makefiles -- Fixes #128
I sorted it out. I took the freedom to drop the changes that added the rpc
directory, since I prefer having them in a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK, thanks.
I missed that my rebase, rebased onto yours which had already included the commit
* `config` submodule updated to pick up `XHAL_ROOT` and default `INSTALL_PATH` * `xhalarm` and `xhalcore` `Makefile`s are simplified for reliable, reproducible builds * `xhalarm` as dependency of `xhalcore` is moved to dependency of `xhalcore.RPM`
055b8aa
to
a200759
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK from me, just the final decision on #123 (review), which can be made in a separate cleanup PR
Description
Handle exceptions thrown by RPC methods and the Wisconsin RPC library. Turn them into two exceptions types at the calling site. For exceptions thrown on the remote side, a stack trace can be recorded and sent back (optional).
This PR adds a
.cpp
file that should be compiled into its a library. It is required on all architectures. The build system has not been modified to include it.Example exception info
I triggered an exception by doing
.at(-1)
on astd::vector
. The message is:[feature was dropped]
The backtrace as retrieved from the thrown exception is (relevant frames are 5-7):
Line numbers and even code snippets could be obtained by linking against
libdwarf
How it works
Exceptions are caught on the server side (CTP7, in
invoke
) and an error message is generated there. The exact type of the exception is determined using a low-level C++ API (defined by the Itanium ABI). This information is sent back to the caller using theerror
andtype
keys. Thecall
function checks for the keys and throws an exception with the relevant information.In addition, code in the
call
function is now protected against exceptions. Any error coming from the Wisconsin RPC library results in an exception being thrown (a single type is used).[feature was dropped]
The optional stack trace functionality works by inserting a hook in the low-level API used by
throw
statements. More specifically, it overrides__cxa_throw
(also from the Itanium ABI) to record a stack trace every time an exception is thrown. When an exception is caught ininvoke
, the stack trace is queried and sent back to the caller.Since recording a stack trace for every exception adds some overhead, it is made optional using a preprocessor macro. If
NDEBUG
is set whenregister.h
is included, no trace will be recorded. (I'm not sure whether this applies at the level of a module, a compilation unit or even the part of it after the#include
. This would need to be tested.)CTP7 warning
[feature was dropped, irrelevant]
The version of
libstdcxx
on the CTP7 has a bug that prevents getting a stack trace. It also foolsgdb
. The best option seems to ask Wisconsin for an image based on a more recent Petalinux. We could also provide an updated version oflibstdcxx
toLD_PRELOAD
when startingwiscrpcsvc
, or a tiny library that would only patch the buggy function.The code was tested primarily on x86, with some testing on a more recent ARM Linux.
Types of changes
Motivation and Context
We want to catch exceptions thrown by RPC modules, and provide devs with as much debugging information as possible.
How Has This Been Tested?
All prototyping was done on x86. Testing on ARM (CTP7 and another chip) was performed to check for architecture-dependent issues. This polished version was tested on x86.
The following client was used with an RPC-ified
memory
:Compilation was tested on
gem904daq01
with the Xilinx SDK 2016.2.Checklist: