Skip to content

Bug in movie. buffer overflow detected #5426

Closed

Description

@Esteban82

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

Activity

  1. added
    bug
    on Jul 2, 2021
  2. PaulWessel commented on Jul 3, 2021

    @PaulWessel
    Contributor

    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.

  3. joa-quim commented on Jul 4, 2021

    @joa-quim
    Member

    Nothing to really help before building with VS is accomplished. e.g #4718

  4. Esteban82 commented on Jul 4, 2021

    @Esteban82
    MemberAuthor

    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.

  5. PaulWessel commented on Jul 4, 2021

    @PaulWessel
    Contributor

    Sure, and it is not crashing in Linux then I take it?

  6. Esteban82 commented on Jul 5, 2021

    @Esteban82
    MemberAuthor

    Sorry Paul. I don't understand well. Do you need me to debug in Linux? Any tips on how to do it in VSC?

  7. joa-quim commented on Jul 5, 2021

    @joa-quim
    Member

    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.

  8. PaulWessel commented on Jul 5, 2021

    @PaulWessel
    Contributor

    Yes, I assumed this was Windows only. if it also is reproducible on Linux then perhaps we can debug via ddd.

  9. maxrjones commented on Jul 14, 2021

    @maxrjones
    Member

    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
    
  10. joa-quim commented on Jul 14, 2021

    @joa-quim
    Member

    The movie module is more peculiar. It depends on the type of shell where it's run. Not the OS (hopefully)

  11. Esteban82 commented on Aug 19, 2021

    @Esteban82
    MemberAuthor

    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.

  12. Esteban82 commented on Jul 20, 2022

    @Esteban82
    MemberAuthor

    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?

  13. maxrjones commented on Jul 20, 2022

    @maxrjones
    Member

    Nice sleuthing. Could the allowable command length be increased instead from GMT_LEN256?

    gmt/src/movie.c

    Line 1320 in 85ec549

    char string[GMT_LEN128] = {""}, extra[GMT_BUFSIZ] = {""}, cmd[GMT_LEN256] = {""}, cleanup_file[PATH_MAX] = {""}, L_txt[GMT_LEN128] = {""};

  14. Esteban82 commented on May 16, 2023

    @Esteban82
    MemberAuthor

    Paul told me that this was modify and it is no longer an issue. I test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions