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

Bug: segfault with set_abundances #745

Merged
merged 2 commits into from
Oct 18, 2019
Merged

Bug: segfault with set_abundances #745

merged 2 commits into from
Oct 18, 2019

Conversation

luizirber
Copy link
Member

@luizirber luizirber commented Oct 18, 2019

I was working on a script and triggered a segfault by setting .track_abundance = True and then calling .set_abundances. For now a test reproducing the bug, working on fixing it.

Checklist

  • Is it mergeable?
  • make test Did it pass the tests?
  • make coverage Is the new code covered?
  • Did it change the command-line interface? Only additions are allowed
    without a major version increment. Changing file formats also requires a
    major version number increment.
  • Was a spellchecker run on the source code and documentation after
    changes were made?

@codecov
Copy link

codecov bot commented Oct 18, 2019

Codecov Report

Merging #745 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #745   +/-   ##
=======================================
  Coverage   88.59%   88.59%           
=======================================
  Files          30       30           
  Lines        4727     4727           
  Branches       46       46           
=======================================
  Hits         4188     4188           
  Misses        536      536           
  Partials        3        3

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ca4406...5f8d0ab. Read the comment docs.

@luizirber
Copy link
Member Author

luizirber commented Oct 18, 2019

This was a bit more nuanced than expected. But it boils down to these assumptions:

  1. This is something that a user would do:

    sig = sourmash.load_one_signature(utils.get_test_data("genome-s12.fa.gz.sig"),
                                      ksize=30,
                                      select_moltype='dna')
    mins = sig.minhash.get_mins()
    mins = {k: 1 for k in mins}
    
    new_mh = sig.minhash.copy_and_clear()
    new_mh.track_abundance = True
    new_mh.set_abundances(mins)

    I will say yes, because seemed intuitive when I did it (and found the bug).

  2. If you have a minhash WITH abundances, and then set track_abundance = False, it should still work (but dropping the abundances) instead of throwing an error.

  3. If you have a minhash WITHOUT abundance, and then set track_abundance = True, it should throw an error (since we have no idea what the abundance of the hashes already there were).
    Caveat: if the minhash is empty, then allow it. This is especially useful with

    mh = MinHash(1, 4, track_abundance=False)
    new_mh = mh.copy_and_clear()
    new_mh.track_abundance = True

    (and was the use case that triggered this bug)......

And thanks @taylorreiter for helping figure out the behaviors for each assumption =]

@luizirber luizirber changed the title [WIP] Bug: segfault with set_abundances Bug: segfault with set_abundances Oct 18, 2019
@luizirber
Copy link
Member Author

Ready for review and merge @ctb @olgabot

Copy link
Contributor

@ctb ctb left a comment

Choose a reason for hiding this comment

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

LGTM!

@ctb ctb merged commit 926a22c into master Oct 18, 2019
@luizirber luizirber deleted the bug_set_abundance branch October 19, 2019 00:18
@luizirber luizirber mentioned this pull request Oct 22, 2019
5 tasks
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.

2 participants