adokter / vol2birdR

R package for the vol2bird algorithm: generate vertical profiles of biological signals in weather radar data
https://adokter.github.io/vol2birdR
GNU Lesser General Public License v3.0
6 stars 3 forks source link

segfault for mistnet run with missing spectrum width data: #29

Open adokter opened 1 year ago

adokter commented 1 year ago

Problematic file: 3_20110209_062319.pvol.h5.zip

load unzipped data:

pvol=read_pvolfile("3_20110209_062319.pvol.h5")

This polar volume contains reflectivity and radial velocity data, but no spectrum width. vol2bird should initialize spectrum width fields with zero's and continue with a mistnet run after throwing a warning:

pvol$scans[[1]]
                  Polar scan (class scan)

     parameters:  DBZH VRADH 
elevation angle:  0.5 deg
           dims:  598 bins x 360 rays

calculate profile without mistnet:

calculate_vp(pvol)
Running vol2birdSetUp
Warning: no dual-pol moments found, switching to SINGLE POL mode
Warning: using experimental SINGLE polarization mode on S-band data, results may be unreliable!
               Vertical profile (class vp)

       radar:  AU03 
      source:  RAD:AU03,PLC:Wollgng,CTY:500,STN:68219 
nominal time:  2011-02-09 06:23:00 
generated by:  vol2bird 0.5.0.9195

Calculate profile with mistnet leads to segfault:

calculate_vp(pvol, mistnet=T)
Running vol2birdSetUp
Warning: no dual-pol moments found, switching to SINGLE POL mode
Warning: using experimental SINGLE polarization mode on S-band data, results may be unreliable!
Warning: using MistNet, disabling other segmentation methods
Running segmentScansUsingMistnet.
Warning: Requested elevation scan at 1.500000 degrees but selected scan at 1.300000 degrees
Warning: Requested elevation scan at 3.500000 degrees but selected scan at 3.100000 degrees
Warning: Requested elevation scan at 4.500000 degrees but selected scan at 4.200000 degrees
Warning: Ignoring scan(s) not used as MistNet input: 2 4 8 9 10 11 12 13 14 ...
Warning: no spectrum width data found for MistNet input scan 0, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 1, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 2, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 3, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 4, initializing with values 0 instead.

 *** caught segfault ***
address 0x12bea3d63ed0, cause 'memory not mapped'

Traceback:
 1: .External(list(name = "CppMethod__invoke_void", address = <pointer: 0x600000d61500>,     dll = list(name = "Rcpp", path = "/Library/Frameworks/R.framework/Versions/4.2/Resources/library/Rcpp/libs/Rcpp.so",         dynamicLookup = TRUE, handle = <pointer: 0x7ff903acedb0>,         info = <pointer: 0x600002959140>), numParameters = -1L),     <pointer: 0x600003109c00>, <pointer: 0x600000d0dbc0>, .pointer,     ...)
 2: processor$process(path.expand(file), config_instance, path.expand(vpfile),     path.expand(pvolfile_out))
 3: vol2birdR::vol2bird(file = file, config = config, vpfile = profile.tmp,     pvolfile_out = pvolfile_out, verbose = verbose)
 4: calculate_vp(tmp_pvol_file, vpfile = vpfile, pvolfile_out = pvolfile_out,     autoconf = autoconf, verbose = verbose, warnings = warnings,     mount = mount, sd_vvp_threshold = sd_vvp_threshold, rcs = rcs,     dual_pol = dual_pol, rho_hv = rho_hv, single_pol = single_pol,     elev_min = elev_min, elev_max = 90, azim_min = 0, azim_max = 360,     range_min = range_min, range_max = range_max, n_layer = n_layer,     h_layer = h_layer, dealias = dealias, nyquist_min = nyquist_min,     dbz_quantity = dbz_quantity, mistnet = mistnet, mistnet_elevations = mistnet_elevations,     local_install = local_install, local_mistnet = local_mistnet)
 5: withCallingHandlers(res <- calculate_vp(tmp_pvol_file, vpfile = vpfile,     pvolfile_out = pvolfile_out, autoconf = autoconf, verbose = verbose,     warnings = warnings, mount = mount, sd_vvp_threshold = sd_vvp_threshold,     rcs = rcs, dual_pol = dual_pol, rho_hv = rho_hv, single_pol = single_pol,     elev_min = elev_min, elev_max = 90, azim_min = 0, azim_max = 360,     range_min = range_min, range_max = range_max, n_layer = n_layer,     h_layer = h_layer, dealias = dealias, nyquist_min = nyquist_min,     dbz_quantity = dbz_quantity, mistnet = mistnet, mistnet_elevations = mistnet_elevations,     local_install = local_install, local_mistnet = local_mistnet),     error = function(e) {        file.remove(tmp_pvol_file)        e    })
 6: calculate_vp(pvol, mistnet = T)
adokter commented 1 year ago

Running valgrind on vol2bird code generated with vol2birdinstall also shows the issue, so not vol2birdR specific

valgrind /opt/vol2bird/vol2bird/bin/vol2bird 3_20110209_062319.pvol.h5 
==420211== Memcheck, a memory error detector
==420211== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==420211== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==420211== Command: /opt/vol2bird/vol2bird/bin/vol2bird 3_20110209_062319.pvol.h5
==420211== 
==420211== Warning: set address range perms: large range [0x556e000, 0x1afc0000) (defined)
Loaded user configuration file 'options.conf' ...
Warning: no dual-pol moments found, switching to SINGLE POL mode
Warning: using experimental SINGLE polarization mode on S-band data, results may be unreliable!
Warning: using MistNet, disabling other segmentation methods
Warning: Requested elevation scan at 1.500000 degrees but selected scan at 1.300000 degrees
Warning: Requested elevation scan at 3.500000 degrees but selected scan at 3.100000 degrees
Warning: Requested elevation scan at 4.500000 degrees but selected scan at 4.200000 degrees
Warning: Ignoring scan(s) not used as MistNet input: 2 4 8 9 10 11 12 13 14 ...
Warning: no spectrum width data found for MistNet input scan 0, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 1, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 2, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 3, initializing with values 0 instead.
Warning: no spectrum width data found for MistNet input scan 4, initializing with values 0 instead.
==420211== Invalid read of size 8
==420211==    at 0x4873E40: flatten3DTensor (librender.c:636)
==420211==    by 0x4874E52: segmentScansUsingMistnet (librender.c:1011)
==420211==    by 0x486B356: vol2birdSetUp (libvol2bird.c:5004)
==420211==    by 0x10A98E: main (vol2bird.c:342)
==420211==  Address 0x1e6b9c90 is 0 bytes after a block of size 80 alloc'd
==420211==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==420211==    by 0x487364D: init3DTensor (librender.c:470)
==420211==    by 0x4873F75: polarVolumeTo3DTensor (librender.c:670)
==420211==    by 0x4874E31: segmentScansUsingMistnet (librender.c:1008)
==420211==    by 0x486B356: vol2birdSetUp (libvol2bird.c:5004)
==420211==    by 0x10A98E: main (vol2bird.c:342)
==420211== 
==420211== Invalid read of size 8
==420211==    at 0x4873E43: flatten3DTensor (librender.c:636)
==420211==    by 0x4874E52: segmentScansUsingMistnet (librender.c:1011)
==420211==    by 0x486B356: vol2birdSetUp (libvol2bird.c:5004)
==420211==    by 0x10A98E: main (vol2bird.c:342)
==420211==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==420211== 
==420211== 
==420211== Process terminating with default action of signal 11 (SIGSEGV)
==420211==  Access not within mapped region at address 0x0
==420211==    at 0x4873E43: flatten3DTensor (librender.c:636)
==420211==    by 0x4874E52: segmentScansUsingMistnet (librender.c:1011)
==420211==    by 0x486B356: vol2birdSetUp (libvol2bird.c:5004)
==420211==    by 0x10A98E: main (vol2bird.c:342)
==420211==  If you believe this happened as a result of a stack
==420211==  overflow in your program's main thread (unlikely but
==420211==  possible), you can try to increase the size of the
==420211==  main thread stack using the --main-stacksize= flag.
==420211==  The main thread stack size used in this run was 8388608.
==420211== 
==420211== HEAP SUMMARY:
==420211==     in use at exit: 133,014,543 bytes in 221,111 blocks
==420211==   total heap usage: 501,659 allocs, 280,548 frees, 200,529,418 bytes allocated
==420211== 
==420211== LEAK SUMMARY:
==420211==    definitely lost: 0 bytes in 0 blocks
==420211==    indirectly lost: 0 bytes in 0 blocks
==420211==      possibly lost: 0 bytes in 0 blocks
==420211==    still reachable: 133,014,543 bytes in 221,111 blocks
==420211==                       of which reachable via heuristic:
==420211==                         stdstring          : 4,459,126 bytes in 94,572 blocks
==420211==         suppressed: 0 bytes in 0 blocks
==420211== Rerun with --leak-check=full to see details of leaked memory
==420211== 
==420211== For lists of detected and suppressed errors, rerun with: -s
==420211== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)