Menu

#2881 Memory leaks if commands fail

None
pending-fixed
nobody
None
2026-08-15
2026-07-31
PuQ
No

Version: 6.0.4

Caught by LSan:

gnuplot> 7bytes
         ^
         invalid command

gnuplot> +8bytes
         ^
         invalid command

gnuplot> print and 24 more bytes
         undefined variable: and

gnuplot>

=================================================================
ERROR: LeakSanitizer: detected memory leaks

Direct leak of 39 byte(s) in 3 object(s) allocated from:
    #0 0x7f5c3dd2c0c1 in malloc (/usr/lib/libasan.so.8+0x12c0c1) (BuildId: 7f2845989b820f536270e19ec47df085ae89a675)
    #1 0x7f5c3dc910ac  (/usr/lib/libasan.so.8+0x910ac) (BuildId: 7f2845989b820f536270e19ec47df085ae89a675)
    #2 0x561b8271e9b1 in command src/command.c:852
    #3 0x561b8271d298 in step_through_line src/command.c:546
    #4 0x561b8271c9d0 in do_line src/command.c:443
    #5 0x561b8271c9ab in com_line src/command.c:431
    #6 0x561b82867d6f in main src/plot.c:682

SUMMARY: AddressSanitizer: 39 byte(s) leaked in 3 allocation(s).

Discussion

  • PuQ

    PuQ - 2026-08-08

    Version: 6.1 1fb8ac4

    Leaks from src/gnuplot -d <demo/fit.dem.

    Reduced repros:

    gnuplot> splot ""
                   ^
             No previous filename
    
    gnuplot> splot ""
                   ^
             No previous filename
    
    gnuplot>
    
    =================================================================
    ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 840 byte(s) in 1 object(s) allocated from:
        #0 0x7f24292198f0 in malloc (/usr/lib/liblsan.so.0+0x198f0)
        #1 0x000001071fd8 in gp_alloc src/alloc.c:56
        #2 0x0000011820b2 in sp_alloc src/plot3d.c:137
        #3 0x00000117e01d in eval_3dplots src/plot3d.c:1743
        #4 0x00000117da92 in plot3drequest src/plot3d.c:398
        #5 0x000001070480 in splot_command src/command.c:2889
    
    gnuplot> print '' . a
             undefined variable: a
    
    gnuplot> print '' . a
             undefined variable: a
    
    gnuplot>
    
    =================================================================
    ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 1 byte(s) in 1 object(s) allocated from:
        #0 0x7fe6200198f0 in malloc (/usr/lib/liblsan.so.0+0x198f0)
        #1 0x7fe61fcaf0bf in __strdup (/usr/lib/libc.so.6+0xaf0bf)
        #2 0x000001073105 in gp_strdup src/util.c:408
        #3 0x000001076c85 in push src/eval.c:651
        #4 0x0000011b5e54 in f_pushc src/internal.c:136
        #5 0x000001076d6e in execute_at src/eval.c:754
        #6 0x000001076e57 in evaluate_at src/eval.c:790
        #7 0x0000010e902b in const_express src/parse.c:176
        #8 0x00000106f5a4 in print_command src/command.c:2496
    
    gnuplot> fit x $bytes8
             no datablock named $bytes8
    
    *** FIT ERROR ***
    gnuplot> fit x '7bytes'
                   ^
             Can't read data from
    
    *** FIT ERROR ***
    gnuplot>
    
    =================================================================
    ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 15 byte(s) in 2 object(s) allocated from:
        #0 0x7f7b268198f0 in malloc (/usr/lib/liblsan.so.0+0x198f0)
        #1 0x7f7b264af0bf in __strdup (/usr/lib/libc.so.6+0xaf0bf)
        #2 0x000001073105 in gp_strdup src/util.c:408
        #3 0x0000010644f9 in fit_main src/fit.c:1708
        #4 0x000001063fdf in fit_command src/fit.c:320
    
    gnuplot> set fit logfile '/doesnt/exist'
    gnuplot> fit x '-'
             could not open log-file /doesnt/exist
    
    *** FIT ERROR ***
    gnuplot>
    
    =================================================================
    ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 14 byte(s) in 1 object(s) allocated from:
        #0 0x7f8878a198f0 in malloc (/usr/lib/liblsan.so.0+0x198f0)
        #1 0x7f88786af0bf in __strdup (/usr/lib/libc.so.6+0xaf0bf)
        #2 0x000001073105 in gp_strdup src/util.c:408
        #3 0x0000010679f3 in getfitlogfile src/fit.c:2415
        #4 0x000001064ca9 in fit_main src/fit.c:1873
        #5 0x000001063fdf in fit_command src/fit.c:320
    
     
  • Ethan Merritt

    Ethan Merritt - 2026-08-15
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     

Log in to post a comment.