Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • SWIFTsim SWIFTsim
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 57
    • Issues 57
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 17
    • Merge requests 17
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • SWIFT
  • SWIFTsimSWIFTsim
  • Issues
  • #582
Closed
Open
Issue created May 15, 2019 by Bert Vandenbroucke@bvandenbrouckeMaintainer

AddressSanitizer: stack-buffer-overflow in space_init_parts_mapper

When running the latest master, configured with

./configure --with-hydro=gadget2 \
  --with-hydro-dimension=3 --with-ext-potential=none \
  --with-equation-of-state=ideal-gas \
  --with-adiabatic-index=5/3 \
  --enable-mpi=no --enable-debug=no --enable-debugging-checks=no \
  --enable-optimization=no --enable-sanitizer=yes

I get the following error when trying to run ZeldovichPancake_3D (also happened for SedovBlast_3D, haven't tried any other tests):

 Welcome to the cosmological hydrodynamical code
    ______       _________________
   / ___/ |     / /  _/ ___/_  __/
   \__ \| | /| / // // /_   / /   
  ___/ /| |/ |/ // // __/  / /    
 /____/ |__/|__/___/_/    /_/     
 SPH With Inter-dependent Fine-grained Tasking

 Version : 0.8.1
 Revision: v0.8.1-828-ge990caac, Branch: master, Date: 2019-05-14 10:47:51 +0100
 Webpage : www.swiftsim.com

 Config. options: '--with-hydro=gadget2 --with-riemann-solver=exact --with-hydro-dimension=3 --with-ext-potential=none --with-equation-of-state=ideal-gas --with-adiabatic-index=5/3 --enable-mpi=no --enable-debug=no --enable-debugging-checks=no --enable-optimization=no --enable-sanitizer=yes'

 Compiler: GCC, Version: 7.4.0
 CFLAGS  : '-fsanitize=address -fno-omit-frame-pointer -pthread -Wall -Wextra -Wno-unused-parameter -Wshadow -Werror -Wstrict-prototypes'

 HDF5 library version: 1.10.0
 FFTW library version: 3.x (details not available)
 GSL  library version: 2.4

[00000.0] main: CPU frequency used for tick conversion: 2300082494 Hz
[00000.0] main: Running on: apsient
[00000.0] main: sizeof(part)        is  128 bytes.
[00000.0] main: sizeof(xpart)       is   64 bytes.
[00000.0] main: sizeof(spart)       is  128 bytes.
[00000.0] main: sizeof(bpart)       is   96 bytes.
[00000.0] main: sizeof(gpart)       is   64 bytes.
[00000.0] main: sizeof(multipole)   is  176 bytes.
[00000.0] main: sizeof(grav_tensor) is  144 bytes.
[00000.0] main: sizeof(task)        is   64 bytes.
[00000.0] main: sizeof(cell)        is 1152 bytes.
[00000.0] main: Reading runtime parameters from file 'zeldovichPancake.yml'
[00000.0] main: Internal unit system: U_M = 1.988480e+43 g.
[00000.0] main: Internal unit system: U_L = 3.085678e+24 cm.
[00000.0] main: Internal unit system: U_t = 3.085678e+19 s.
[00000.0] main: Internal unit system: U_I = 1.000000e+00 A.
[00000.0] main: Internal unit system: U_T = 1.000000e+00 K.
[00000.0] phys_const_print:    Gravitational constant = 4.300927e+01
[00000.0] phys_const_print:            Speed of light = 2.997925e+05
[00000.0] phys_const_print:           Planck constant = 1.079902e-99
[00000.0] phys_const_print:        Boltzmann constant = 6.943236e-70
[00000.0] phys_const_print:     Thomson cross-section = 6.986845e-74
[00000.0] phys_const_print:             Electron-Volt = 8.057293e-66
[00000.0] phys_const_print:                      Year = 1.022690e-12
[00000.0] phys_const_print:         Astronomical Unit = 4.848137e-12
[00000.0] phys_const_print:                    Parsec = 1.000000e-06
[00000.0] phys_const_print:                Solar mass = 1.000000e-10
[00000.0] phys_const_print:                  km/s/Mpc = 1.000000e+02
[00000.7] cosmology_print: Density parameters: [O_m, O_l, O_b, O_k, O_r] = [1.000000, 0.000000, 1.000000, 0.000000, 0.000000]
[00000.7] cosmology_print: Dark energy equation of state: w_0=-1.000000 w_a=0.000000
[00000.7] cosmology_print: Hubble constant: h = 1.000000, H_0 = 1.000000e+02 U_t^(-1)
[00000.7] cosmology_print: Hubble time: 1/H0 = 1.000000e-02 U_t
[00000.7] cosmology_print: Universe age at present day: 6.666667e-03 U_t
[00000.7] cooling_print_backend: Cooling function is 'No cooling'.
[00000.7] chemistry_print_backend: Chemistry function is 'No chemistry'.
[00000.7] main: Reading ICs from file './zeldovichPancake.hdf5'
[00000.7] io_read_unit_system: Reading IC units from ICs.
[00000.7] read_ic_single: IC and internal units match. No conversion needed.
[00000.7] main: Reading initial conditions took 22.369 ms.
[00000.7] main: Read 32768 gas particles, 0 stars particles, 0 black hole particles and 32768 gparts from the ICs.
[00000.7] main: space_init took 5.991 ms.
[00000.7] potential_print_backend: External potential is 'No external potential'.
[00000.7] main: space dimensions are [ 64.000 64.000 64.000 ].
[00000.7] main: space is periodic.
[00000.7] main: highest-level cell dimensions are [ 8 8 8 ].
[00000.7] main: 32768 parts in 512 cells.
[00000.7] main: 32768 gparts in 512 cells.
[00000.7] main: 0 sparts in 512 cells.
[00000.7] main: 0 bparts in 512 cells.
[00000.7] main: maximum depth is 0.
[00000.7] engine_config: no processor affinity used
[00000.7] engine_policy: engine policies are [  'steal'  'keep'  'numa affinity'  'hydro'  'self gravity'  'cosmological integration'  ]
[00000.7] eos_print: Equation of state: Ideal gas.
[00000.7] eos_print: Adiabatic index gamma: 1.666667.
[00000.7] hydro_props_print: Hydrodynamic scheme: Gadget-2 version of SPH (Springel 2005) in 3D.
[00000.7] hydro_props_print: Hydrodynamic kernel: Cubic spline (M4) with eta=1.234800 (48.00 neighbours).
[00000.7] hydro_props_print: Hydrodynamic relative tolerance in h: 0.00010 (+/- 0.0144 neighbours).
[00000.7] hydro_props_print: Hydrodynamic integration: CFL parameter: 0.1000.
[00000.7] hydro_props_print: Artificial viscosity parameters set to alpha: 0.800, max: 2.000, min: 0.100, length: 0.100.
[00000.7] hydro_props_print: Hydrodynamic integration: Max change of volume: 1.40 (max|dlog(h)/dt|=0.112157).
[00000.7] entropy_floor_print: Entropy floor is 'no entropy floor'.
[00000.7] gravity_props_print: Self-gravity scheme: Default (no potential)
[00000.7] gravity_props_print: Self-gravity scheme: FMM-MM with m-poles of order 4
[00000.7] gravity_props_print: Self-gravity time integration: eta=0.0250
[00000.7] gravity_props_print: Self-gravity opening angle:  theta=0.3000
[00000.7] gravity_props_print: Self-gravity softening functional form: Wendland-C2
[00000.7] gravity_props_print: Self-gravity comoving softening:    epsilon=0.0030 (Plummer equivalent: 0.0010)
[00000.7] gravity_props_print: Self-gravity maximal physical softening:    epsilon=0.0030 (Plummer equivalent: 0.0010)
[00000.7] gravity_props_print: Self-gravity mesh side-length: N=32
[00000.7] gravity_props_print: Self-gravity mesh smoothing-scale: a_smooth=1.250000
[00000.7] gravity_props_print: Self-gravity tree cut-off ratio: r_cut_max=5.000000
[00000.7] gravity_props_print: Self-gravity truncation cut-off ratio: r_cut_min=0.100000
[00000.7] gravity_props_print: Self-gravity mesh truncation function: Gadget-like (using erfc())
[00000.7] gravity_props_print: Self-gravity tree update frequency: f=0.010000
[00000.7] engine_config: Absolute minimal timestep size: 3.202383e-17
[00000.7] engine_config: Minimal timestep size (on time-line): 5.081252e-08
[00000.7] engine_config: Maximal timestep size (on time-line): 3.330049e-03
[00000.7] engine_config: Restarts will be dumped every 6.000000 hours
[00000.7] main: engine_init took 7.758 ms.
[00000.7] main: Running on 32768 gas particles, 0 stars particles 0 black hole particles and 0 DM particles (32768 gravity particles)
[00000.7] main: from t=6.568e-06 until t=6.667e-03 with 1 ranks, 8 threads / rank and 8 task queues / rank (dt_min=1.000e-07, dt_max=4.000e-03)...
=================================================================
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==AddressSanitizer: while reporting a bug found another one. Ignoring.
==29718==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffdb03d8f0 at pc 0x55616d2e6ba9 bp 0x7fffdb03c0c0 sp 0x7fffdb03c0b0
READ of size 4 at 0x7fffdb03d8f0 thread T0
    #0 0x55616d2e6ba8 in space_init_parts_mapper (/data/bv7/swiftsim/examples/swift+0x74ba8)
    #1 0x55616d3b9f38 in threadpool_chomp (/data/bv7/swiftsim/examples/swift+0x147f38)
    #2 0x55616d3ba74f in threadpool_map (/data/bv7/swiftsim/examples/swift+0x14874f)
    #3 0x55616d2e71b0 in space_init_parts (/data/bv7/swiftsim/examples/swift+0x751b0)
    #4 0x55616d33e262 in engine_init_particles (/data/bv7/swiftsim/examples/swift+0xcc262)
    #5 0x55616d2afd60 in main (/data/bv7/swiftsim/examples/swift+0x3dd60)
    #6 0x7f2f09cd9b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #7 0x55616d2a5a79 in _start (/data/bv7/swiftsim/examples/swift+0x33a79)

Address 0x7fffdb03d8f0 is located in stack of thread T0 at offset 5184 in frame
    #0 0x55616d2a6172 in main (/data/bv7/swiftsim/examples/swift+0x34172)

  This frame has 72 object(s):
    [32, 33) 'chemistry'
    [96, 97) 'cooling_func'
    [160, 161) 'potential'
    [224, 225) 'starform'
    [288, 289) 'feedback_properties'
    [352, 353) 'entropy_floor'
    [416, 420) 'with_aff'
    [480, 484) 'dry_run'
    [544, 548) 'dump_tasks'
    [608, 612) 'dump_threadpool'
    [672, 676) 'nsteps'
    [736, 740) 'restart'
    [800, 804) 'with_cosmology'
    [864, 868) 'with_external_gravity'
    [928, 932) 'with_temperature'
    [992, 996) 'with_cooling'
    [1056, 1060) 'with_self_gravity'
    [1120, 1124) 'with_hydro'
    [1184, 1188) 'with_stars'
    [1248, 1252) 'with_star_formation'
    [1312, 1316) 'with_feedback'
    [1376, 1380) 'with_black_holes'
    [1440, 1444) 'with_limiter'
    [1504, 1508) 'with_fp_exceptions'
    [1568, 1572) 'with_drift_all'
    [1632, 1636) 'with_mpole_reconstruction'
    [1696, 1700) 'with_structure_finding'
    [1760, 1764) 'verbose'
    [1824, 1828) 'nr_threads'
    [1888, 1892) 'with_verbose_timers'
    [1952, 1956) 'flag_entropy_ICs'
    [2016, 2020) 'restart_nfiles'
    [2080, 2084) 'icount'
    [2144, 2152) 'gparts'
    [2208, 2216) 'parts'
    [2272, 2280) 'sparts'
    [2336, 2344) 'bparts'
    [2400, 2408) 'output_parameters_filename'
    [2464, 2472) 'cpufreqarg'
    [2528, 2536) 'cpufreq'
    [2592, 2600) 'buffer'
    [2656, 2664) 'Ngas'
    [2720, 2728) 'Ngpart'
    [2784, 2792) 'Nspart'
    [2848, 2856) 'Nbpart'
    [2912, 2928) 'tic'
    [2976, 2992) 'toc'
    [3040, 3064) 'stars_properties'
    [3104, 3128) 'black_holes_properties'
    [3168, 3208) 'us'
    [3264, 3312) 'reparttype'
    [3360, 3440) 'gravity_properties'
    [3488, 3568) 'argparse'
    [3616, 3720) 'hydro_properties'
    [3776, 3944) 'prog_const'
    [4000, 4384) 'cosmo'
    [4416, 4424) 'data'
    [4480, 4504) 'dim'
    [4544, 4576) 'N_total'
    [4608, 4696) 'mesh'
    [4736, 5176) 's' <== Memory access at offset 5184 overflows this variable
    [5216, 6952) 'options'
    [7008, 9304) 'e'
    [9344, 13448) 'cmdps'
    [13504, 13544) 'dumpfile'
    [13600, 13800) 'restart_file'
    [13856, 14056) 'ICfileName'
    [14112, 14368) '__xpg_basename'
    [14400, 14656) 'stfbasename'
    [14688, 14944) 'restart_dir'
    [14976, 15232) 'restart_name'
    [15264, 15520) 'resubmit_command'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/data/bv7/swiftsim/examples/swift+0x74ba8) in space_init_parts_mapper
Shadow bytes around the buggy address:
  0x10007b5ffac0: f2 f2 f2 f2 f2 f2 f8 f8 f8 f2 f2 f2 f2 f2 f8 f8
  0x10007b5ffad0: f8 f8 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffae0: 00 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffaf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10007b5ffb10: 00 00 00 00 00 00 00 00 00 00 00 00 00 f2[f2]f2
  0x10007b5ffb20: f2 f2 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffb30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffb40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffb50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007b5ffb60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==29718==ABORTING

The test seems to run fine with optimisations enabled. Without the sanitizer and without optimisations it just stops at the point where the sanitizer makes it crash.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking