Skip to content

MAINT: random: Follow-up to PR 14458. #14465

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

Closed
wants to merge 1 commit into from

Conversation

WarrenWeckesser
Copy link
Member

  • The comment about casting to long is no longer relevant.
  • The conversion of the arrays to int64 immediately before calling
    discrete_broadcast_iii is no longer necessary, because they are
    created as int64 arrays.

* The comment about casting to long is no longer relevant.
* The conversion of the arrays to int64 immediately before calling
  `discrete_broadcast_iii` is no longer necessary, because they are
  created as int64 arrays.
@rkern
Copy link
Member

rkern commented Sep 9, 2019 via email

@seberg
Copy link
Member

seberg commented Sep 9, 2019

OK, I am fine with that. If we specifically do not fix this, I suppose we should add it to the notes section (assuming we do not support a bugs section, I am not sure) in the documentation.

@seberg
Copy link
Member

seberg commented Sep 9, 2019

Unless this is a bug in a branch that would (practically) crash before? In which case fixing it does not matter.

@WarrenWeckesser
Copy link
Member Author

@rkern wrote

If this is a regression from 1.16, we can also restore 1.16 results.

The bug reported in #14457 is a regression from 1.16. The fix in #14458 fixes the bug, but also appears to introduce a change in behavior on systems where a C long int is 32 bits for inputs that are outside the range of a 32 bit integer.

@ahaldane
Copy link
Member

I think it is fairly clear there is no NEP-19 problem here:

  1. This is a regression, as the problematic code worked in 1.15, but does near-infinite hang now.
  2. This fixes a potential segfault, as the bug involved dereferencing an int32 with an int64 pointer.
  3. Arguably this does not affect the rng-stream at all. Rather, it affects the parsing of the input args to the function, so that the function returned the wrong number of samples or out-of-bounds values, and so should not have passed any downstream tests anyway.

@ahaldane
Copy link
Member

Because of the delicacy of our back-compat guarantees on mtrand, it may be worth adding a release note though, even though I don't think we are breaking code that did anything useful before. (I checked: inputting args > 2**32 gave OverflowError before on 32-bit).

The note can go in doc/release/upcoming_changes/14465.changes.rst, mentioning that the args to hypergeometric are now treated as int64 on 32bit systems (or similar, however you think it should be described).

@WarrenWeckesser
Copy link
Member Author

Because of the delicacy of our back-compat guarantees on mtrand, it may be worth adding a release note though, even though I don't think we are breaking code that did anything useful before.

Pretty clearly, gh-14458 did not change any useful behavior. If we want to be severely strict about not changing any behavior, however, we could revert gh-14458, and make the one-line fix that I mentioned in the comments to that PR. Then there would be no need for any mention in the release notes.

@charris
Copy link
Member

charris commented Sep 10, 2019

Just to make sure, 1.16.x also works?

@WarrenWeckesser
Copy link
Member Author

@charris, the bug reported in #14457 was introduced in 1.17, so there should be no need to touch 1.16.x.

@charris
Copy link
Member

charris commented Sep 10, 2019

I don't think it is worth hassling over the new behavior. If an error was previously raised it is unlikely that anyone was depending on that behavior, but it might be good to have a note in case someone runs a new program on an old release.

@ahaldane
Copy link
Member

Confirmed that 1.16.5 works, it gives an overflow error only (no bug).

@rkern
Copy link
Member

rkern commented Sep 11, 2019

I'll allow it since it's incidentally fixing a 1.17 regression (which crashes, to boot), but a similar enhancement would not fly otherwise.

@mattip
Copy link
Member

mattip commented Sep 12, 2019

@WarrenWeckesser could you add a release note which includes the changes in both this PR and gh-14458

@WarrenWeckesser
Copy link
Member Author

My preferred change is actually reverting gh-14558 and fixing the original, actual bug. I'm closing this PR in favor of #14490.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants