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

array: add test code #35

Merged
merged 8 commits into from
Aug 5, 2024
Merged

array: add test code #35

merged 8 commits into from
Aug 5, 2024

Conversation

nokute78
Copy link
Contributor

This patch is to

  • Add test code for cfl_array
  • Add cfl_array_size to iterate array to hide internal of cfl_array from user.

Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78
Copy link
Contributor Author

Oh, the test indicated removing APIs had a bug.

https://github.com/fluent/cfl/actions/runs/5034666306/jobs/9029600025?pr=35#step:4:100

 Test remove_by_index...                         =================================================================
  ==271==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x607000000128,0x607000000148) and [0x607000000130, 0x607000000150) overlap
  ==271==WARNING: invalid path to external symbolizer!
  ==271==WARNING: Failed to use and restart external symbolizer!
      #0 0x4976c4  (/github/workspace/tests/cfl-test-array+0x4976c4)
      #1 0x4cd32b  (/github/workspace/tests/cfl-test-array+0x4cd32b)
      #2 0x4cc0b8  (/github/workspace/tests/cfl-test-array+0x4cc0b8)
      #3 0x4cb779  (/github/workspace/tests/cfl-test-array+0x4cb779)
      #4 0x4ca9d3  (/github/workspace/tests/cfl-test-array+0x4ca9d3)
      #5 0x4c9cc2  (/github/workspace/tests/cfl-test-array+0x4c9cc2)
      #6 0x7f329bfd5d09  (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
      #7 0x41e2f9  (/github/workspace/tests/cfl-test-array+0x41e2f9)
  
  0x607000000128 is located 40 bytes inside of 80-byte region [0x607000000100,0x607000000150)
  allocated by thread T0 here:
      #0 0x4984e2  (/github/workspace/tests/cfl-test-array+0x4984e2)
      #1 0x4ccd64  (/github/workspace/tests/cfl-test-array+0x4ccd64)
      #2 0x4cbf8b  (/github/workspace/tests/cfl-test-array+0x4cbf8b)
      #3 0x4cb779  (/github/workspace/tests/cfl-test-array+0x4cb779)
      #4 0x4ca9d3  (/github/workspace/tests/cfl-test-array+0x4ca9d3)
      #5 0x4c9cc2  (/github/workspace/tests/cfl-test-array+0x4c9cc2)
      #6 0x7f329bfd5d09  (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
  
  0x607000000130 is located 48 bytes inside of 80-byte region [0x607000000100,0x607000000150)
  allocated by thread T0 here:
      #0 0x4984e2  (/github/workspace/tests/cfl-test-array+0x4984e2)
      #1 0x4ccd64  (/github/workspace/tests/cfl-test-array+0x4ccd64)
      #2 0x4cbf8b  (/github/workspace/tests/cfl-test-array+0x4cbf8b)
      #3 0x4cb779  (/github/workspace/tests/cfl-test-array+0x4cb779)
      #4 0x4ca9d3  (/github/workspace/tests/cfl-test-array+0x4ca9d3)
      #5 0x4c9cc2  (/github/workspace/tests/cfl-test-array+0x4c9cc2)
      #6 0x7f329bfd5d09  (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
  
  SUMMARY: AddressSanitizer: memcpy-param-overlap (/github/workspace/tests/cfl-test-array+0x4976c4) 
  ==271==ABORTING
  Test remove_by_reference...                     =================================================================
  ==272==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x607000000128,0x607000000148) and [0x607000000130, 0x607000000150) overlap
  ==272==WARNING: invalid path to external symbolizer!
  ==272==WARNING: Failed to use and restart external symbolizer!
      #0 0x4976c4  (/github/workspace/tests/cfl-test-array+0x4976c4)
      #1 0x4cd32b  (/github/workspace/tests/cfl-test-array+0x4cd32b)
      #2 0x4cd4d8  (/github/workspace/tests/cfl-test-array+0x4cd4d8)
      #3 0x4cc816  (/github/workspace/tests/cfl-test-array+0x4cc816)
      #4 0x4cb779  (/github/workspace/tests/cfl-test-array+0x4cb779)
      #5 0x4ca9d3  (/github/workspace/tests/cfl-test-array+0x4ca9d3)
      #6 0x4c9cc2  (/github/workspace/tests/cfl-test-array+0x4c9cc2)
      #7 0x7f329bfd5d09  (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
      #8 0x41e2f9  (/github/workspace/tests/cfl-test-array+0x41e2f9)
  
  0x607000000128 is located 40 bytes inside of 80-byte region [0x607000000100,0x607000000150)
  allocated by thread T0 here:
      #0 0x4984e2  (/github/workspace/tests/cfl-test-array+0x4984e2)
      #1 0x4ccd64  (/github/workspace/tests/cfl-test-array+0x4ccd64)
      #2 0x4cc66b  (/github/workspace/tests/cfl-test-array+0x4cc66b)
      #3 0x4cb779  (/github/workspace/tests/cfl-test-array+0x4cb779)
      #4 0x4ca9d3  (/github/workspace/tests/cfl-test-array+0x4ca9d3)
      #5 0x4c9cc2  (/github/workspace/tests/cfl-test-array+0x4c9cc2)
      #6 0x7f329bfd5d09  (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
  
  0x607000000130 is located 48 bytes inside of 80-byte region [0x607000000100,0x607000000150)
  allocated by thread T0 here:
      #0 0x4984e2  (/github/workspace/tests/cfl-test-array+0x4984e2)
      #1 0x4ccd64  (/github/workspace/tests/cfl-test-array+0x4ccd64)
      #2 0x4cc66b  (/github/workspace/tests/cfl-test-array+0x4cc66b)
      #3 0x4cb779  (/github/workspace/tests/cfl-test-array+0x4cb779)
      #4 0x4ca9d3  (/github/workspace/tests/cfl-test-array+0x4ca9d3)
      #5 0x4c9cc2  (/github/workspace/tests/cfl-test-array+0x4c9cc2)
      #6 0x7f329bfd5d09  (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
  
  SUMMARY: AddressSanitizer: memcpy-param-overlap (/github/workspace/tests/cfl-test-array+0x4976c4) 
  ==272==ABORTING
  FAILED: 2 of 4 unit tests have failed.
  
  
  83% tests passed, 1 tests failed out of 6

memcpy doesn't allow overlap.

Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78
Copy link
Contributor Author

nokute78 commented May 20, 2023

I fixed array API by using memmove.

https://linux.die.net/man/3/memcpy

The memcpy() function copies n bytes from memory area src to memory area dest.
The memory areas must not overlap. Use memmove(3) if the memory areas do overlap.

tests/array.c Outdated Show resolved Hide resolved
tests/array.c Outdated Show resolved Hide resolved
tests/array.c Outdated Show resolved Hide resolved
@leonardo-albertovich
Copy link
Contributor

The changes I requested are not limited to the particular instances where I added them, please make those improvements globally.

Signed-off-by: Takahiro Yamashita <[email protected]>
Signed-off-by: Takahiro Yamashita <[email protected]>
@leonardo-albertovich
Copy link
Contributor

I fixed array API by using memmove.

https://linux.die.net/man/3/memcpy

The memcpy() function copies n bytes from memory area src to memory area dest.
The memory areas must not overlap. Use memmove(3) if the memory areas do overlap.

Yes, that's totally legit!

Signed-off-by: Takahiro Yamashita <[email protected]>
Signed-off-by: Takahiro Yamashita <[email protected]>
@edsiper
Copy link
Member

edsiper commented Feb 16, 2024

@leonardo-albertovich is this approved ?

@edsiper edsiper merged commit a1c6096 into fluent:master Aug 5, 2024
22 checks passed
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.

3 participants