Skip to content

Commit

Permalink
alloca: new faults
Browse files Browse the repository at this point in the history
We'll use DTRACEFLT_BADSIZE to distinguish in error messages between
out-of-bounds errors in bcopy and the like, and size-too-large errors.
(Without this, it's hard to tell if a, say, 0x12 in the fault value
is a nearly-NULL pointer or a wrong size.)

We'll use DTRACEFLT_INTERR to indicate can-never-happen errors where we
have tested the actual condition already (and emitted a proper error)
followed by a check to placate the verifier (which will always succeed
if the actual condition check failed).  The latter failure happening at
runtime always indicates a bug in DTrace, not in the user's code, so
indicate as much.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
  • Loading branch information
nickalcock committed Mar 1, 2022
1 parent 9033301 commit a651809
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/dtrace/faults_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define DTRACEFLT_UPRIV 7 /* Illegal user access */
#define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */
#define DTRACEFLT_BADSTACK 9 /* Bad stack */
#define DTRACEFLT_BADSIZE 10 /* Bad size */
#define DTRACEFLT_INTERR 11 /* Internal error */

#define DTRACEFLT_LIBRARY 1000 /* Library-level fault */

Expand Down
2 changes: 2 additions & 0 deletions libdtrace/dt_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ dtrace_faultstr(dtrace_hdl_t *dtp, int fault)
{ DTRACEFLT_UPRIV, "invalid user access" },
{ DTRACEFLT_TUPOFLOW, "tuple stack overflow" },
{ DTRACEFLT_BADSTACK, "bad stack" },
{ DTRACEFLT_BADSIZE, "invalid size" },
{ DTRACEFLT_INTERR, "internal error" },
{ DTRACEFLT_LIBRARY, "library-level fault" },
{ 0, NULL }
};
Expand Down
1 change: 1 addition & 0 deletions libdtrace/dt_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
case DTRACEFLT_BADADDR:
case DTRACEFLT_BADALIGN:
case DTRACEFLT_BADSTACK:
case DTRACEFLT_BADSIZE:
sprintf(details, " (0x%llx)", (u_longlong_t)err.dteda_addr);
break;

Expand Down

0 comments on commit a651809

Please sign in to comment.