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

fix #15631 #15632

Merged
merged 12 commits into from
Oct 19, 2020
Merged

fix #15631 #15632

merged 12 commits into from
Oct 19, 2020

Conversation

n5m
Copy link
Contributor

@n5m n5m commented Oct 19, 2020

fix #15631

Copy link
Contributor

@Clyybber Clyybber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests without -d:useMalloc should be removed as they only really test that we don't use malloc or that valgrind can only detect leaks via malloc (not something we should test or rely on); we also don't need seperate tests for orc/arc in this case IMO.

@n5m
Copy link
Contributor Author

n5m commented Oct 19, 2020

What is the best way to get the Valgrind tests to pass on non-Linux hosts in the pipelines?

One way could be to rewrite the tests to look like

discard """
   # Testament configs
   # Testament configs
   # Testament configs
"""
when defined(linux) and sizeof(int) == 8:
  # original test code
  discard alloc(1)
else:
  # simulate the expected failed valgrind output
  echo "   definitely lost: 7 bytes in 2 blocks"
  # exit with the same code as --error-exitcode=1
  quit(1)

which follows the example set here:

when defined(linux) and sizeof(int) == 8:

and fakes the output expected in test cases like
outputsub: " definitely lost: 7 bytes in 2 blocks"

but this does not seem like a great solution.

@n5m
Copy link
Contributor Author

n5m commented Oct 19, 2020

Oh, this looks like it will be much better:

Nim/testament/specs.nim

Lines 317 to 325 in d6160ef

of "disabled":
case e.value.normalize
of "y", "yes", "true", "1", "on": result.err = reDisabled
of "n", "no", "false", "0", "off": discard
of "win", "windows":
when defined(windows): result.err = reDisabled
of "linux":
when defined(linux): result.err = reDisabled
of "bsd":

Nim/testament/specs.nim

Lines 339 to 341 in d6160ef

of "32bit":
if sizeof(int) == 4:
result.err = reDisabled

@Clyybber
Copy link
Contributor

tests/arc/tasyncorc.nim and tests/arc/thavlak_orc_stress.nim leak :)

@Clyybber
Copy link
Contributor

Sorry for force-pushing to your branch @n5m , I thought that a rebase would solve the errors.
I now added a leaks switch to the valgrind option to accomodate for the two failing tests.
(Test failures unrelated)

@Clyybber Clyybber merged commit 436e1fa into nim-lang:devel Oct 19, 2020
@n5m
Copy link
Contributor Author

n5m commented Oct 19, 2020

Quite all right, @Clyybber. Happy to have helped with this PR.

I am interested, however, in seeing tvalgrind.nim added back into the codebase. My rationale is that while tleak_arc.nim tests that memory leaks are found, tvalgrind.nim tests Testament, itself. It also nicely parallels the remaining tests in testament/tests/shouldfail/, which test Testament's other configuration options.

Would you be opposed to a tvalgrind.nim like this?

discard """
valgrind: enabled
cmd: "nim $target --gc:arc -d:useMalloc $options $file"
disabled: "freebsd"
disabled: "macosx"
disabled: "openbsd"
disabled: "windows"
disabled: "32bit"
"""

when defined(linux) and sizeof(int) == 8:
  # test that a memory leak is caught by valgrind, but valgrind only
  # runs on 64-bit Linux machines...
  discard alloc(1)
else:
  # ...so on all other OS/architectures, simulate the same exit code
  # that valgrind would have thrown for this test case
  quit(1) # chosen from --error-exit=1

@Clyybber
Copy link
Contributor

@n5m Oh, yeah that looks fine.

@n5m n5m deleted the n5m-valgrind branch October 21, 2020 03:17
narimiran pushed a commit that referenced this pull request Oct 21, 2020
* trigger valgrind failure on memory leak

* remove non-malloc tests

* remove ORC test

is redundant because we already have an ARC test

* only run valgrind tests on 64-bit Linux

* disable freebsd and openbsd

* Remove tleak_refc

As to not test implementation details (or bug)

* Fix test failures by removing redundant test

Since this tests/shoulfail/tvalgrind.nim was specified here to fail this test
itself fails since it will be skipped on non-linux CI

* Remove test, reason detailed in the previous commit

* Remove redundant disables

* Revert removing disables

* Add and use valgrind: leaks

* Fix

Co-authored-by: Clyybber <darkmine956@gmail.com>
Co-authored-by: n5m
(cherry picked from commit 436e1fa)
mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
* trigger valgrind failure on memory leak

* remove non-malloc tests

* remove ORC test

is redundant because we already have an ARC test

* only run valgrind tests on 64-bit Linux

* disable freebsd and openbsd

* Remove tleak_refc

As to not test implementation details (or bug)

* Fix test failures by removing redundant test

Since this tests/shoulfail/tvalgrind.nim was specified here to fail this test
itself fails since it will be skipped on non-linux CI

* Remove test, reason detailed in the previous commit

* Remove redundant disables

* Revert removing disables

* Add and use valgrind: leaks

* Fix

Co-authored-by: Clyybber <darkmine956@gmail.com>
Co-authored-by: n5m
irdassis pushed a commit to irdassis/Nim that referenced this pull request Mar 16, 2021
* trigger valgrind failure on memory leak

* remove non-malloc tests

* remove ORC test

is redundant because we already have an ARC test

* only run valgrind tests on 64-bit Linux

* disable freebsd and openbsd

* Remove tleak_refc

As to not test implementation details (or bug)

* Fix test failures by removing redundant test

Since this tests/shoulfail/tvalgrind.nim was specified here to fail this test
itself fails since it will be skipped on non-linux CI

* Remove test, reason detailed in the previous commit

* Remove redundant disables

* Revert removing disables

* Add and use valgrind: leaks

* Fix

Co-authored-by: Clyybber <darkmine956@gmail.com>
Co-authored-by: n5m
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.

Testament does not check memory leaks with Valgrind
3 participants