-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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] Enable assertions when testing the stdlib in the CI #2687
Comments
… (#40083) [External] [stdlib] Fix incorrect number of elements in `StaticTuple` We could technically have a check at compile-time but I'm not sure it's worth the effort as `StaticTuple` is deprecated in favor of `InlineArray`. Related to #2687 Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2689 MODULAR_ORIG_COMMIT_REV_ID: b965330e55c49074b61d9603414c033580a9e096
[External] [stdlib] Fix wrong slice check in span Fix part of #2687 both the start and the end of span can be `len(original_string)`, that's not an issue. In the case where the start is equal to the lenght of th string, it just gives an empty span. This is similar to the slicing `my_string[:0]` which also gives an empty span. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2726 MODULAR_ORIG_COMMIT_REV_ID: 1e08d3d29352ae43b7e833d36f5a3acfa7ebe765
@JoeLoser I found all of them and made PRs for all fixables bugs. The final big bad boss is a segfault that happens when compiling I even got sometimes (I was spamming the command to build the test) this output:
I'll try to open an issue with a minimal reproducible example later on so that we can actually track this build segfault. |
… (#40083) [External] [stdlib] Fix incorrect number of elements in `StaticTuple` We could technically have a check at compile-time but I'm not sure it's worth the effort as `StaticTuple` is deprecated in favor of `InlineArray`. Related to modularml#2687 Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2689 MODULAR_ORIG_COMMIT_REV_ID: b965330e55c49074b61d9603414c033580a9e096
[External] [stdlib] Fix wrong slice check in span Fix part of modularml#2687 both the start and the end of span can be `len(original_string)`, that's not an issue. In the case where the start is equal to the lenght of th string, it just gives an empty span. This is similar to the slicing `my_string[:0]` which also gives an empty span. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2726 MODULAR_ORIG_COMMIT_REV_ID: 1e08d3d29352ae43b7e833d36f5a3acfa7ebe765
The blocker segfault is documented here: #2751 |
[External] [stdlib] Fix out of bounds access in `List.index()` Related to #2687 There were multiple bugs related to clipping there. Long story short, the behavior of `list.index()` in python is this one: given a `start` and `end`, python will look for the element in `my_list[start:end]` and report the result, (`start` is added to the result to give the index with respect to the original list). You can take a look at the description of the `index` method here: https://docs.python.org/3/tutorial/datastructures.html#more-on-lists Since there is slicing semantics applied to `start` and `end`, we should do multiple things: 1) default to the start and the end of the list 2) normalize negative values by doing `+ len(my_list)` 3) clip both start and end between `0` and `len(my_list)` The last step wasn't done correctly. Especially for the `stop` argument where the clipping was applied only when negative values were found (this caused the out of bounds bug in the tests). Effectively ```mojo return end if end > 0 else min(end + size, size) ``` is equivalent to ```mojo return end if end > 0 else end + size ``` since the min is applied only when `end <= 0`. So `end + size <= size` This test can cause some flakyness in our CI: `test_list_a.index(10, start=5, stop=50)` for a list of size 6. The stop was positive, so it was never clipped, thus too many values (out of bounds) were tried, causing some to match, sometimes. Another bug was that because of this condition, `end = 0` means "check until the end of the list" while in python, with the slicing semantics, `end = 0` means "do nothing" (empty slice). ### TL;DR Multiple clipping bugs. Slicing semantics applied to `start` and `stop` now like in Python. No more flakyness in our CI. No more out of bounds access. Corresponding tests added. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2745 MODULAR_ORIG_COMMIT_REV_ID: 7bad2830dc41d96ae383fc4a8eac9ca3a69581de
…(#40303) [External] [stdlib] Fix wrong debug_assert condition in `InlineList` If the InlineList is of capacity N, then it's possible to initialize it with N values. It's the same as a regular List. Related to #2687 Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2744 MODULAR_ORIG_COMMIT_REV_ID: 8f5093eb1eb79591e9636f9a7a969037bab6dcd1
[External] [stdlib] Fix invalid code point check Related to #2687 See https://stackoverflow.com/questions/27415935/does-unicode-have-a-defined-maximum-number-of-code-points for the correct range. You can also use Python's `chr` function to make sure the range is correct Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2747 MODULAR_ORIG_COMMIT_REV_ID: e93765fdad9876ba4b7838194182bf72c5fb1c71
…D (#40375) [External] [stdlib] Fix incorrect number of variadic arguments in SIMD Fix part of #2687 by changing various SIMD tests that were neither passing `1` or `N` values in the construction of a `SIMD` type (i.e. ones that were passing `k` values where `1 < k < N`). Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2720 MODULAR_ORIG_COMMIT_REV_ID: 20baf2934b7d768523a412755e32ffbfb109c0fd
…str__` method (#40421) [External] [stdlib] Fix: Add null terminator to the buffer inside `__str__` method String really has a hard time working without this null terminator and I feel this PR is a step towards fixing #2687 without requirering controversial changes like the ones in #2691. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes #2787 MODULAR_ORIG_COMMIT_REV_ID: 95f438ebbb6e076fe6ffb79debf7cd4fd70248de
@JoeLoser Is the blocker still a problem or is there a work around? |
Yes the blocker is still a problem. In my PR #2718 I enable assertions in all unit tests except |
… (#40083) [External] [stdlib] Fix incorrect number of elements in `StaticTuple` We could technically have a check at compile-time but I'm not sure it's worth the effort as `StaticTuple` is deprecated in favor of `InlineArray`. Related to modularml#2687 Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2689 MODULAR_ORIG_COMMIT_REV_ID: b965330e55c49074b61d9603414c033580a9e096
[External] [stdlib] Fix wrong slice check in span Fix part of modularml#2687 both the start and the end of span can be `len(original_string)`, that's not an issue. In the case where the start is equal to the lenght of th string, it just gives an empty span. This is similar to the slicing `my_string[:0]` which also gives an empty span. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2726 MODULAR_ORIG_COMMIT_REV_ID: 1e08d3d29352ae43b7e833d36f5a3acfa7ebe765
[External] [stdlib] Fix out of bounds access in `List.index()` Related to modularml#2687 There were multiple bugs related to clipping there. Long story short, the behavior of `list.index()` in python is this one: given a `start` and `end`, python will look for the element in `my_list[start:end]` and report the result, (`start` is added to the result to give the index with respect to the original list). You can take a look at the description of the `index` method here: https://docs.python.org/3/tutorial/datastructures.html#more-on-lists Since there is slicing semantics applied to `start` and `end`, we should do multiple things: 1) default to the start and the end of the list 2) normalize negative values by doing `+ len(my_list)` 3) clip both start and end between `0` and `len(my_list)` The last step wasn't done correctly. Especially for the `stop` argument where the clipping was applied only when negative values were found (this caused the out of bounds bug in the tests). Effectively ```mojo return end if end > 0 else min(end + size, size) ``` is equivalent to ```mojo return end if end > 0 else end + size ``` since the min is applied only when `end <= 0`. So `end + size <= size` This test can cause some flakyness in our CI: `test_list_a.index(10, start=5, stop=50)` for a list of size 6. The stop was positive, so it was never clipped, thus too many values (out of bounds) were tried, causing some to match, sometimes. Another bug was that because of this condition, `end = 0` means "check until the end of the list" while in python, with the slicing semantics, `end = 0` means "do nothing" (empty slice). ### TL;DR Multiple clipping bugs. Slicing semantics applied to `start` and `stop` now like in Python. No more flakyness in our CI. No more out of bounds access. Corresponding tests added. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2745 MODULAR_ORIG_COMMIT_REV_ID: 7bad2830dc41d96ae383fc4a8eac9ca3a69581de
…(#40303) [External] [stdlib] Fix wrong debug_assert condition in `InlineList` If the InlineList is of capacity N, then it's possible to initialize it with N values. It's the same as a regular List. Related to modularml#2687 Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2744 MODULAR_ORIG_COMMIT_REV_ID: 8f5093eb1eb79591e9636f9a7a969037bab6dcd1
[External] [stdlib] Fix invalid code point check Related to modularml#2687 See https://stackoverflow.com/questions/27415935/does-unicode-have-a-defined-maximum-number-of-code-points for the correct range. You can also use Python's `chr` function to make sure the range is correct Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2747 MODULAR_ORIG_COMMIT_REV_ID: e93765fdad9876ba4b7838194182bf72c5fb1c71
…D (#40375) [External] [stdlib] Fix incorrect number of variadic arguments in SIMD Fix part of modularml#2687 by changing various SIMD tests that were neither passing `1` or `N` values in the construction of a `SIMD` type (i.e. ones that were passing `k` values where `1 < k < N`). Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2720 MODULAR_ORIG_COMMIT_REV_ID: 20baf2934b7d768523a412755e32ffbfb109c0fd
…str__` method (#40421) [External] [stdlib] Fix: Add null terminator to the buffer inside `__str__` method String really has a hard time working without this null terminator and I feel this PR is a step towards fixing modularml#2687 without requirering controversial changes like the ones in modularml#2691. Co-authored-by: Gabriel de Marmiesse <gabriel.demarmiesse@datadoghq.com> Closes modularml#2787 MODULAR_ORIG_COMMIT_REV_ID: 95f438ebbb6e076fe6ffb79debf7cd4fd70248de
[External] [stdlib] Enable assertions in unit tests Change the default mode of running the standard library unit tests to run with `-D MOJO_ENABLE_ASSERTIONS`, i.e. assertions enabled. Not all of the tests work with assertions, so appropriate issues are filed to track that work along with a new substitution, `%bare-mojo` for running without assertions enabled. Related to #2687 Closes #2718 MODULAR_ORIG_COMMIT_REV_ID: ddc68f1fd7ae786abe135f254264157d264caa93
Bug description
Currently, there are out-of-bounds access bugs in the stdlib's tests. We don't know yet if the bugs are coming from the stdlib or their tests but it's not really acceptable, especially since we have a mechanisme in the Mojo language to detect them (MOJO_ENABLE_ASSERTIONS=1)
We should:
See #2677 (comment) for the background about this issue.
Steps to reproduce
Run the unit tests with
MOJO_ENABLE_ASSERTIONS=1
System information
The text was updated successfully, but these errors were encountered: