You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@corinthia.apache.org by Gabriela Gibson <ga...@gmail.com> on 2015/04/05 18:40:37 UTC

Valgrind leak in dftest & CMakeList include problem

Hi,

The command ./bin/dftest -plain showed a memory leak when run with Valgrind.

The reason for that is that in file

  incubator-corinthia/DocFormats/platform/tests/OStests.c

in function

  static void test_DFAddDirContents(void)

the call to the clean up function:

  static void freeDirEntryList(DFDirEntryList *list)

which lives in incubator-corinthia/DocFormats/core/src/lib/DFFilesystem.c

is omitted.

I think it's worthwhile to keep the test suite's Valgrind output
pristine, and so would like to fix this.

I could just copy the short code from the clean up function, but that's a
bit untidy, and, I failed at including the header file for DFFilesystem.h.

I added

  include_directories(../core/src/lib/)

to

  incubator-corinthia/DocFormats/platform/CMakeLists.txt

so it could find the header DFFilesystem.h and that solved that problem,
but alas,
DFFilesystem.h also requires:

[ 65%] Building C object
DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o
In file included from
/home/g/cor4/incubator-corinthia/DocFormats/platform/tests/OStests.c:19:0:
/home/g/cor4/incubator-corinthia/DocFormats/platform/../core/src/lib/DFFilesystem.h:21:32:
fatal error: DocFormats/DFError.h: No such file or directory
 #include <DocFormats/DFError.h>
                                ^
compilation terminated.
make[2]: ***
[DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o] Error 1
make[1]: *** [DocFormats/platform/CMakeFiles/platform.dir/all] Error 2
make: *** [all] Error 2

so do quite a few other files[1].

I did try to add

  include_directories(../api/headers/DocFormats/)

to the CmakeList.txt file above, but it does no good, since I
think it's in another directory when it works on that and so
cannot find it.

I'm wondering if:

a) there is an easy solution to this which I am missing

b) if it would be worthwhile, given the large amount of files
that require this header, to change things so that it no longer
requires the path but can simply be included with

#include "DFError.h" where required.

thanks,

Gabriela

[1]
./DocFormats/platform/tests/OStests.c:20:#include <DocFormats/DFError.h>
./DocFormats/api/headers/DocFormats/DFStorage.h:21:#include
<DocFormats/DFError.h>
./DocFormats/api/headers/DocFormats/Operations.h:21:#include
<DocFormats/DFError.h>
./DocFormats/api/headers/DocFormats/DocFormats.h:21:#include
<DocFormats/DFError.h>
./DocFormats/core/tests/html/HTMLPlain.h:21:#include <DocFormats/DFError.h>
./DocFormats/core/src/xml/DFXML.h:24:#include <DocFormats/DFError.h>
./DocFormats/core/src/html/DFHTDocument.h:23:#include <DocFormats/DFError.h>
./DocFormats/core/src/html/DFHTML.h:24:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/DFError.c:19:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/DFFilesystem.c:23:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/#DFFilesystem.c#:23:#include
<DocFormats/DFError.h>
./DocFormats/core/src/lib/DFZipFile.h:21:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/TextPackage.h:21:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/DFBuffer.h:21:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/DFFilesystem.h:21:#include <DocFormats/DFError.h>
./DocFormats/core/src/lib/DFString.h:21:#include <DocFormats/DFError.h>
./DocFormats/filters/ooxml/tests/word/WordPlain.h:21:#include
<DocFormats/DFError.h>
./DocFormats/filters/ooxml/src/common/OPC.h:22:#include
<DocFormats/DFError.h>
./DocFormats/filters/ooxml/src/word/Word.h:21:#include
<DocFormats/DFError.h>
./DocFormats/filters/odf/src/ODFPackage.h:22:#include <DocFormats/DFError.h>
./DocFormats/filters/odf/src/text/ODFText.h:21:#include
<DocFormats/DFError.h>
./consumers/dfutil/src/Commands.h:21:#include <DocFormats/DFError.h>


-- 
Visit my Coding Diary: http://gabriela-gibson.blogspot.com/

Re: Valgrind leak in dftest & CMakeList include problem

Posted by jan i <ja...@apache.org>.
On Sunday, April 5, 2015, Gabriela Gibson <ga...@gmail.com> wrote:

> Should OStests.c move or should the test function move into a new file
> in DocFormats/core/tests/common/ ?
>
> new file. OSTests.c is about low level io, DfFilesystem is a rather high
level function, that understand the strucure of ooxml and odf documents.

rgds
jan i

> It was all fine until I tried adding the clean up function to the test
> function :-)
>
> G
>
> On Sun, Apr 5, 2015 at 5:54 PM, jan i <jani@apache.org <javascript:;>>
> wrote:
>
> > You have problems because you turn the system upside down.
> >
> > platform depend only on itself (andxexternals)
> >
> > core depend on platform.
> >
> > so do not try to make platform depend on core. A test function that needs
> > DFFikesystem.h
> > does not beling in platform but in core.
> >
> > rgds
> > jan i
> >
> > On Sunday, April 5, 2015, Gabriela Gibson <gabriela.gibson@gmail.com
> <javascript:;>>
> > wrote:
> >
> > > Hi,
> > >
> > > The command ./bin/dftest -plain showed a memory leak when run with
> > > Valgrind.
> > >
> > > The reason for that is that in file
> > >
> > >   incubator-corinthia/DocFormats/platform/tests/OStests.c
> > >
> > > in function
> > >
> > >   static void test_DFAddDirContents(void)
> > >
> > > the call to the clean up function:
> > >
> > >   static void freeDirEntryList(DFDirEntryList *list)
> > >
> > > which lives in
> incubator-corinthia/DocFormats/core/src/lib/DFFilesystem.c
> > >
> > > is omitted.
> > >
> > > I think it's worthwhile to keep the test suite's Valgrind output
> > > pristine, and so would like to fix this.
> > >
> > > I could just copy the short code from the clean up function, but
> that's a
> > > bit untidy, and, I failed at including the header file for
> > DFFilesystem.h.
> > >
> > > I added
> > >
> > >   include_directories(../core/src/lib/)
> > >
> > > to
> > >
> > >   incubator-corinthia/DocFormats/platform/CMakeLists.txt
> > >
> > > so it could find the header DFFilesystem.h and that solved that
> problem,
> > > but alas,
> > > DFFilesystem.h also requires:
> > >
> > > [ 65%] Building C object
> > > DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o
> > > In file included from
> > >
> >
> /home/g/cor4/incubator-corinthia/DocFormats/platform/tests/OStests.c:19:0:
> > >
> > >
> >
> /home/g/cor4/incubator-corinthia/DocFormats/platform/../core/src/lib/DFFilesystem.h:21:32:
> > > fatal error: DocFormats/DFError.h: No such file or directory
> > >  #include <DocFormats/DFError.h>
> > >                                 ^
> > > compilation terminated.
> > > make[2]: ***
> > > [DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o] Error 1
> > > make[1]: *** [DocFormats/platform/CMakeFiles/platform.dir/all] Error 2
> > > make: *** [all] Error 2
> > >
> > > so do quite a few other files[1].
> > >
> > > I did try to add
> > >
> > >   include_directories(../api/headers/DocFormats/)
> > >
> > > to the CmakeList.txt file above, but it does no good, since I
> > > think it's in another directory when it works on that and so
> > > cannot find it.
> > >
> > > I'm wondering if:
> > >
> > > a) there is an easy solution to this which I am missing
> > >
> > > b) if it would be worthwhile, given the large amount of files
> > > that require this header, to change things so that it no longer
> > > requires the path but can simply be included with
> > >
> > > #include "DFError.h" where required.
> > >
> > > thanks,
> > >
> > > Gabriela
> > >
> > > [1]
> > > ./DocFormats/platform/tests/OStests.c:20:#include
> <DocFormats/DFError.h>
> > > ./DocFormats/api/headers/DocFormats/DFStorage.h:21:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/api/headers/DocFormats/Operations.h:21:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/api/headers/DocFormats/DocFormats.h:21:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/core/tests/html/HTMLPlain.h:21:#include
> > <DocFormats/DFError.h>
> > > ./DocFormats/core/src/xml/DFXML.h:24:#include <DocFormats/DFError.h>
> > > ./DocFormats/core/src/html/DFHTDocument.h:23:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/core/src/html/DFHTML.h:24:#include <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/DFError.c:19:#include <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/DFFilesystem.c:23:#include
> > <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/#DFFilesystem.c#:23:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/DFZipFile.h:21:#include
> <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/TextPackage.h:21:#include
> > <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/DFBuffer.h:21:#include <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/DFFilesystem.h:21:#include
> > <DocFormats/DFError.h>
> > > ./DocFormats/core/src/lib/DFString.h:21:#include <DocFormats/DFError.h>
> > > ./DocFormats/filters/ooxml/tests/word/WordPlain.h:21:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/filters/ooxml/src/common/OPC.h:22:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/filters/ooxml/src/word/Word.h:21:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/filters/odf/src/ODFPackage.h:22:#include
> > > <DocFormats/DFError.h>
> > > ./DocFormats/filters/odf/src/text/ODFText.h:21:#include
> > > <DocFormats/DFError.h>
> > > ./consumers/dfutil/src/Commands.h:21:#include <DocFormats/DFError.h>
> > >
> > >
> > > --
> > > Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
> > >
> >
> >
> > --
> > Sent from My iPad, sorry for any misspellings.
> >
>
>
>
> --
> Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
>


-- 
Sent from My iPad, sorry for any misspellings.

Re: Valgrind leak in dftest & CMakeList include problem

Posted by Gabriela Gibson <ga...@gmail.com>.
Should OStests.c move or should the test function move into a new file
in DocFormats/core/tests/common/ ?

It was all fine until I tried adding the clean up function to the test
function :-)

G

On Sun, Apr 5, 2015 at 5:54 PM, jan i <ja...@apache.org> wrote:

> You have problems because you turn the system upside down.
>
> platform depend only on itself (andxexternals)
>
> core depend on platform.
>
> so do not try to make platform depend on core. A test function that needs
> DFFikesystem.h
> does not beling in platform but in core.
>
> rgds
> jan i
>
> On Sunday, April 5, 2015, Gabriela Gibson <ga...@gmail.com>
> wrote:
>
> > Hi,
> >
> > The command ./bin/dftest -plain showed a memory leak when run with
> > Valgrind.
> >
> > The reason for that is that in file
> >
> >   incubator-corinthia/DocFormats/platform/tests/OStests.c
> >
> > in function
> >
> >   static void test_DFAddDirContents(void)
> >
> > the call to the clean up function:
> >
> >   static void freeDirEntryList(DFDirEntryList *list)
> >
> > which lives in incubator-corinthia/DocFormats/core/src/lib/DFFilesystem.c
> >
> > is omitted.
> >
> > I think it's worthwhile to keep the test suite's Valgrind output
> > pristine, and so would like to fix this.
> >
> > I could just copy the short code from the clean up function, but that's a
> > bit untidy, and, I failed at including the header file for
> DFFilesystem.h.
> >
> > I added
> >
> >   include_directories(../core/src/lib/)
> >
> > to
> >
> >   incubator-corinthia/DocFormats/platform/CMakeLists.txt
> >
> > so it could find the header DFFilesystem.h and that solved that problem,
> > but alas,
> > DFFilesystem.h also requires:
> >
> > [ 65%] Building C object
> > DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o
> > In file included from
> >
> /home/g/cor4/incubator-corinthia/DocFormats/platform/tests/OStests.c:19:0:
> >
> >
> /home/g/cor4/incubator-corinthia/DocFormats/platform/../core/src/lib/DFFilesystem.h:21:32:
> > fatal error: DocFormats/DFError.h: No such file or directory
> >  #include <DocFormats/DFError.h>
> >                                 ^
> > compilation terminated.
> > make[2]: ***
> > [DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o] Error 1
> > make[1]: *** [DocFormats/platform/CMakeFiles/platform.dir/all] Error 2
> > make: *** [all] Error 2
> >
> > so do quite a few other files[1].
> >
> > I did try to add
> >
> >   include_directories(../api/headers/DocFormats/)
> >
> > to the CmakeList.txt file above, but it does no good, since I
> > think it's in another directory when it works on that and so
> > cannot find it.
> >
> > I'm wondering if:
> >
> > a) there is an easy solution to this which I am missing
> >
> > b) if it would be worthwhile, given the large amount of files
> > that require this header, to change things so that it no longer
> > requires the path but can simply be included with
> >
> > #include "DFError.h" where required.
> >
> > thanks,
> >
> > Gabriela
> >
> > [1]
> > ./DocFormats/platform/tests/OStests.c:20:#include <DocFormats/DFError.h>
> > ./DocFormats/api/headers/DocFormats/DFStorage.h:21:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/api/headers/DocFormats/Operations.h:21:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/api/headers/DocFormats/DocFormats.h:21:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/core/tests/html/HTMLPlain.h:21:#include
> <DocFormats/DFError.h>
> > ./DocFormats/core/src/xml/DFXML.h:24:#include <DocFormats/DFError.h>
> > ./DocFormats/core/src/html/DFHTDocument.h:23:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/core/src/html/DFHTML.h:24:#include <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/DFError.c:19:#include <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/DFFilesystem.c:23:#include
> <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/#DFFilesystem.c#:23:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/DFZipFile.h:21:#include <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/TextPackage.h:21:#include
> <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/DFBuffer.h:21:#include <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/DFFilesystem.h:21:#include
> <DocFormats/DFError.h>
> > ./DocFormats/core/src/lib/DFString.h:21:#include <DocFormats/DFError.h>
> > ./DocFormats/filters/ooxml/tests/word/WordPlain.h:21:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/filters/ooxml/src/common/OPC.h:22:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/filters/ooxml/src/word/Word.h:21:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/filters/odf/src/ODFPackage.h:22:#include
> > <DocFormats/DFError.h>
> > ./DocFormats/filters/odf/src/text/ODFText.h:21:#include
> > <DocFormats/DFError.h>
> > ./consumers/dfutil/src/Commands.h:21:#include <DocFormats/DFError.h>
> >
> >
> > --
> > Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
> >
>
>
> --
> Sent from My iPad, sorry for any misspellings.
>



-- 
Visit my Coding Diary: http://gabriela-gibson.blogspot.com/

Re: Valgrind leak in dftest & CMakeList include problem

Posted by jan i <ja...@apache.org>.
You have problems because you turn the system upside down.

platform depend only on itself (andxexternals)

core depend on platform.

so do not try to make platform depend on core. A test function that needs
DFFikesystem.h
does not beling in platform but in core.

rgds
jan i

On Sunday, April 5, 2015, Gabriela Gibson <ga...@gmail.com> wrote:

> Hi,
>
> The command ./bin/dftest -plain showed a memory leak when run with
> Valgrind.
>
> The reason for that is that in file
>
>   incubator-corinthia/DocFormats/platform/tests/OStests.c
>
> in function
>
>   static void test_DFAddDirContents(void)
>
> the call to the clean up function:
>
>   static void freeDirEntryList(DFDirEntryList *list)
>
> which lives in incubator-corinthia/DocFormats/core/src/lib/DFFilesystem.c
>
> is omitted.
>
> I think it's worthwhile to keep the test suite's Valgrind output
> pristine, and so would like to fix this.
>
> I could just copy the short code from the clean up function, but that's a
> bit untidy, and, I failed at including the header file for DFFilesystem.h.
>
> I added
>
>   include_directories(../core/src/lib/)
>
> to
>
>   incubator-corinthia/DocFormats/platform/CMakeLists.txt
>
> so it could find the header DFFilesystem.h and that solved that problem,
> but alas,
> DFFilesystem.h also requires:
>
> [ 65%] Building C object
> DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o
> In file included from
> /home/g/cor4/incubator-corinthia/DocFormats/platform/tests/OStests.c:19:0:
>
> /home/g/cor4/incubator-corinthia/DocFormats/platform/../core/src/lib/DFFilesystem.h:21:32:
> fatal error: DocFormats/DFError.h: No such file or directory
>  #include <DocFormats/DFError.h>
>                                 ^
> compilation terminated.
> make[2]: ***
> [DocFormats/platform/CMakeFiles/platform.dir/tests/OStests.c.o] Error 1
> make[1]: *** [DocFormats/platform/CMakeFiles/platform.dir/all] Error 2
> make: *** [all] Error 2
>
> so do quite a few other files[1].
>
> I did try to add
>
>   include_directories(../api/headers/DocFormats/)
>
> to the CmakeList.txt file above, but it does no good, since I
> think it's in another directory when it works on that and so
> cannot find it.
>
> I'm wondering if:
>
> a) there is an easy solution to this which I am missing
>
> b) if it would be worthwhile, given the large amount of files
> that require this header, to change things so that it no longer
> requires the path but can simply be included with
>
> #include "DFError.h" where required.
>
> thanks,
>
> Gabriela
>
> [1]
> ./DocFormats/platform/tests/OStests.c:20:#include <DocFormats/DFError.h>
> ./DocFormats/api/headers/DocFormats/DFStorage.h:21:#include
> <DocFormats/DFError.h>
> ./DocFormats/api/headers/DocFormats/Operations.h:21:#include
> <DocFormats/DFError.h>
> ./DocFormats/api/headers/DocFormats/DocFormats.h:21:#include
> <DocFormats/DFError.h>
> ./DocFormats/core/tests/html/HTMLPlain.h:21:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/xml/DFXML.h:24:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/html/DFHTDocument.h:23:#include
> <DocFormats/DFError.h>
> ./DocFormats/core/src/html/DFHTML.h:24:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/DFError.c:19:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/DFFilesystem.c:23:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/#DFFilesystem.c#:23:#include
> <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/DFZipFile.h:21:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/TextPackage.h:21:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/DFBuffer.h:21:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/DFFilesystem.h:21:#include <DocFormats/DFError.h>
> ./DocFormats/core/src/lib/DFString.h:21:#include <DocFormats/DFError.h>
> ./DocFormats/filters/ooxml/tests/word/WordPlain.h:21:#include
> <DocFormats/DFError.h>
> ./DocFormats/filters/ooxml/src/common/OPC.h:22:#include
> <DocFormats/DFError.h>
> ./DocFormats/filters/ooxml/src/word/Word.h:21:#include
> <DocFormats/DFError.h>
> ./DocFormats/filters/odf/src/ODFPackage.h:22:#include
> <DocFormats/DFError.h>
> ./DocFormats/filters/odf/src/text/ODFText.h:21:#include
> <DocFormats/DFError.h>
> ./consumers/dfutil/src/Commands.h:21:#include <DocFormats/DFError.h>
>
>
> --
> Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
>


-- 
Sent from My iPad, sorry for any misspellings.