After reading a blog post from thinkingpinoy.net about the unexplained hashcode mismatched of data files uploaded to COMELEC’s Transparency Server, I kept on thinking the other possible reasons to explain it. I wanted to give a shot at figuring out the rootcause of the issue or at least simulate it. I spent nine (9) years working on bug fixing before moving to full software development. I have acquired the skills to identify, simulate, and fix Software bugs.
Please be advised that what follow are all speculations and based on that blog. Moreover, I am neither pro-BBM or Leni Robredo. What matters to me is Mayor Duterte has won the presidency.
At work, investigation like this requires a lot of patience, imagination, and verified input parameters. “Verified input parameters” means the data to test and to depend on is valid and correct. In this case, our valid input parameter is the issue shown on the screenshot from the other blog post.
My bugfix team at CML used to say, “Bugfixing is better than sex.”
Okay, I’ll cut to the chase. If the screenshot shown above is correct, I believe the mismatched hashcodes may just be due to some software glitch or Race Condition among processes somewhere in the system. I’d say somewhere before the file was uploaded to the Transparency Server.
Perhaps data was still being written to the file
results_nle2016_05092016_2000.txt when another process created a hashcode (file) before generating a .zip file that includes all the other files.
After all the data has been written to
results_nle2016_05092016_2000.txt, the hashcode for this same file will be different.
Simulating the mismatched Hashcodes
On this simulation, I used two (2) PHP scripts to run concurrently. The way to achieve that is to let one script process a very large file so that it’ll take considerably more time to complete the processing and immediately execute another script. Also, I used Ubuntu 14.04 LTS.
The codes are pretty basic.
$srcfile = fopen("test-data-from-any-source.dat", 'r');
$destfile = fopen("results_nle2016_05092016_2000.txt", "w");
while(($line = fgets($srcfile)) != false)
$hashCode = md5_file('results_nle2016_05092016_2000.txt');
$destfile = fopen("results_nle2016_05092016_2000.hash", "w");