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

Memory leak in TDFieldExporter2D::export_field #129

Closed
samcunliffe opened this issue Oct 10, 2022 · 3 comments · Fixed by #254
Closed

Memory leak in TDFieldExporter2D::export_field #129

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

Comments

@samcunliffe
Copy link
Member

Not sure why yet, but we have a segmentation violation (I think from the 2D field exporter)...

➤ tdms in_pstd_cyl.mat output.mat
[2022-10-10 16:47:51.417] [debug] Parsing 3 command line arguments
infile:[in_pstd_cyl.mat], outfile:[output.mat], m=0
[2022-10-10 16:47:51.417] [debug] Finished parsing arguments
[2022-10-10 16:47:51.425] [info] Using 8 OMP threads
[2022-10-10 16:47:51.425] [info] Isource is empty
[2022-10-10 16:47:51.425] [info] Jsource is empty
[2022-10-10 16:47:51.425] [debug] f_ex_vec has ndims=2 N=1
[2022-10-10 16:47:51.425] [info] interpolation method = 1
[2022-10-10 16:47:51.425] [info] exi not present
[2022-10-10 16:47:51.425] [info] eyi not present
[2022-10-10 16:47:51.425] [info] Ni_tdf=276 Nk_tdf=276
[2022-10-10 16:47:51.425] [info] Refractive index = 1.35001
[2022-10-10 16:47:52.470] [debug] init_diff_shift_op, delta=-0.5
[2022-10-10 16:47:52.470] [debug] init_diff_shift_op, delta=-0.5
[2022-10-10 16:47:52.470] [debug] init_diff_shift_op, delta=-0.5
[2022-10-10 16:47:52.470] [debug] init_diff_shift_op, delta=0.5
[2022-10-10 16:47:52.470] [debug] init_diff_shift_op, delta=0.5
[2022-10-10 16:47:52.470] [debug] init_diff_shift_op, delta=0.5
[2022-10-10 16:47:52.470] [info] Np=2 Nt=500 Npe=250 f_max=2.94577e+14 Npraw=0.4606
dims:(254,1,254)
[2022-10-10 16:47:52.476] [debug] Starting main loop
[2022-10-10 16:47:52.488] [info] Saving field
[2022-10-10 16:47:52.488] [debug] Entered TDFieldExporter2D::export_field
[2022-10-10 16:47:52.488] [debug] Entered field written to array, creating output filename
[2022-10-10 16:47:52.488] [debug] output folder name: ??
[2022-10-10 16:47:52.488] [debug] output file name: ??/ex_000000.mat
time domain output: ??/ex_000000.mat
[2022-10-10 16:47:52.488] [debug] About to write matlab_array to the MATLAB output file
zsh: segmentation fault  tdms in_pstd_cyl.mat output.mat

Seems to only appear once debug logging was turned on. Which is rather alarming.

@samcunliffe samcunliffe self-assigned this Oct 10, 2022
@samcunliffe samcunliffe added the bug Something isn't working label Oct 10, 2022
@samcunliffe
Copy link
Member Author

[Notes to myself so I don't forget]

Seems to be restricted to my machine. Cannot reproduce on Myriad, and does not happen on the GitHub actions build.

The problem seems to be the TDFieldExporter2D.folder_name which gets given garbage.

(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
  * frame #0: 0x00000001092f3690 libmat.dylib`___lldb_unnamed_symbol1400 + 16
    frame #1: 0x00000001092f366f libmat.dylib`mat_developer_api::matPutVariable(MATFile*, char const*, mxArray_tag const*) + 63
    frame #2: 0x0000000100037640 tdms`TDFieldExporter2D::export_field(SplitField&, int, int) const + 736
    frame #3: 0x000000010005c801 tdms`mexFunction + 66385
    frame #4: 0x00000001000057a9 tdms`main + 601
    frame #5: 0x000000020013552e dyld`start + 462

@t-young31
Copy link
Member

could just get rid of MATLAB..?

@samcunliffe
Copy link
Member Author

In this case, I think it's our fault. For some reason, we're giving matPutVariable some memory garbage filename.

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