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

fix stylecheck for BiggestUInt #99

Merged
merged 4 commits into from
Oct 10, 2024
Merged

fix stylecheck for BiggestUInt #99

merged 4 commits into from
Oct 10, 2024

Conversation

metagn
Copy link
Contributor

@metagn metagn commented Oct 10, 2024

As described in nim-lang/Nim#24269, stylecheck has a bug where it doesn't check the usage of symbols from the standard library. The tests for this library enable --styleCheck:error, so the style for stdlib symbols is fixed. In this library the only mismatching usage seems to be BiggestUInt.

@tersec
Copy link
Contributor

tersec commented Oct 10, 2024

[NimScript] exec: nim cpp  --styleCheck:usages --styleCheck:error --verbosity:0 --hints:off --outdir:build --nimcache:build/nimcache -f -d:nimOldCaseObjects  --threads:off --mm:refc -r tests/test_all
/home/runner/work/nim-json-serialization/nim-json-serialization/json_serialization/stew/results.nim(11, 7) Warning: `stew/results` is now available as `import results` via the `results` Nimble package; results is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/json_serialization/stew/results.nim(13, 1) Warning: results is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(360, 34) Warning: [] is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(361, 34) Warning: [] is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(362, 34) Warning: [] is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(363, 34) Warning: [] is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(364, 34) Warning: [] is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(365, 34) Warning: [] is deprecated [Deprecated]
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_serialization.nim(308, 1) template/generic instantiation of `executeReaderWriterTests` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(334, 8) template/generic instantiation of `suite` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(355, 5) template/generic instantiation of `test` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1128, 24) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1132, 26) template/generic instantiation of `failingOnExceptions` from here
/home/runner/.nimble/pkgs2/serialization-0.2.2-8cd7d369b8e128106c1978b5bae42fe56689d880/serialization/testing/generic_suite.nim(366, 34) Warning: [] is deprecated [Deprecated]
lexer test suite ......................... (0.00s)
Json read/write tests .. (0.00s)
Json generic roundtrip tests ....... (0.17s)
toJson tests .............................................................................. (0.01s)
Custom parser tests .... (0.00s)
Test JsonFlavor ....... (0.00s)
Custom iterators ... (0.00s)
Public parser ..................... (0.01s)
Parse to runtime dynamic structure ... (0.00s)
Test line col ......... (0.00s)
Traceback (most recent call last)
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1152) test_reader
/home/runner/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1086) runDirect
/home/runner/work/nim-json-serialization/nim-json-serialization/tests/test_reader.nim(152) runTest`gensym202
/home/runner/work/nim-json-serialization/nim-json-serialization/nim/lib/system/comparisons.nim(304) ==
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)
Error: execution of an external program failed: '/home/runner/work/nim-json-serialization/nim-json-serialization/build/test_all'

It's a C++ backend-only phenomenon.

Apparently https://github.com/status-im/nim-json-serialization/actions/runs/11107010807/job/30856615404 from last week (main master CI run) worked fine.

It's not this PR, for sure -- I git cloned master and the same thing happens.

@metagn
Copy link
Contributor Author

metagn commented Oct 10, 2024

I'm guessing it's related to status-im/nim-unittest2@11f7cff @arnetheduck

The var T iterator seems to be causing it, I added a workaround

@tersec
Copy link
Contributor

tersec commented Oct 10, 2024

JsonReader basic test ...Traceback (most recent call last)
/tmp/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1152) test_reader
/tmp/.nimble/pkgs2/unittest2-0.2.3-6936b4e4676c9b37537d93f31cb8fc46f4ebaacb/unittest2.nim(1086) runDirect
/tmp/nim-json-serialization/tests/test_reader.nim(152) runTest`gensym701
/tmp/nim2010/lib/system/comparisons.nim(304) ==
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault

Tried both refc and ORC, it's the same in both. And it's 100% repeatable, not a flaky memory corruption. Still investigating.

But it is C++-only. With C:

JsonReader basic test ....... (0.00s)
[Summary] 7 tests run (0.00s): 7 OK, 0 FAILED, 0 SKIPPED

@metagn
Copy link
Contributor Author

metagn commented Oct 10, 2024

Opened Nim bug nim-lang/Nim#24274

@tersec
Copy link
Contributor

tersec commented Oct 10, 2024

I'm guessing it's related to status-im/nim-unittest2@11f7cff @arnetheduck

The var T iterator seems to be causing it, I added a workaround

Seems reasonable. Prefer links to upstream Nim issues so in the future it's not a mystery (yes, git blame, but that leaves intent ambiguous) why the code does something odd.

Less critical in test code where can just try changing something and if it works it works, but, still useful.

@metagn
Copy link
Contributor Author

metagn commented Oct 10, 2024

Added comment that links to the Nim issue, is it good enough?

@tersec
Copy link
Contributor

tersec commented Oct 10, 2024

Added comment that links to the Nim issue, is it good enough?

Sure, yeah. Now to see if it fixes CI.

@tersec tersec merged commit 9110cc8 into status-im:master Oct 10, 2024
18 checks passed
Araq pushed a commit to nim-lang/Nim that referenced this pull request Oct 11, 2024
fixes #24269, refs #20095

Instead of checking the package of the *used sym* to determine whether a
stylecheck should trigger, we check the package of the lineinfo instead.
Before #20095 this checked for the current compilation context module
instead which caused issues with generic procs, but the lineinfo should
more closely match the AST.

I figured this might cause issues with includes etc but the foreign
package test specifically tests for an include and passes, so maybe the
package determining logic accounts for this already. This still might
not be the correct logic, I'm not too familiar with the package handling
in the compiler.

Package PRs, both merged:

- json_rpc: status-im/nim-json-rpc#226
- json_serialization:
status-im/nim-json-serialization#99
narimiran pushed a commit to nim-lang/Nim that referenced this pull request Oct 11, 2024
fixes #24269, refs #20095

Instead of checking the package of the *used sym* to determine whether a
stylecheck should trigger, we check the package of the lineinfo instead.
Before #20095 this checked for the current compilation context module
instead which caused issues with generic procs, but the lineinfo should
more closely match the AST.

I figured this might cause issues with includes etc but the foreign
package test specifically tests for an include and passes, so maybe the
package determining logic accounts for this already. This still might
not be the correct logic, I'm not too familiar with the package handling
in the compiler.

Package PRs, both merged:

- json_rpc: status-im/nim-json-rpc#226
- json_serialization:
status-im/nim-json-serialization#99

(cherry picked from commit aaf6c40)
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