delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2016/03/13/04:18:09

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Date: Sun, 13 Mar 2016 09:21:24 +0100 (CET)
X-X-Sender: igor2 AT igor2priv
To: geda-user AT delorie DOT com
X-Debug: to=geda-user AT delorie DOT com from="gedau AT igor2 DOT repo DOT hu"
From: gedau AT igor2 DOT repo DOT hu
Subject: [geda-user] pcb: more memory leaks
Message-ID: <alpine.DEB.2.00.1603130700180.7885@igor2priv>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
MIME-Version: 1.0
Reply-To: geda-user AT delorie DOT com

Hi all,

after removing glib from pcb-rnd core, I am in a better position to 
valgrind the code. (Bert asked me to send leaks I find so that they can be 
fixed in mainline too; rNUMBERS are revision numbers in pcb-rnd's svn 
for reference).

(Note: some of these leaks are "virtual" in the sense that they are 
allocated once and would be free'd at exit. Some say such allocation 
should not be free'd because it's just spending/wasting some CPU cycles on 
heap administration of memory that will be discarded anyway. I do not 
want to generate discussion about this topic; I decided to fix them in 
pcb-rnd and I list them so mainline pcb developers can decide whether 
they should be fixed.)

1. Easy ones

These are relatively easy to fix, as they are local.

- InitBuffers() allocates paste buffers, but there's no UninitBuffers() to 
free them (r1227)

- on quit, either by the GUI hid's main loop returning or by the quit 
action, FreePCBMemory() is called, but the actual PCB data allocation is 
not freed, only its fields (r1229, r1238, depends on r1223, see later)

- on quit, default layer names in settings are not free'd (r1231, depends 
on r1223)

- pcb parser: parse_y.y: in the "flags:" rule, after string_to_flags, $1 
should be free()'d; the .l allocates the string, the parser should free 
it.

- pcb parser: parse_y.y: a similar case in rule "pcbflags:" for $3 in the 
second subrule (where flags are spcified as a string, not as an integer)

- pcb parser: parse_y.y: two similar case in rule "pcbstyles:" for $3

- pcb parser: parse_y.y: in the "layers:" rule, at the end free($5) if $5 
is not NULL (but do NOT free($4))

- strflags.c: alloc_buf(); it allocates and maintains a cache of 10 
buffers; at the end none of this get free()'d (r1233)

- strflags.c: grow_layer_list(); it allocates and maintains an array of 
layers; at the end none of this get free()'d (r1237)

- main.c: pcblibdir, homedir, bindir, exec_prefix are allocated in 
InitPaths() but are never free()'d (r1234)

- main.c: program_directory is never free()'d (r1235)

- main.c: Settings.MakeProgram and Settings.GnetlistProgram are never 
free()'d (r1236)


2. Hard ones

These require new API and/or biggish refactoring.

- there's no infrastructure for properly uninitializing GUI hids so they 
have no chance to free resources they allocated for the gui (r1222)

- the quit action just runs exit(0); instead, it should issue a call to 
the GUI hid and ask it to exit cleanly (r1223)

- resource_parse() allocates a tree for the resources loaded, but there's 
no call to free() this tree. I plan to replace the current resource code 
with lihata on the long run, so I did not properly fix this one, just 
worked it around using the "leaky" "auto-free-at-exit" allocation 
mechanism (free_atexit.[ch])

The list is not complete, it reflects the result of my first leak cleanup 
session. There would be subsequent sessions soon.

Regards,

Igor2

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019