ORNL-Fusion / KORC

Kinetic Orbit Runaway Code (KORC)
http://ornl-fusion.github.io/KORC
MIT License
6 stars 2 forks source link

Call destruction destructors after constructing random state objects. #22

Closed cianciosa closed 7 months ago

cianciosa commented 7 months ago

This fixes memory leaks of random state objects by ensuring the destructors are called.

quantumsteve commented 7 months ago
1: Test command: /home/svh/Documents/KORC/test/egyro/korc_egyro.sh "/home/svh/Documents/KORC/test/egyro"
1: Working Directory: /home/svh/Documents/KORC/build/bin
1: Test timeout computed to be: 10000000
1: + INPUT_FILE=/home/svh/Documents/KORC/test/egyro/input_file_egyro.korc
1: + OUT_DIR=egyro_test
1: + mkdir -p egyro_test
1: + ./xkorc /home/svh/Documents/KORC/test/egyro/input_file_egyro.korc egyro_test/
1: =================================================================
1: ==899590==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x61e000016880 in thread T0:
1:   object passed to delete has wrong type:
1:   size of the allocated type:   2536 bytes;
1:   size of the deallocated type: 2520 bytes.
1:     #0 0x7f1222407c65 in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:177
1:     #1 0x55814ebd09d8 in random_destroy_U /home/svh/Documents/KORC/src/korc_c_random.cpp:66
1:     #2 0x55814eb59f8c in __korc_random_MOD_finalize_random_u /home/svh/Documents/KORC/src/korc_random.f90:151
1:     #3 0x55814eafd3e4 in __korc_rnd_numbers_MOD_finalize_random_seed /home/svh/Documents/KORC/src/korc_rnd_numbers.f90:195
1:     #4 0x55814e9b6f6e in __korc_fields_MOD_unitvectors /home/svh/Documents/KORC/src/korc_fields.f90:1164
1:     #5 0x55814eb4ca3e in gyro_distribution /home/svh/Documents/KORC/src/korc_velocity_distribution.f90:437
1:     #6 0x55814eb490f5 in __korc_velocity_distribution_MOD_initial_gyro_distribution /home/svh/Documents/KORC/src/korc_velocity_distribution.f90:508
1:     #7 0x55814eb1945a in __korc_initialize_MOD_set_up_particles_ic /home/svh/Documents/KORC/src/korc_initialize.f90:733
1:     #8 0x55814e94d61f in MAIN__ /home/svh/Documents/KORC/src/main.f90:270
1:     #9 0x55814e94e712 in main /home/svh/Documents/KORC/src/main.f90:7
1:     #10 0x7f1221787082 in __libc_start_main ../csu/libc-start.c:308
1:     #11 0x55814e948aed in _start (/home/svh/Documents/KORC/build/bin/xkorc+0x35aed)
1: 
1: 0x61e000016880 is located 0 bytes inside of 2536-byte region [0x61e000016880,0x61e000017268)
1: allocated by thread T0 here:
1:     #0 0x7f1222406587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
1:     #1 0x55814ebd0908 in random_construct_N /home/svh/Documents/KORC/src/korc_c_random.cpp:50
1:     #2 0x55814eb59f6f in __korc_random_MOD_initialize_random_n /home/svh/Documents/KORC/src/korc_random.f90:159
1:     #3 0x55814eafec3d in __korc_rnd_numbers_MOD_init_random_seed /home/svh/Documents/KORC/src/korc_rnd_numbers.f90:163
1:     #4 0x55814e9b44b4 in __korc_fields_MOD_unitvectors /home/svh/Documents/KORC/src/korc_fields.f90:1101
1:     #5 0x55814eb4ca3e in gyro_distribution /home/svh/Documents/KORC/src/korc_velocity_distribution.f90:437
1:     #6 0x55814eb490f5 in __korc_velocity_distribution_MOD_initial_gyro_distribution /home/svh/Documents/KORC/src/korc_velocity_distribution.f90:508
1:     #7 0x55814eb1945a in __korc_initialize_MOD_set_up_particles_ic /home/svh/Documents/KORC/src/korc_initialize.f90:733
1:     #8 0x55814e94d61f in MAIN__ /home/svh/Documents/KORC/src/main.f90:270
1:     #9 0x55814e94e712 in main /home/svh/Documents/KORC/src/main.f90:7
1:     #10 0x7f1221787082 in __libc_start_main ../csu/libc-start.c:308
1: 
1: SUMMARY: AddressSanitizer: new-delete-type-mismatch ../../../../src/libsanitizer/asan/asan_new_delete.cc:177 in operator delete(void*, unsigned long)
1: ==899590==HINT: if you don't care about these errors you may set ASAN_OPTIONS=new_delete_type_mismatch=0
1: ==899590==ABORTING
1/2 Test #1: egyro_test .......................***Failed    1.61 sec