semigroups / Semigroups

The GAP package Semigroups
https://semigroups.github.io/Semigroups/
Other
23 stars 36 forks source link

Possible memory leak #948

Closed james-d-mitchell closed 12 months ago

james-d-mitchell commented 1 year ago
          OK, ran tests number of times, with both this and the old branch. The new branch doesn't really display a different behaviour (crashes don't happen during every run, and anyway it's a memory corruption/leak that finally brings GAP down sometimes).

Leaking/broken test is apparently semigroups/tst/standard/semigroups/semidp.tst and semigroups/tst/standard/semigroups/semiquo.tst, possibly more, only when run with acting methods disabled.

So here what all the logs I made have in common:

...
testing: /home/dima/tmp/gap/pkg/semigroups/tst/standard/tools/io.tst
    2438 ms (1711 ms GC) and 7.58MB allocated for tools/io.tst
-----------------------------------
total   1072164 ms (115772 ms GC) and 17.0GB allocated
              0 failures in 72 files

ESC[1m#I  Running tests with acting methods disabled
ESC[0mArchitecture: x86_64-unknown-openbsd7.3-default64-kv9

testing: /home/dima/tmp/gap/pkg/semigroups/tst/standard/attributes/acting.tst
    2281 ms (1625 ms GC) and 47.6MB allocated for attributes/acting.tst
...
testing: /home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semicons.ts\
t
   22820 ms (1734 ms GC) and 105MB allocated for semigroups/semicons.tst
testing: /home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semidp.tst
######## > Diff in:
/home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semidp.tst:319
# Input is:
Size(D) = Size(T) ^ 3;
# Expected output:
ESC[30;42mtrueESC[0m
# But found:
ESC[30;41mError, std::bad_allocESC[0m
########
   10906 ms (1812 ms GC) and 109MB allocated for semigroups/semidp.tst
testing: /home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semieunit.t\
st
...
testing: /home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semiquo.tst
######## > Diff in:
/home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semiquo.tst:121
# Input is:
Size(S / cong);
# Expected output:
ESC[30;42m120ESC[0m
# But found:
ESC[30;41mError, std::bad_allocESC[0m
########
######## > Diff in:
/home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semiquo.tst:123
# Input is:
IsomorphismPermGroup(S / cong);
# Expected output:
ESC[30;42m<quotient of <semigroup congruence over <inverse partial perm semigrou\
p 
  of size 720, rank 10 with 14 generators> with congruence pair (6,1)>> -> 
<permutation group of size 120 with 2 generators>ESC[0m
# But found:
ESC[30;41mError, std::bad_allocESC[0m
########
######## > Diff in:
/home/dima/tmp/gap/pkg/semigroups/tst/standard/semigroups/semiquo.tst:138
# Input is:
Size(S);
# Expected output:
ESC[30;42m336ESC[0m
# But found:
ESC[30;41mError, std::bad_allocESC[0m
########
...

Also,when it comes to running these tests, memory used by GAP shots up by about 1GB - another indication of a leak to me.

Originally posted by @dimpase in https://github.com/semigroups/Semigroups/issues/942#issuecomment-1712458666

james-d-mitchell commented 1 year ago

@dimpase, there were some leaks in Semigroups and downstream in Digraphs that are now resolved (I think, final checking tomorrow). I don’t think they accounted for the std::bad_allocs seen above though, they were mostly some memory allocated on start up, so fixed in size and not growing. Im going to check if it’s still an issue on the openBSD machine tomorrow.

james-d-mitchell commented 1 year ago

@dimpase I'm trying to check if this resolves the std::bad_allocs that you observed above on the openbsd machine that you gave me access to, but I'm getting:

Error, LOAD_DYN: failed to load kernel module /home/jdm/gap/pkg/Semigroups//bin/x86_64-unknown-openb\
sd7.3-default64-kv9/semigroups.so, Cannot load specified object in
  LOAD_DYN( filename ) at /home/jdm/gap/lib/files.gd:594 called from
<function "LoadDynamicModule">( <arguments> )
 called from read-eval loop at /home/jdm/gap/pkg/Semigroups/init.g:22
Error, was not in any namespace at /home/jdm/gap/lib/variable.g:269 called from
LEAVE_NAMESPACE(  ); at /home/jdm/gap/lib/package.gi:1324 called from
ReadPackage( pkgname, "init.g" ); at /home/jdm/gap/lib/package.gi:1697 called from
<function "LoadPackage">( <arguments> )
 called from read-eval loop at *stdin*:1
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk>

Any ideas how I can resolve this?

dimpase commented 1 year ago

export LD_LIBRARY_PATH=

then start GAP in this shell

(cf comments on this issue)

dimpase commented 1 year ago

it should point to the location of libsemigroups.so

james-d-mitchell commented 1 year ago

Aha, thanks, that works. When using the vendored libsemigroups wouldn't it make sense to set LD_LIBRARY_PATH so that this works automatically?

dimpase commented 1 year ago

the better way is to use -rpath mechanism, so that in the kernel module semigroups.so the location of libsemigroup.so is baked in. That's something I've promised to implement, hopefully today.

james-d-mitchell commented 1 year ago

Great, thank you very much @dimpase

dimpase commented 1 year ago

Great, thank you very much @dimpase

See #954 - ready for review. @fingolfin

james-d-mitchell commented 12 months ago

Resolved in v5.3.0, thanks @fingolfin and @dimpase