Skip to content
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

Plug memory leak #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Plug memory leak #7

wants to merge 3 commits into from

Conversation

ms609
Copy link

@ms609 ms609 commented Jun 16, 2021

p0 seems never to be freed.
This PR adds a record of its unincremented address to the tr object, and frees it in freeTree().
valgrind suggests that this plugs the leak.

ms609 and others added 3 commits June 16, 2021 17:02
free(p0)
Need also to change legacy.h
Unmatched CALLOC
@ms609
Copy link
Author

ms609 commented Jul 24, 2023 via email

@JGLAHE
Copy link

JGLAHE commented Jul 25, 2023

Yes sorry I got confused: aberer/RogueNaRok lists two public forks (the most recent of which is yours), but accessing it from that ms609/RogueNaRok link goes to the ms609:master branch, which is what I cloned, and thus got an error about common.h requiring R.h.

I commented about it here before I found the ms609:patch-1 branch through somewhere, maybe one of the CRAN pages (I can't recall exactly? obviously I wasn't thinking clearly). But that worked well, so hopefully this eventually gets merged...

@JGLAHE
Copy link

JGLAHE commented Aug 23, 2023

Hi, sorry just getting back to this:

RogueNaRok $make
gcc  -c -o common.o common.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o RogueNaRok.o RogueNaRok.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o Tree.o Tree.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o BitVector.o BitVector.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o HashTable.o HashTable.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o List.o List.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o Array.o Array.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o Dropset.o Dropset.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o ProfileElem.o ProfileElem.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o legacy.o legacy.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o newFunctions.o newFunctions.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o parallel.o parallel.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -c -o Node.o Node.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
gcc  -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -o RogueNaRok common.o RogueNaRok.o Tree.o BitVector.o HashTable.o List.o Array.o Dropset.o ProfileElem.o legacy.o newFunctions.o parallel.o Node.o -lm
/usr/bin/ld: RogueNaRok.o:(.bss+0x10080): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: Tree.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0x80): first defined here
/usr/bin/ld: Tree.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: BitVector.o:(.bss+0x20): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0x80): first defined here
/usr/bin/ld: BitVector.o:(.bss+0x10020): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: HashTable.o:(.bss+0x0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: List.o:(.bss+0x0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: Dropset.o:(.bss+0x20): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0x80): first defined here
/usr/bin/ld: Dropset.o:(.bss+0x10020): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: ProfileElem.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0x80): first defined here
/usr/bin/ld: ProfileElem.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: legacy.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0x80): first defined here
/usr/bin/ld: legacy.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: newFunctions.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0x80): first defined here
/usr/bin/ld: newFunctions.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: Node.o:(.bss+0x0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:49: RogueNaRok] Error 1

and,

RogueNaRok $make mode=parallel
gcc  -c -o common.o common.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o RogueNaRok.o RogueNaRok.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o Tree.o Tree.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o BitVector.o BitVector.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o HashTable.o HashTable.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o List.o List.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o Array.o Array.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o Dropset.o Dropset.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o ProfileElem.o ProfileElem.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o legacy.o legacy.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o newFunctions.o newFunctions.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o parallel.o parallel.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -c -o Node.o Node.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS
gcc  -Wall -D_GNU_SOURCE -O3 -DNDEBUG  -DPARALLEL -DPORTABLE_PTHREADS  -o RogueNaRok-parallel common.o RogueNaRok.o Tree.o BitVector.o HashTable.o List.o Array.o Dropset.o ProfileElem.o legacy.o newFunctions.o parallel.o Node.o -lm -pthread
/usr/bin/ld: RogueNaRok.o:(.bss+0x100c0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: Tree.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: Tree.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: BitVector.o:(.bss+0x20): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: BitVector.o:(.bss+0x10020): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: HashTable.o:(.bss+0x0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: List.o:(.bss+0x0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: Dropset.o:(.bss+0x20): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: Dropset.o:(.bss+0x10020): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: ProfileElem.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: ProfileElem.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: legacy.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: legacy.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: newFunctions.o:(.bss+0x0): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: newFunctions.o:(.bss+0x10000): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: parallel.o:(.bss+0x0): multiple definition of `globalPArgs'; RogueNaRok.o:(.bss+0x68): first defined here
/usr/bin/ld: parallel.o:(.bss+0x20): multiple definition of `bits_in_16bits'; RogueNaRok.o:(.bss+0xc0): first defined here
/usr/bin/ld: parallel.o:(.bss+0x10020): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
/usr/bin/ld: Node.o:(.bss+0x0): multiple definition of `processID'; common.o:(.bss+0x480): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:46: RogueNaRok] Error 1

This was via git clone -b patch-1 https://github.com/ms609/RogueNaRok.git
GNU Make 4.3 Built for x86_64-pc-linux-gnu
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0

I tried moving some definitions around (processID; bits_in_16bits) and it also complained about globalPArgs in debug and it got rid of the warning but aborted as soon as it started on the examples (I don't know C at all)

Cheers

@ms609
Copy link
Author

ms609 commented Aug 23, 2023 via email

@JGLAHE
Copy link

JGLAHE commented Aug 23, 2023

Thank you for the quick response!

I assume I can just use the patch-1 makefile for the master branch (there's no makefile)?

Anyway, make just gave me the same error as last time:

RogueNaRok $make
gcc  -c -o common.o common.c -Wall -D_GNU_SOURCE -O3 -DNDEBUG
In file included from common.c:31:
common.h:43:10: fatal error: R.h: No such file or directory
   43 | #include <R.h>
      |          ^~~~~
compilation terminated.
make: *** [Makefile:53: common.o] Error 1

@ms609
Copy link
Author

ms609 commented Aug 23, 2023 via email

@JGLAHE
Copy link

JGLAHE commented Aug 23, 2023

Yes, sorry I misunderstood; yes I'll fork it cheers

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

Successfully merging this pull request may close these issues.

None yet

2 participants