Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garbage when reading in a blank string for tdfdir on M2 Mac. #255

Closed
samcunliffe opened this issue Mar 10, 2023 · 3 comments · Fixed by #254
Closed

Garbage when reading in a blank string for tdfdir on M2 Mac. #255

samcunliffe opened this issue Mar 10, 2023 · 3 comments · Fixed by #254
Labels
bug Something isn't working

Comments

@samcunliffe
Copy link
Member

Possibly related to #191.
Probably related to #211.
Superficially fixed by PR #254.

Bug investigation:

I noticed on (and only on?) my M2 Mac that all of the system tests fail. Unzipping the contents of arc_01.zip and running interactively (with a lot of debug printout), I get:

./tdms pstd_fs_input.mat fs_output.mat
[2023-03-10 11:31:59.189] [debug] Parsing 3 command line arguments
[2023-03-10 11:31:59.189] [info] Output file specified: fs_output.mat
[2023-03-10 11:31:59.189] [debug] Finished parsing arguments
[2023-03-10 11:31:59.190] [info] Input file: pstd_fs_input.mat | No gridfile supplied
[2023-03-10 11:31:59.196] [info] exi not present
[2023-03-10 11:31:59.196] [info] eyi not present
[2023-03-10 11:31:59.196] [info] Using pseudospectral method (PSTD)
[2023-03-10 11:31:59.196] [info] Using band-limited interpolation where possible
[2023-03-10 11:31:59.196] [debug] Finding the string: 'sourcemode'
[2023-03-10 11:31:59.196] [debug] This string is 7 chars long.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'sourcemode' = 'pulsed'.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'sourcemode' = 'pulsed'.
[2023-03-10 11:31:59.196] [debug] Finding the string: 'runmode'
[2023-03-10 11:31:59.196] [debug] This string is 9 chars long.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'runmode' = 'complete'.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'runmode' = 'complete'.
[2023-03-10 11:31:59.196] [debug] Finding the string: 'dimension'
[2023-03-10 11:31:59.196] [debug] This string is 2 chars long.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'dimension' = '3'.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'dimension' = '3'.
[2023-03-10 11:31:59.196] [info] intmethod = 1
[2023-03-10 11:31:59.196] [info] exi not present
[2023-03-10 11:31:59.196] [info] eyi not present
[2023-03-10 11:31:59.196] [info] f_ex_vec has ndims=2 N=512
[2023-03-10 11:31:59.196] [info] Np = 2, Nt = 500, Npe = 250, f_max = 2.94577e+14, Npraw = 0.4606
[2023-03-10 11:31:59.196] [debug] Finding the string: 'tdfdir'
[2023-03-10 11:31:59.196] [debug] This string is 1 chars long.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'tdfdir' = ''.
[2023-03-10 11:31:59.196] [debug] Have got the string. 'tdfdir' = ''.
[2023-03-10 11:31:59.196] [debug] Will write the TD fields to '?'
[2023-03-10 11:31:59.196] [info] Ni_tdf = 276, Nk_tdf = 276
[2023-03-10 11:31:59.196] [debug] Will write the TD fields to '?'
[2023-03-10 11:31:59.196] [info] Isource is empty
[2023-03-10 11:31:59.196] [info] Jsource is empty
[2023-03-10 11:31:59.196] [info] f_ex_vec has ndims=2 N=512
[2023-03-10 11:31:59.197] [debug] init_diff_shift_op, delta=-0.5
[2023-03-10 11:31:59.197] [debug] init_diff_shift_op, delta=-0.5
[2023-03-10 11:31:59.197] [debug] init_diff_shift_op, delta=-0.5
[2023-03-10 11:31:59.197] [debug] init_diff_shift_op, delta=0.5
[2023-03-10 11:31:59.197] [debug] init_diff_shift_op, delta=0.5
[2023-03-10 11:31:59.197] [debug] init_diff_shift_op, delta=0.5
[2023-03-10 11:32:00.245] [info] dims: (254,1,254)
[2023-03-10 11:32:00.251] [info] Using 8 OMP threads
[2023-03-10 11:32:00.251] [info] refind (Refractive index) = 1.350014e+00
[2023-03-10 11:32:00.251] [info] Starting main looop
[2023-03-10 11:32:00.266] [info] Exporting field... folder_name = 
[2023-03-10 11:32:00.266] [debug] folder_name = 
[2023-03-10 11:32:00.266] [debug] folder_name = 
time domain output: /ex_000000.mat
[2023-03-10 11:32:00.266] [debug] Opened file /ex_000000.mat
0x117844b20
zsh: segmentation fault  ./tdms pstd_fs_input.mat fs_output.mat

Investigation:

  • The 'tifdir' is an empty string (this is verified in the input .mat file).
  • The matlabio.cpp::string_in function correctly reads in an empty char * this is propagated to the IndependentObjectsFromInfile constructor.
  • But! Gets replaced by garbage (i.e. is not empty) during a conversion between std::string and char*. And since the design is that a non-empty 'tdfdir' means "write out the field", tdms tries to write out a field to the root of my file system (/).
@samcunliffe samcunliffe added the bug Something isn't working label Mar 10, 2023
@samcunliffe
Copy link
Member Author

We can't run our CI on MacOS ARM images ... yet (actions/runner-images#2187).

@samcunliffe
Copy link
Member Author

🤦 this duplicates #129.

@giordano
Copy link
Member

We can't run our CI on MacOS ARM images ... yet

I use Cirrus for running CI on apple silicon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants