Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
25 Views

Code Crashes on macOS but not Windows

macOS 10.14.6 with Xcode 10.1 tooling. Windows 1810 with MSVC 15 2017 tooling. Both are using IFort 19.u5 I am facing a crash that only appears on macOS but not Windows during run time. The code will run properly using GFortran 6.3 on macOS. Code crashes under both Debug and Release modes. The crashing function is below: recursive function HDF_writeDatasetIntegerArray4D(dataname, intarr, dim0, dim1, dim2, dim3, HDF_head, overwrite) result(success) !DEC$ ATTRIBUTES DLLEXPORT :: HDF_writeDatasetIntegerArray4D use ISO_C_BINDING IMPLICIT NONE character(fnlen),INTENT(IN) :: dataname integer(kind=irg),INTENT(IN) :: dim0 integer(kind=irg),INTENT(IN) :: dim1 integer(kind=irg),INTENT(IN) :: dim2 integer(kind=irg),INTENT(IN) :: dim3 integer(kind=irg),INTENT(IN) :: intarr(dim0, dim1, dim2, dim3) type(HDFobjectStackType),INTENT(INOUT) :: HDF_head !f2py intent(in,out) :: HDF_head logical,INTENT(IN),OPTIONAL :: overwrite integer(kind=irg) :: success integer(HID_T) :: space, dset ! Handles integer :: hdferr, rnk integer(HSIZE_T), DIMENSION(1:4) :: dims integer, TARGET :: wdata(1:dim0,1:dim1,1:dim2,1:dim3) TYPE(C_PTR) :: f_ptr success = 0 write(*,*)'dim0=',dim0 write(*,*)'dim1=',dim1 write(*,*)'dim2=',dim2 write(*,*)'dim3=',dim3 dims(1:4) = (/ dim0, dim1, dim2, dim3 /) wdata = intarr <====================== CRASHES HERE The error that comes back is: Process 32216 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7ffeef0c1b88) frame #0: 0x0000000100513cde EMMCOpenCL`hdfsupport_mp_hdf_writedatasetintegerarray4d_ at HDFsupport.f90:2335 The code that actually calls that function is (Partially) this: ...... integer(kind=4),allocatable :: accum_e(:,:,:), accum_z(:,:,:,:), accum_xyz(:,:,:), rnseeds(:) character(fnlen) :: groupname, dataset, instring, dataname, fname, sourcefile, datagroupname, attributename, HDF_FileVersion integer(kind=irg) :: nx_size, nx , numEbins, numzbins ....... numangle = 1 nx_size = nx / 10 allocate(accum_e(numEbins,-nx:nx,-nx:nx),accum_z(numEbins,numzbins,-nx_size:nx_size,-nx_size:nx_size),stat=istat) accum_e = 0 accum_z = 0 call h5open_EMsoft(hdferr) call timestamp(datestring=dstr, timestring=tstre) ! get the filename; if it already exists, then delete it and create a new one dataname = '/tmp/OUT_TEST.h5' dataname = EMsoft_toNativePath(dataname) inquire(file=trim(dataname), exist=f_exists) if (f_exists) then open(unit=dataunit, file=trim(dataname), status='old',form='unformatted') close(unit=dataunit, status='delete') end if ! Create a new file using the default properties. hdferr = HDF_createFile(dataname, HDF_head) nx_size = 2 * (nx/10) + 1 dataset = SC_accumz hdferr = HDF_writeDatasetIntegerArray4D(dataset, accum_z, numEbins, numzbins, nx_size, nx_size, HDF_head) I have tried various ideas but none have solved the issue. Looking at the values in the debugger they all seem reasonable (at least to my untrained Fortran eyes). Thread 2 received signal SIGSEGV, Segmentation fault. 0x000000010051419a in hdfsupport::hdf_writedatasetintegerarray4d (dataname=..., intarr=..., dim0=11, dim1=101, dim2=51, dim3=51, hdf_head=..., overwrite=.TRUE., .tmp.DATANAME.len_V$2306=512) at /Users/mjackson/EMsoft-Dev/EMsoftPublic/Source/EMsoftHDFLib/HDFsupport.f90:2336 2336 wdata = intarr (gdb) p dim 0 $1 = 11 (gdb) p intarr $2 = (( ( ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, ...) ...) ...) ...) (gdb) p dim1 $3 = 101 (gdb) p dim2 $4 = 51 (gdb) p dim3 $5 = 51 (gdb) p wdata Cannot access memory at address 0x7ffeef0c2460 Thoughts or ideas?
0 Kudos
0 Replies