Skip to content

memory leak #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
asarubbo opened this issue Jul 29, 2016 · 0 comments
Open

memory leak #24

asarubbo opened this issue Jul 29, 2016 · 0 comments

Comments

@asarubbo
Copy link

ago@willoughby /tmp $ echo "foo" > foo.txt && paps foo.txt 
foo foo.txt                                                                                                                                                                                                                                                                   
%!PS-Adobe-3.0                                                                                                                                                                                                                                                                
%%Title: foo.txt                                                                                                                                                                                                                                                              
%%Creator: paps version 0.6.7 by Dov Grobgeld                                                                                                                                                                                                                                 
%%Pages: (atend)                                                                                                                                                                                                                                                              
%%BoundingBox: 0 0 595 841                                                                                                                                                                                                                                                    
%%BeginProlog                                                                                                                                                                                                                                                                 
%%Orientation: Portrait                                                                                                                                                                                                                                                       
/papsdict 1 dict def                                                                                                                                                                                                                                                          
papsdict begin                                                                                                                                                                                                                                                                

/inch {72 mul} bind def                                                                                                                                                                                                                                                       
/mm {1 inch 25.4 div mul} bind def                                                                                                                                                                                                                                            

% override setpagedevice if it is not defined                                                                                                                                                                                                                                 
/setpagedevice where {                                                                                                                                                                                                                                                        
    pop % get rid of its dictionary                                                                                                                                                                                                                                           
    /setpagesize {                                                                                                                                                                                                                                                            
       3 dict begin                                                                                                                                                                                                                                                           
         /pageheight exch def                                                                                                                                                                                                                                                 
         /pagewidth exch def                                                                                                                                                                                                                                                  
         /orientation 0 def                                                                                                                                                                                                                                                   
         % Exchange pagewidth and pageheight so that pagewidth is bigger                                                                                                                                                                                                      
         pagewidth pageheight gt {                                                                                                                                                                                                                                            
             pagewidth                                                                                                                                                                                                                                                        
             /pagewidth pageheight def                                                                                                                                                                                                                                        
             /pageheight exch def                                                                                                                                                                                                                                             
             /orientation 3 def                                                                                                                                                                                                                                               
         } if                                                                                                                                                                                                                                                                 
         2 dict                                                                                                                                                                                                                                                               
         dup /PageSize [pagewidth pageheight] put                                                                                                                                                                                                                             
         dup /Orientation orientation put                                                                                                                                                                                                                                     
         setpagedevice                                                                                                                                                                                                                                                        
       end                                                                                                                                                                                                                                                                    
    } def                                                                                                                                                                                                                                                                     
}                                                                                                                                                                                                                                                                             
{                                                                                                                                                                                                                                                                             
    /setpagesize { pop pop } def                                                                                                                                                                                                                                              
} ifelse                                                                                                                                                                                                                                                                      
/duplex {                                                                                                                                                                                                                                                                     
    statusdict /setduplexmode known 
    { statusdict begin setduplexmode end } {pop} ifelse
} def
/tumble {
    statusdict /settumble known
   { statusdict begin settumble end } {pop} ifelse
} def
% Turn the page around
/turnpage {
  90 rotate
  0 pageheight neg translate
} def
% User settings
/pagewidth 595 def
/pageheight 841 def
pagewidth pageheight setpagesize
/column_width 523 def
/bodyheight 769 def
/lmarg 36 def
/ytop 805 def
/do_separation_line true def
/do_landscape false def
/do_tumble true def
/do_duplex true def
% Procedures to translate position to first and second column
/lw 20 def % whatever
/setnumcolumns {
    /numcolumns exch def
    /firstcolumn { /xpos lmarg def /ypos ytop def} def
    /nextcolumn { 
      do_separation_line {
          xpos column_width add gutter_width 2 div add % x start
           ytop lw add moveto              % y start
          0 bodyheight lw add neg rlineto 0 setlinewidth stroke
      } if
      /xpos xpos column_width add gutter_width add def 
      /ypos ytop def
    } def
} def

1 setnumcolumns
/showline {
    /y exch def
    /s exch def
    xpos y moveto 
    column_width 0 rlineto stroke
    xpos y moveto /Helvetica findfont 20 scalefont setfont s show
} def
/paps_bop {  % Beginning of page definitions
    papsdict begin
    gsave
    do_landscape {turnpage} if 
    % ps2pdf gets wrong orientation without this!
    /Helvetica findfont setfont 100 100 moveto ( ) show
    firstcolumn
    end
} def

/paps_eop {  % End of page cleanups
    grestore    
} def
%%BeginProlog
/papsdict 1 dict def
papsdict begin

/conicto {
    /to_y exch def
    /to_x exch def
    /conic_cntrl_y exch def
    /conic_cntrl_x exch def
    currentpoint
    /p0_y exch def
    /p0_x exch def
    /p1_x p0_x conic_cntrl_x p0_x sub 2 3 div mul add def
    /p1_y p0_y conic_cntrl_y p0_y sub 2 3 div mul add def
    /p2_x p1_x to_x p0_x sub 1 3 div mul add def
    /p2_y p1_y to_y p0_y sub 1 3 div mul add def
    p1_x p1_y p2_x p2_y to_x to_y curveto
} bind def
/start_ol { gsave } bind def
/end_ol { closepath fill grestore } bind def
/draw_char { fontdict begin gsave 0.001000 dup scale last_x last_y translate load exec end grestore} def
/goto_xy { fontdict begin /last_y exch def /last_x exch def end } def
/goto_x { fontdict begin /last_x exch def end } def
/fwd_x { fontdict begin /last_x exch last_x add def end } def
/c /curveto load def
/x /conicto load def
/l /lineto load def
/m /moveto load def
end
/paps_exec {
  1 dict begin
  /ps exch def
  /len ps length def
  /pos 0 def

  % Loop over all the characters of the string
  {
    pos len eq {exit} if

    % Get character at pos
    /ch ps pos 1 getinterval def

    % check for +
    (+) ch eq {
      /pos 1 pos add def
      /xp ps pos 8 getinterval cvi def
      /yp ps pos 8 add 8 getinterval cvi def
      /pos 16 pos add def
      papsdict begin xp yp goto_xy end
    } {
      (*) ch eq {
        /pos 1 pos add def
        /xp ps pos 8 getinterval cvi def
        /pos 8 pos add def
        papsdict begin xp goto_x end
      } { (>) ch eq {
          /pos 1 pos add def
          /xp ps pos 4 getinterval cvi def
          /pos 4 pos add def
          papsdict begin xp 2 mul fwd_x end
        } { (-) ch eq {
            /pos 1 pos add def
            /xp ps pos 4 getinterval cvi def
            /pos 4 pos add def
            papsdict begin xp neg 2 mul fwd_x end
          } {
              % Must be a 3 char sym. Load and exec
              /name ps pos 3 getinterval def
              papsdict begin name draw_char end
              /pos 3 pos add def
            } ifelse
          } ifelse
        } ifelse
    } ifelse
  } loop
  end
} def
/fontdict 1 dict def
papsdict begin fontdict begin
/AAA { start_ol
6192 9144 m
6192 8280 l
4980 8280 l
4406 8280 4182 8032 x
3960 7785 3960 7156 x
3960 6552 l
6192 6552 l
6192 5688 l
3960 5688 l
3960 0 l
2880 0 l
2880 5688 l
1152 5688 l
1152 6552 l
2880 6552 l
2880 7027 l
2880 8115 3372 8629 x
3866 9144 4910 9144 x
6192 9144 l
7272 fwd_x
end_ol
 } def
/BAA { start_ol
3596 5760 m
2782 5760 2362 5133 x
1944 4506 1944 3276 x
1944 2050 2362 1420 x
2782 792 3596 792 x
4417 792 4836 1420 x
5256 2050 5256 3276 x
5256 4506 4836 5133 x
4417 5760 3596 5760 x
3596 6696 m
4961 6696 5684 5817 x
6408 4939 6408 3276 x
6408 1606 5686 731 x
4966 -144 3596 -144 x
2233 -144 1512 731 x
792 1606 792 3276 x
792 4939 1512 5817 x
2233 6696 3596 6696 x
7272 fwd_x
end_ol
 } def
end end
%%EndPrologue
%%EndPrologue
%%Page: 1 1
paps_bop
(+   36000  791032AAABAABAA)paps_exec
paps_eop
showpage
%%Pages: 1
%%Trailer
%%EOF

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

Direct leak of 2048 byte(s) in 3 object(s) allocated from:
    #0 0x4bdc75 in realloc (/usr/local/bin/paps+0x4bdc75)
    #1 0x7f99d8d7d14a  (/usr/lib64/libfontconfig.so.1+0x1c14a)

Indirect leak of 2176 byte(s) in 68 object(s) allocated from:
    #0 0x4bdaab in __interceptor_calloc (/usr/local/bin/paps+0x4bdaab)
    #1 0x7f99d8d7d8b8  (/usr/lib64/libfontconfig.so.1+0x1c8b8)

Indirect leak of 1856 byte(s) in 58 object(s) allocated from:
    #0 0x4bd932 in __interceptor_malloc (/usr/local/bin/paps+0x4bd932)
    #1 0x7f99d8d6c52f  (/usr/lib64/libfontconfig.so.1+0xb52f)

Indirect leak of 1333 byte(s) in 96 object(s) allocated from:
    #0 0x4bd932 in __interceptor_malloc (/usr/local/bin/paps+0x4bd932)
    #1 0x7f99d92a12c9 in __strdup (/lib64/libc.so.6+0x812c9)

Indirect leak of 864 byte(s) in 27 object(s) allocated from:
    #0 0x4bdaab in __interceptor_calloc (/usr/local/bin/paps+0x4bdaab)
    #1 0x7f99d8d7cde4  (/usr/lib64/libfontconfig.so.1+0x1bde4)

Indirect leak of 96 byte(s) in 2 object(s) allocated from:
    #0 0x4bd932 in __interceptor_malloc (/usr/local/bin/paps+0x4bd932)
    #1 0x7f99d8d77b0d in FcLangSetCreate (/usr/lib64/libfontconfig.so.1+0x16b0d)

Indirect leak of 64 byte(s) in 2 object(s) allocated from:
    #0 0x4bdaab in __interceptor_calloc (/usr/local/bin/paps+0x4bdaab)
    #1 0x7f99d8d7cc64  (/usr/lib64/libfontconfig.so.1+0x1bc64)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x4bd932 in __interceptor_malloc (/usr/local/bin/paps+0x4bd932)
    #1 0x7f99d8d7b842 in FcMatrixCopy (/usr/lib64/libfontconfig.so.1+0x1a842)

SUMMARY: AddressSanitizer: 8469 byte(s) leaked in 257 allocation(s).

To reproduce just compile it with -fsanitize=address which includes the memleak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant