Project

General

Profile

Bug #1705

trjcat append feature is broken

Added by Sergei Khruschev over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
analysis tools
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

trjcat append feature is broken in 5.x branch (with xtc files in my case). To reproduce:

wget "http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId=2F4K" -O 2F4K.pdb
trjconv -f 2F4K.pdb -o 2F4K.xtc
cp 2F4K.xtc 2F4K_1.xtc
trjcat -f 2F4K_1.xtc 2F4K.xtc -o 2F4K_1.xtc -cat

Invalid read of size 4
at 0x51CD5B1: trx_get_time_of_final_frame (trxio.c:241)
by 0x52A8843: gmx_trjcat (gmx_trjcat.c:698)
by 0x5144D92: gmx::(anonymous namespace)::CMainCommandLineModule::run(int, char**) (cmdlinemodulemanager.cpp:119)
by 0x514644F: gmx::CommandLineModuleManager::run(int, char**) (cmdlinemodulemanager.cpp:545)
by 0x40F032: main (gmx.cpp:58)
Address 0xc is not stack'd, malloc'd or (recently) free'd

Process terminating with default action of signal 11 (SIGSEGV)
Access not within mapped region at address 0xC
at 0x51CD5B1: trx_get_time_of_final_frame (trxio.c:241)
by 0x52A8843: gmx_trjcat (gmx_trjcat.c:698)
by 0x5144D92: gmx::(anonymous namespace)::CMainCommandLineModule::run(int, char**) (cmdlinemodulemanager.cpp:119)
by 0x514644F: gmx::CommandLineModuleManager::run(int, char**) (cmdlinemodulemanager.cpp:545)
by 0x40F032: main (gmx.cpp:58)


Related issues

Related to GROMACS - Task #2115: trjconv does too many things, and combinations of them work poorlyNew

Associated revisions

Revision ae076b0c (diff)
Added by Erik Lindahl over 2 years ago

Fix segfault in random access XTC searching

The XTC random access routine was accessing natoms
in a substructure that could be a null pointer. Fixed
by adding natoms as a separate field in the
high-level status, so we don't depend on frame data.

Fixes #1705.

Change-Id: I88c961b33ae21b16d64ed5d7514a1e0287c89baf

History

#1 Updated by Justin Lemkul over 2 years ago

  • Priority changed from Normal to Low

The problem is that you're using the same file name (2F4K_1.xtc) as input and output. If you specify a unique output name, the problem is fixed. We can probably put in a check against this, but this case really indicates abnormal usage. Or does this occur in other situations with unique file names?

#2 Updated by Sergei Khruschev over 2 years ago

Yes, of course! But in 4.x it was a documented feature - one may append an existing trajectory with new frames without overwriting. It's very pitty if it is no longer supported as our scripts rely on this. No we call old trjcat and it works as expected...

#3 Updated by Sergei Khruschev over 2 years ago

Well, looking through lines 650-750 of gmx_trjcat.c I cannot see any attempt to open output file if append mode is specified. :)
So it's not strange that it dies with segfault if trying to do sth with this file.

#4 Updated by Justin Lemkul over 2 years ago

Something probably went wrong with commit 2d8bcd501d0db411773b66a5e3bd2805ad7c4c04, which affects trxio.c and gmx_trjcat.c

#5 Updated by Mark Abraham over 2 years ago

  • Status changed from New to In Progress
  • Assignee set to Mark Abraham
  • Target version set to 5.0.5

Sergei Khruschev wrote:

Well, looking through lines 650-750 of gmx_trjcat.c I cannot see any attempt to open output file if append mode is specified. :)
So it's not strange that it dies with segfault if trying to do sth with this file.

Such a line exists e.g.

                trxout = open_trx(out_file, "a");

Justin Lemkul wrote:

Something probably went wrong with commit 2d8bcd501d0db411773b66a5e3bd2805ad7c4c04, which affects trxio.c and gmx_trjcat.c

Correct. read_next_x and read_next_frame (which deprecated the former a million years ago, not that anybody has acted on it) handle status differently, which causes the segfault.

#6 Updated by Mark Abraham over 2 years ago

Turns out there's an existing probably-unrelated problem with concatenating xtc files, probably only in trivial case of appending a single-frame XTC file to a copy of itself, but I'll probably have a fix in a few days.

#7 Updated by Mark Abraham over 2 years ago

  • Target version changed from 5.0.5 to 5.0.6

I have some wip

#8 Updated by Gerrit Code Review Bot over 2 years ago

Gerrit received a related patchset '1' for Issue #1705.
Uploader: Erik Lindahl ()
Change-Id: I88c961b33ae21b16d64ed5d7514a1e0287c89baf
Gerrit URL: https://gerrit.gromacs.org/4750

#9 Updated by Erik Lindahl over 2 years ago

  • Status changed from In Progress to Fix uploaded

#10 Updated by Mark Abraham over 2 years ago

I don't remember if this is the same thing I half-fixed already (but I think I remember that I was doing a more complex fix) but I'll check after 5.1

#11 Updated by Rossen Apostolov over 2 years ago

  • Status changed from Fix uploaded to Closed

closing

#12 Updated by Mark Abraham over 2 years ago

  • Status changed from Closed to Blocked, need info
  • Target version changed from 5.0.6 to 5.x

Please leave it open so I have the reminder that I need to check wehther I was fixing the same thing

#13 Updated by Erik Lindahl over 2 years ago

  • Status changed from Blocked, need info to Resolved
  • % Done changed from 0 to 100

#14 Updated by Rossen Apostolov over 2 years ago

  • Status changed from Resolved to Blocked, need info

issue was automatically marked resolved, changing to blocked as per Mark's request

#15 Updated by Erik Lindahl over 1 year ago

  • Status changed from Blocked, need info to Resolved

Checked that it works for the 2016 release.

#16 Updated by Erik Lindahl over 1 year ago

  • Status changed from Resolved to Closed

#17 Updated by Mark Abraham over 1 year ago

  • Target version changed from 5.x to 2016

#18 Updated by Mark Abraham 8 months ago

  • Related to Task #2115: trjconv does too many things, and combinations of them work poorly added

Also available in: Atom PDF