apr: Failed Creating Threads

May 5th, 2020

There is a potential segmentation fault when executing ‘make test’ while building apr-1.7.0. The following lines are output:

...
testatomic          : -Line 413: Failed creating threads
-/bin/sh: line 2: XXXXX Segmentation fault      ./$prog -v
...
Programs failed: testall
make[1]: *** [check] Error 139
make[1]: Leaving directory `.../apr-1.7.0/test'
make: *** [check] Error 2

The segmentation fault is caused by a call to apr_thread_join() on an invalid apr_thread_t instance in test_atomics_threaded(). The problematic functions, test_atomics_threaded() and test_atomics_threaded64(), continue processing even when apr_thread_create() returns an error value.

The segmentation fault is avoided and the remaining tests are executed if either of the following is performed on …/apr-1.7.0/test/testatomic.c:

1. Comment out the following lines:

abts_run_test(suite, test_atomics_threaded, NULL);
abts_run_test(suite, test_atomics_threaded64, NULL);

2. Update NUM_THREADS with a smaller number, for example:

#define NUM_THREADS 25

A lack of memory resources is the underlying cause of this segmentation fault. Reducing the number of threads created for these tests allows testing the atomic operations as intended.

fciv.py – Python Module for Microsoft FCIV

April 5th, 2020

fciv.py is a Python module that I implemented to generate file integrity data in a format used by Microsoft File Checksum Integrity Verifier. My use case involves copying files from a Linux workstation to a Microsoft Windows workstation. I wanted to generate integrity data on Linux using Python 3 and verify file integrity on Microsoft Windows without installing 3rd party software.

FCIV file content is generated with the following Python snippet:

import fciv
digests = fciv.fciv_compute('mydirectory/**')
fciv.fciv_write(digests)

With the output of the generation script redirected to a file named ‘fciv.xml’, the following snippet performs verification:

import fciv
reference_digests = fciv.fciv_read('fciv.xml')
actual_digests = fciv.fciv_compute('mydirectory/**')
fciv.fciv_verify(actual_digests, reference_digests)

The verification performed by fciv.py reports mismatches between expected and actual file checksums. Files missing from and files in addition to that of the verification data are also reported.

Let the (Casino) Chips Fall Where They May

March 25th, 2020

MGM Drops

It has been more than 10 years since the Great Recession.

TypeScript: readonly vs. const

March 10th, 2020
Posted in TypeScript | No Comments

From The TypeScript Handbook:

The easiest way to remember whether to use readonly or const is to ask whether your using it on a variable or a property. Variables use const whereas properties use readonly.

Backup Procedure Using WSL

February 1st, 2020

Using Microsoft Windows Subsystem for Linux (WSL) to gain access to Linux command line tools within Microsoft Windows 10, I was able to create a consistent backup procedure that can be performed in Windows and Linux environments. I used SyncToy and File Checksum Integrity Verifier (FCIV) to perform backups before adopting this standard approach.

Except where noted, the following procedure can be performed in both Windows and Linux environments.

  1. Navigate to Desired Folder’s Parent.
    $ cd /mnt/c/myfolderparent
  2. Generate SHA1 Digest File.
    $ find ./myfolder -type f -exec sha1sum -b "{}" + > ~/myfolder.sha1
  3. Verify SHA1 Digest File (optional).
    $ sha1sum -c ~/myfolder.sha1

    or

    $ sha1sum -c --quiet ~/myfolder.sha1

    Note: myfolder.sha1 contains relative paths. The above command requires execution from a directory where relative paths lead to the files desired for integrity checks.

  4. Mount Destination (optional)
    1. Create Mount Point
      $ mkdir /mnt/usbdrive
    2. Review Mount Options of Mounted Fixed Drives
      $ mount

    3. Mount Drive
      $ sudo mount -t drvfs f: /mnt/usbdrive \
      -o noatime,uid=1000,gid=1000

      This command is specific to Microsoft Windows; a similar command is available in the Linux environment. “f:” is the drive letter that Microsoft Windows assigned to the inserted USB drive in this example. Options are specified to match those highlighted above for the already mounted fixed drives.

  5. Perform Copy
    1. Dry Run
      $ rsync -n -av --delete --force --progress \
      --human-readable ./myfolder/ /mnt/usbdrive/myfolder
    2. Live Run
      $ rsync -av --delete --force --progress \
      --human-readable ./myfolder/ /mnt/usbdrive/myfolder

      The trailing ‘/’ of the source folder is important to the command’s correctness.

  6. Move Checksum File
    $ cp ~/myfolder.sha1 /mnt/usbdrive/.
  7. Verify File Integrity
    $ cd /mnt/usbdrive
    $ sha1sum -c myfolder.sha1