-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terminate with signal in case of an assert #134
Terminate with signal in case of an assert #134
Conversation
I had this problem with Jerry before. I suspect the reason of not using abort() is avoiding compiling issues on dev boards. Perhaps we could add an abort() to jerry libc, and call the normal abort on Linux. |
Going for From the proposed patch's point of view, the abort-approach would need the change of 2 lines only: replacing We could also have a 2-step approach:
|
@akiss77, @zherczeg, there is also a third option that seems to be more convenient for automatic testing systems, and maybe, for manual debugging too. As far as I understand, by SIGILL we are causing core dump to extract backtrace later. While the way with SIGILL is working and seems to be simple, there are some disadvantages, as using SIGILL:
There is another way to perform core dump. Under Linux we could use gdb's When using this way, we:
Furthermore, this way we can get backtrace without allocating much storage space for core dumps during automatic testing. |
I feel we would just overcomplicate things. We need to capture abnormal program termination in testing environments, regardless how we fix this. So there is no simplification here. When we are debugging, gdb has been started, and creating another one would be overkill. And abort() throws SIGABRT, not SIGILL. That is for invalid instructions. |
@zherczeg, using |
This is just a secondary use case, while the main proposed use case was to self-attach gdb upon failure during automatic testing for dumping backtrace, core, or whatever we would add to the dumping script. |
@ruben-ayrapetyan, tying gdb so tightly to jerry does not feel right to me. That would add a very strong dependency to the project. Also, usually, an automatic testing framework does start whatever debugger it wants from outside. Starting it up from inside of the tested app is normally unexpected. Furthermore, the question/point (for me, at least) is not really which signal to raise just to raise one and not exit in a "normal" way. (As seen in all projects using assertions I had a chance to stumble upon.) SIGILL comes into play only because From the docs of gcc: "This function causes the program to exit abnormally. GCC implements this function by using a target-dependent mechanism (such as intentionally executing an illegal instruction) or by calling abort." So, eventually, it may be the same as calling In my view, the advantage of |
Hope this fix has little or no problem with embed RTOS. |
@seanshpark, I'm not too familiar with embedded RTOSes so I have to rely on existing examples: iotjs also uses |
@akiss77 , thank you for your kind explanation. :) |
Updated patch to use |
@@ -50,7 +50,7 @@ typedef enum | |||
ERR_SYSCALL = 11, | |||
ERR_PARSER = 12, | |||
ERR_UNIMPLEMENTED_CASE = 118, | |||
ERR_FAILED_INTERNAL_ASSERTION = 120 | |||
ERR_FAILED_INTERNAL_ASSERTION = 134 |
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.
In case of abort
usage we don't need this change anymore.
Blocked by #141. |
|
Using We could add a debug option like
with the following:
In the case, we would expect exit code, corresponding to SIGABRT, if the option is passed in debug version (maybe, in release too?), and expect our internal exit codes otherwise. We can leave |
Updated the patch according to the latest comments from @egavrin and @ruben-ayrapetyan . The introduction of an |
@akiss77 Great! |
Got |
Automated debugging is easier if the process terminates with a signal instead of a regular `exit (code);` call, since in this latter case the cause of error cannot be automatically backtraced. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
Automated debugging is easier if the process terminates with a
signal instead of a regular
exit (code);
call, since in thislatter case the cause of error cannot be automatically backtraced.
Care has been taken to ensure that the exit code after the signal
is the same as what we would get with
exit
.JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]