gmt
gmt copied to clipboard
Bug in movie. buffer overflow detected
I run the following script, when I use title=EJ24_3_Anim_EARG_Sismicid
(which is used for movie -N) I have no problem but when I use title=EJ24_3_Anim_EARG_Sismicida
I get the following error:
*** buffer overflow detected ***: terminated Anim_EARG_BUG.sh: línea 16: 96051 Abortado (`core' generado) gmt movie main.sh -Chd -Ttimes.txt -N$title -H2 -Lc0+jTR+o0.4/0.4+gwhite+h+r --FONT_TAG=16p,Helvetica,black --FORMAT_CLOCK_MAP=- --FORMAT_DATE_MAP=o-yyyy -Fmp4 -D14 --GMT_LANGUAGE=ES -Ve -Zs
What is the problem? That name must be less than 26 characters?
Full Script:
#!/usr/bin/env bash
title=EJ24_3_Anim_EARG_Sismicid # Works fine
title=EJ24_3_Anim_EARG_Sismicida # Buffer overflow
echo $title
gmt math -o0 -T2001-01-01T/2021-01-1T/1y T = times.txt
cat << EOF > main.sh
gmt begin
gmt basemap -R-85/-20/-64.9/-44.4 -JM23.8c -B+n -Yc -Xc
gmt end
EOF
gmt movie main.sh -Chd -Ttimes.txt -N$title -H2 -Lc0+jTR+o0.4/0.4+gwhite+h+r --FONT_TAG=16p,Helvetica,black --FORMAT_CLOCK_MAP=- \
--FORMAT_DATE_MAP=o-yyyy -Fmp4 -D14 --GMT_LANGUAGE=ES -Ve -Zs
I made two string variables longer but I do not think it is related (but give it a test). Does not crash on macOS. Perhaps this is a good opportunity for you to learn how to build GMT in debug mode and run it in a visual debugger (VSC?). Maybe @joa-quim can advice on that. If there is a bug we need to know where it crashes - it is not enough to know that it crashes in movie. I have added how-to debugging information in the documentation but I only have knowledge of macOS and to some extent Linux - I cannot write the same sections for Windows - help needed.
Nothing to really help before building with VS is accomplished. e.g https://github.com/GenericMappingTools/gmt/issues/4718
Ok @PaulWessel. I will read it and try to debug in VSC. Right now I am working mostly in Linux. Then, I have yet to learn to build from source and debug in Windows.
Sure, and it is not crashing in Linux then I take it?
Sorry Paul. I don't understand well. Do you need me to debug in Linux? Any tips on how to do it in VSC?
Paul is assuming that the problem manifests only on Windows. I don't know how to debug with VSC. Apparently it's possible but the setting seemed too complicated to me. I do the debugging with VS, which is needed anyway to build GMT. After building it (again, I posted an issue explaining) the debug is very easy. Just do\
- "File -> Open -> Project/Solution" and open the .exe that we want to debug.
- Next open the source code and set breakpoints.
- Under "Project -> Properties" set the command line option in the
Arguments
field - Hit F5
The bad news is that movie
is the worst module to debug, under ANY OS, because it makes many system calls and there no debugger can dive.
Yes, I assumed this was Windows only. if it also is reproducible on Linux then perhaps we can debug via ddd.
I wasn't able to reproduce the bug when building from master on Windows and running the script using Git Bash.
$ gmt --version
6.3.0_417760f_2021.07.12
The movie module is more peculiar. It depends on the type of shell where it's run. Not the OS (hopefully)
I have a similar error in Ubuntu when the name has more than 24 characters. I don't think it is important to debug. For me, to add a warning in the docs to avoid long names in movie -N is enough.
I continue falling with this issue. I was running on Ubuntu.
After some test, i found that the "buffer overflow error" appears when the ffmpeg
command is longer than 256 characters.
For example I made a movie that uses this ffmpeg command (wich is 256 character long) and works.
movie [NOTICE]: Running: ffmpeg -loglevel warning -f image2 -framerate 99 -y -i "/home/federico/Software/gmt_test/movie_BufferOverflow_0123456789012345678901234567890123456789012345/10_TierraGirando/10_TierraGirando_%01d.png" -vcodec libx264 -pix_fmt yuv420p 10_TierraGirando.mp4
Then when I change the frame rate from 99 to 100, I got the overflow error. If I run the ffmpeg
command directly on the terminal, it works fine.
Is there a way to add a warning when the ffmpeg command is too large?
Nice sleuthing. Could the allowable command length be increased instead from GMT_LEN256
?
https://github.com/GenericMappingTools/gmt/blob/85ec5493062bf90c9eb4cd31e958db2024d338aa/src/movie.c#L1320