linux - C++ command line utility input file location changes behaviour -
i've wrote command line utility extracting text dxf files. utility named drawingtotext. assuming directory structure this(linux os):
/home/dave/dxfs/
with bunch of dxf files in dxfs folder. location, assuming file exists named "p1-1522-yi-wd-0403r1.dxf", running drawingtotext fails:
drawingtotext p1-1522-yi-wd-0403r1.dxf
with error: segmentation fault (core dumped)
running drawingtotext ~/dxfs/p1-1522-yi-wd-0403r1.dxf
gives me expect plus @ end:
*** error in 'drawingtotext': free(): invalid next size (fast): 0x0000000002031170 ***
with backtrace , huge memory map.
now, moving file directory (/home/dave/ instead of /home/dave/dxfs/) results in results i'm looking no error. renaming file else "mydxf.dxf" , keeping in /home/dave/dxfs/ fixes issue well.
my question how , why location of file change behaviour of program , how fix it?
the code here: http://www.github.com/davidworkman9/drawingtotext/
the main file called "autocadconverter.cpp"
for first error drawingtotext p1-1522-yi-wd-0403r1.dxf
command, sure executable in same folder p1-1522-yi-wd-0403r1.dxf?
the second error occurs when free memory has not been allocated. looking @ code, error must occurring on delete input
or delete output
lines near end, seeing that's place you're freeing memory.
said
"running gives me expect plus [error] @ end?"
if output created want, , thing wrong error, can account adding:
if (input != null) delete input; if (output != null) delete output;
to avoid freeing memory not allocated. again fixes problem if output correct said, works, may indicative of larger error.
should run program strace can see system calls before seg fault , free() error.
Comments
Post a Comment