Skip to content

Commit

Permalink
Change dt_cg_agg_lquantize() arg check to agree with message
Browse files Browse the repository at this point in the history
We check limitval<baseval, but the error message is "base must
be less than limit".  Make the check more stringent to agree
with the error message.

Note that this behavior dates back to DTrace v1:
     # dtrace -n 'BEGIN {@ = lquantize(8, 4, 4); exit(0) }'
     dtrace: invalid probe specifier:
     lquantize( ) step (argument #3) too large:
     must have at least one quantization level
That is, the arguments pass the check but are then caught by a
later, rather confusing, message.

Add a test to catch this case.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Dec 10, 2020
1 parent ca54e2b commit 5db20ff
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,7 @@ dt_cg_agg_lquantize(dt_pcb_t *pcb, dt_ident_t *aid, dt_node_t *dnp,
dnerror(arg2, D_LQUANT_LIMVAL, "lquantize( ) argument #2 must "
"be a 32-bit quantity\n");

if (limitval < baseval)
if (limitval <= baseval)
dnerror(dnp, D_LQUANT_MISMATCH,
"lquantize( ) base (argument #1) must be less than "
"limit (argument #2)\n");
Expand Down
33 changes: 33 additions & 0 deletions test/unittest/aggs/err.D_LQUANT_MISMATCH.lqbadarg2.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/

/*
* ASSERTION:
* Upper bound must be greater than lower bound argument
*
* SECTION: Aggregations/Aggregations
*/

#pragma D option quiet

BEGIN
{
i = 0;
}

tick-1
/i < 1000/
{
@ = lquantize(i, 1100, 1100, -100 );
i += 100;
}

tick-1
/i == 1000/
{
exit(0);
}

0 comments on commit 5db20ff

Please sign in to comment.