usnistgov / SP800-90B_EntropyAssessment

The SP800-90B_EntropyAssessment C++package implements the min-entropy assessment methods included in Special Publication 800-90B.
195 stars 88 forks source link

ea_iid, ea_non_iid crashing when -l used. #191

Closed dj-on-github closed 2 years ago

dj-on-github commented 2 years ago

I took a fresh pull and compiled according to the instructions on Ubuntu 20.04.1 LTS.

The file is a 1 bit per byte file in the nist oddball format. The data is IID (generated with a biased 0.6 model).

$ ea_iid -i -t -l 0,1000000 -o non_iid_result.json biased0p6.nob 1 Segmentation fault (core dumped)

$ ea_non_iid -i -t -l 0,1000000 -o non_iid_result.json biased0p6.nob 1 Segmentation fault (core dumped)

The crash is instant, not somewhere in the middle of processing. Removing the -l 0,1000000 option (to use the first 1,000,000 bits since the file is 1MiByte, fixes the problem, but breaks our manufacturing test flow so we are forced to use an older version.

$ ea_non_iid -i -t -o non_iid_result.json biased0p6.nob 1

Running non-IID tests...

Running Most Common Value Estimate...

Running Entropic Statistic Estimates (bit strings only)...

Running Tuple Estimates...

Running Predictor Estimates...

H_original: 0.528182

joshuaehill commented 2 years ago

I suspect that you're running into some interaction between the new JSON code and the subset processing. I'll look into it.

joshuaehill commented 2 years ago

When the JSON output argument was added, the patch stripped the getopt flag that indicates that "-l" takes an argument. I'll set up a pull request to fix the issue.

dj-on-github commented 2 years ago

Yes. I just dug into the code and the colon was missing from the getopt format. Putting it in fixes it. //while ((opt = getopt(argc, argv, "icatvlqo:")) != -1) { while ((opt = getopt(argc, argv, "icatvl:qo:")) != -1) {

joshuaehill commented 2 years ago

The PR fix is essentially that for both files.

dj-on-github commented 2 years ago

Yes. The bug is in iid_main.cpp and non_iid_main.cpp.