lorenzo-rovigatti / oxDNA

A new version of the code to simulate the oxDNA/oxRNA models, now equipped with Python bindings
https://dna.physics.ox.ac.uk/
GNU General Public License v3.0
42 stars 27 forks source link

[BUG] oxpy `file_info` segfaults when presented with a malformed trajectory file #65

Closed JeDeveloper closed 11 months ago

JeDeveloper commented 1 year ago

Describe the bug When given a trajectory file in which the final conf is malformed (i.e. the file is prematurely truncated), oxDNA_analysis_tools.file_info.file_info will crash with a segmentation fault error. The cause of this appears to be a misalignment between the behaviors of oxDNA_analysis_tool.UTILS.RyeReader.descibe and cget_confs (which I think? is a C++ binding?). describe lists the index of the final, malformed conf as valid but passing it to cget_confs causes the segfault.

To Reproduce Steps to reproduce the behavior: I can reproduce the issue by mutilating my one of my other trajectories (removing the last few dozen lines), and then attempting to use file_info in the same manner.

Expected behavior I don't think it's my place to define the failure behavior or whether it should attempt to recover but some sort of warning in this circumstance would be very helpful

Desktop (please complete the following information):

ErikPoppleton commented 1 year ago

Just wanted to let you know that I have seen this and will add a helpful error message at some point. I'm sure that it happens because on the C side, cget_confs is allocating memory based on the number of bases in the first configuration and then something bad is happening when it hits a configuration with a different size. A bit surprising it segfaults instead of leaving you with an array full of garbage data.

ErikPoppleton commented 11 months ago

C pointers aren't nice, but it's fixed on oat_dev now. Will merge the pull request to master shortly.