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

Segfault on accessing variant.samples #2400

Closed
hyanwong opened this issue Jul 12, 2022 · 2 comments · Fixed by #2401
Closed

Segfault on accessing variant.samples #2400

hyanwong opened this issue Jul 12, 2022 · 2 comments · Fixed by #2401
Labels
bug Something isn't working
Milestone

Comments

@hyanwong
Copy link
Member

hyanwong commented Jul 12, 2022

This segfaults for me, and I think it does on CI too.

import msprime
ts = msprime.simulate(10, mutation_rate=1)
next(ts.variants()).samples
@hyanwong hyanwong added the bug Something isn't working label Jul 12, 2022
@benjeffery
Copy link
Member

⚠️ OUCH ⚠️
I can recreate this. Thankyou for finding it.

@benjeffery benjeffery added this to the Python 0.5.1 milestone Jul 12, 2022
@benjeffery
Copy link
Member

The iterator returned by ts.variant gives copies by default. tsk_variant_restricted_copy doesn't copy the samples. I think when copy was written (in March) it wasn't expected that the Python class would have a property to get the samples (in June), and they weren't needed as variant copies can not be decoded to a new site. As variant->samples is NULL on the copy Python crashes as it tries to build a numpy array.

Although tests were added when copy was added in 48c16df when the samples accessor was added in b97c6f1 there were no tests of the combination of copy.samples.

The fix here is to copy the samples in tsk_variant_restricted_copy, which sadly will make it a bit slower.

I'll do that tomorrow (and add the missing tests) with a fresh head and get out a point release.

Sorry, everyone! This is my (seg)fault!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants