Bug 197260 - [dtrace] assertion failure when printing aggregation
Summary: [dtrace] assertion failure when printing aggregation
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-02 04:55 UTC by Mark Johnston
Modified: 2015-04-12 21:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston freebsd_committer freebsd_triage 2015-02-02 04:55:31 UTC
While playing around with stddev() I discovered that it's possible to crash libdtrace by printing a stddev aggregation immediately after clearing it:

$ cat test.d
dtrace:::BEGIN
{
        @a = stddev(0);
        clear(@a);
        printa("%@d", @a);
}
$ sudo dtrace -s test.d
dtrace: script 'test.d' matched 1 probe
CPU     ID                    FUNCTION:NAME
Assertion failed: (divisor != 0), file /home/mark/src/freebsd/cddl/lib/libdtrace/../../../cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c, line 240.
  4      1                           :BEGIN

This doesn't happen with other aggregation functions (avg, max, min).
Comment 1 commit-hook freebsd_committer freebsd_triage 2015-02-02 20:49:30 UTC
A commit references this bug:

Author: markj
Date: Mon Feb  2 20:48:32 UTC 2015
New revision: 278114
URL: https://svnweb.freebsd.org/changeset/base/278114

Log:
  Let the standard deviation of the empty set be 0. This is consistent with
  the behaviour for averages, and fixes a crash that can occur when attempting
  to print a stddev aggregation containing no elements:

      dtrace:::BEGIN { @ = stddev(0); clear(@); printa("%@d", @); }

  PR:		197260
  MFC after:	2 week

Changes:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-04-12 21:36:01 UTC
A commit references this bug:

Author: markj
Date: Sun Apr 12 21:35:14 UTC 2015
New revision: 281472
URL: https://svnweb.freebsd.org/changeset/base/281472

Log:
  MFC r278114:
  libdtrace: Let the standard deviation of the empty set be 0.

  PR:	197260

Changes:
_U  stable/10/
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c