Menu ▾ ▴

#2906 [revised description] very long command may be truncated on input

None
pending-fixed
nobody
12 hours ago
4 days ago
Rene Hansen
No

I am using gnuplot thru wxMaxima:

If I make somewhat less than 50-90 tics the plots goes fine, but above 100-130 tics (yes - that number varies...) all I get is:

image

If I then locate the temporary gnuplot files:

image

And open them with wxgnuplot.exe - I can get two results:

Either
1) This with a lot of spaces where the tics should have been:

image

Or -
2) The plot works just fine

It's seems a bit random - especially when the number of tics goes above 50-90

Beyond 150 tics, it certainly doesn't work !

I have made a small test workbook for wxMaxima. There are also a set of gnuplot-files to test on:

TicsTest.zip (github.com)

I have made a ticket at the wxMaxima:
https://github.com/wxMaxima-developers/wxmaxima/issues/2284

But Gunter Königsman at the wxMaxima developer team, thinks it is more likely to be a gnuplot issue - he writes:

That seems to clearly indicate that the problem is on gnuplot's side and not triggered reliably. "Not reliable" sounds like a memory or thread concurrency bug. A few years ago I would have said that means it being hard-to-hunt down (what still is true). Nowadays I would immediately label it as "potential security issue. Report it to them and tell them to try asan to get a chance of hunting it down."

The earliest gnuplot version I have that works is:

 G N U P L O T
        Version 6.0 patchlevel 3    last modified 2025-06-07 

        Copyright (C) 1986-1993, 1998, 2004, 2007-2025
        Thomas Williams, Colin Kelley and many others

        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help FAQ"
        immediate help:   type "help"  (plot window: hit 'h')

        Terminal type is now q

The first gnuplot version I have, which has this failure is:

 G N U P L O T
        Version 6.0 patchlevel 5    last modified 2026-07-28 

        Copyright (C) 1986-1993, 1998, 2004, 2007-2026
        Thomas Williams, Colin Kelley and many others

        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help FAQ"
        immediate help:   type "help"  (plot window: hit 'h')

        Terminal type is now qt
1 Attachments

Discussion

  • Rene Hansen

    Rene Hansen - 4 days ago
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -21,6 +21,8 @@
     2) The plot works just fine
    
     It's seems a bit random - especially when the number of tics goes above 50-90
    +
    +Beyond 150 tics, it certainly doesn't work !
    
     I have made a small test workbook for wxMaxima. There are also a set of gnuplot-files to test on:
    
    • Group: -->
    • Priority: -->
     
  • Rene Hansen

    Rene Hansen - 4 days ago
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -37,7 +37,7 @@
     That seems to clearly indicate that the problem is on gnuplot's side and not triggered reliably. "Not reliable" sounds like a memory or thread concurrency bug. A few years ago I would have said that means it being hard-to-hunt down (what still is true). Nowadays I would immediately label it as "potential security issue. Report it to them and tell them to try asan to get a chance of hunting it down."
    
    
    -The last  gnuplot version I have that works is:
    +The earliest  gnuplot version I have that works is:
     ~~~
      G N U P L O T
             Version 6.0 patchlevel 3    last modified 2025-06-07 
    @@ -52,7 +52,7 @@
             Terminal type is now q
     ~~~
    
    -The first gnuplot version that has this failure is:
    +The first gnuplot version I have, which has this failure is:
    
      ~~~
      G N U P L O T
    
     
  • Rene Hansen

    Rene Hansen - 4 days ago
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -56,16 +56,16 @@
    
      ~~~
      G N U P L O T
    
    -        Version 6.0 patchlevel 3    last modified 2025-06-07 
    +        Version 6.0 patchlevel 5    last modified 2026-07-28 
    
    
    -        Copyright (C) 1986-1993, 1998, 2004, 2007-2025
    +        Copyright (C) 1986-1993, 1998, 2004, 2007-2026
             Thomas Williams, Colin Kelley and many others
    
             gnuplot home:     http://www.gnuplot.info
             faq, bugs, etc:   type "help FAQ"
             immediate help:   type "help"  (plot window: hit 'h')
    
    
    -        Terminal type is now q
    +        Terminal type is now qt
     ~~~
    
     
  • Rene Hansen

    Rene Hansen - 4 days ago
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -54,7 +54,7 @@
    
     The first gnuplot version I have, which has this failure is:
    
    
    - ~~~
    +~~~
      G N U P L O T
             Version 6.0 patchlevel 5    last modified 2026-07-28 
    
     
  • Ethan Merritt

    Ethan Merritt - 2 days ago
    • status: open --> pending-fixed
     
  • Ethan Merritt

    Ethan Merritt - 2 days ago

    Fixed now.

    There is no security concern here. The bug was that if a very long (>2048 char) command line is encountered early in a session, the input buffer size may not yet have been extended to hold the full command. This resulted in the command being only partially read, with the result being the error message you see. It also results in the input buffer being extended, so that same command would succeed if issued again. This might be the source of the "not triggered reliably" observation.
    When the input buffer requires extension because of a very long command, the program must issue an additional read to load the rest of the command. This "go back and read the rest" step was inadvertantly lost in version 6.0.5 as a side-effect of a fix for a related bug.

     
  • Ethan Merritt

    Ethan Merritt - 2 days ago
    • summary: Ticx not working reliably - potential security risk !!! --> [revised description] very long command may be truncated on input
     
  • Ethan Merritt

    Ethan Merritt - 2 days ago

    Fixed now.

    There is no security concern here. The bug was that if a very long (>2048 char) command line is encountered early in a session, the input buffer size may not yet have been extended to hold the full command. This resulted in the command being only partially read, with the result being the error message you see. It also results in the input buffer being extended, so that same command would succeed if issued again. This might be the source of the "not triggered reliably" observation.
    When the input buffer requires extension because of a very long command, the program must issue an additional read to load the rest of the command. This "go back and read the rest" step was inadvertantly lost in version 6.0.5 as a side-effect of a fix for a related bug.

     
    • Hiroki Motoyoshi

      With 93a256 applied, one case still fails.

      If a line plus its trailing newline exactly fills the buffer, left <= 1 is true even though the whole line was read, so the next line is appended to it.

      Attached test.gp shows the issue: line 2 is exactly 2046 characters, and the script stops with
      "test.gp" line 2: unexpected or unrecognized token: print.

      Checking for the newline fixed it for me:

      if (left <= 1 && gp_input_line[len-1] != '\n') {
      
       
      • Ethan Merritt

        Ethan Merritt - 1 day ago

        You are right. Thanks.

         
  • Rene Hansen

    Rene Hansen - 21 hours ago

    I am using gnuplot from within wxMaxima, who generates the files for gnuplot and calls gnuplot to execute these files. Is this fixed for now ?
    When is the fix included in a release that wxMaxima can include with their installations files ?

     
    • Ethan Merritt

      Ethan Merritt - 12 hours ago

      This particular bug exists only in versions 6.0.5 and 6.0.6. If you need a pre-built release, you could "downgrade" to version 6.0.4 or earlier. If building from source, you could pull from the current git repositories for either version 6.0 or 6.1.

      For a work-around that lets you continue using version 6.0.5 or 6.0.6, place the following lines in your system or personal initialization file for gnuplot. See "help initialization" for guidance on where these files are located. Or I suppose there may be a way to tell wxMaxima to add these commands at the front of a gnuplot script. This creates a very long string of comment characters and tells gnuplot to load it. The bug will cause only part of the string to be executed, but it's all one big comment so nothing happens except that the input buffer is expanded to >8K characters. After that the bug will not trigger again unless an even longer command is encountered. If you are worried that 8K is not enough, feel free to adjust the iteration in the do for statement.

      # force expansion of the gnuplot input line buffer
      comment = "#"; do for [i=1:1024] { comment = comment."########" }
      evaluate(comment)
      
       

Log in to post a comment.