uniform_int_distribution misbehaves if the range exceeds the range of the underlying rng_engine
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- backend
Research direction
Start at lib/github.com/diku-dk/cpprandom/random.fut lines 486-487, focusing on the loop that computes secure_max for uniform_int_distribution. Reproduce the supplied program and confirm that the distribution terminates when the requested range exceeds the underlying rng range, without leaving the distribution unbalanced.
Written by the indexing model from the issue text.
Description
For example, this program will not terminate:
import "lib/github.com/diku-dk/cpprandom/random"
module rng = minstd_rand
module dist = uniform_int_distribution u32 rng
let main (seed: i32) =
let r = rng.rng_from_seed [seed]
in dist.rand (rng.min,rng.max+1) r
The problem is this loop where it tries to ensure that the distribution is not unbalanced. If the range is too great, then secure_max becomes 0, and the loop becomes infinite.
- Dominant language
- Futhark
- Stars
- 4
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
bug customer-eng Durable Agents Inngest status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
integration: elevenlabs
Difficulty 1/5 Under an hour Newbie friendliness 88/100
home-assistant/core#182944 · 1 comment ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vicharanashala/fln#563 ·