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 leak in test_mem_protect_map_ptr. (#1682) #1684

Merged
merged 1 commit into from
Aug 15, 2022
Merged

Fix leak in test_mem_protect_map_ptr. (#1682) #1684

merged 1 commit into from
Aug 15, 2022

Conversation

relapids
Copy link
Contributor

This fixes a memory leak in test_mem reported by leak sanitizer. See #1682 for details.

@wtdcode
Copy link
Member

wtdcode commented Aug 15, 2022

Thanks, could be merged once CI is green

@relapids
Copy link
Contributor Author

Strange. There is a failure in the CI, but it seems to be unrelated to my change (in a totally different test, when my change is very narrowly scoped to a single test case):

2: Test command: D:\a\unicorn\unicorn\test_arm.exe
2: Test timeout computed to be: 10000000
2: Test test_arm_nop...                            [ OK ]
2: Test test_arm_thumb_sub...                      [ OK ]
2: Test test_armeb_sub...                          [ OK ]
2: Test test_armeb_be8_sub...                      [ OK ]
2: Test test_arm_thumbeb_sub...                    [ OK ]
2: Test test_arm_thumb_ite...                      [ OK ]
2: Test test_arm_m_thumb_mrs...                    [ OK ]
2: Test test_arm_m_control...                      [ OK ]
2: Test test_arm_m_exc_return...                   [ OK ]
2: Test test_arm_und32_to_svc32...                 [ OK ]
2: Test test_arm_usr32_to_svc32...                 [ OK ]
2: Test test_arm_v8...                             [ OK ]
2: Test test_arm_thumb_smlabb...                   [ OK ]
2: Test test_arm_not_allow_privilege_escalation... [ OK ]
2: Test test_arm_mrc...                            [ OK ]
2: Test test_arm_hflags_rebuilt...                 [ OK ]
2: Test test_arm_mem_access_abort...               [ OK ]
2: Test test_arm_read_sctlr...                     [ OK ]
2: Test test_arm_be_cpsr_sctlr...                  [ FAILED ]
2:   Unhandled SEH exception... failed
2:     Exception code:    0xc0000005
2:     Exception address: 0x77d7fd5c
2: Test test_arm_switch_endian...                  [ OK ]
2: Test test_armeb_ldrb...                         [ OK ]
2:   Access violation.
2: FAILED: 1 of 21 unit tests has failed.
 2/12 Test  #2: test_arm .........................***Failed    0.36 sec
test 3
      Start  3: test_arm64

Is this test known to be flakey? It doesn't reproduce for me locally (using the same platform and toolchain).

relapids@relapids-win1 MINGW32 /e/Dev/unicorn/build
$ cmake --build . --target test
[0/1] Running tests...Test project E:/Dev/unicorn/build
      Start  1: test_x86
 1/12 Test  #1: test_x86 .........................   Passed    1.32 sec
      Start  2: test_arm
 2/12 Test  #2: test_arm .........................   Passed    0.22 sec
      Start  3: test_arm64
 3/12 Test  #3: test_arm64 .......................   Passed    0.08 sec
      Start  4: test_m68k
 4/12 Test  #4: test_m68k ........................   Passed    0.01 sec
      Start  5: test_mips
 5/12 Test  #5: test_mips ........................   Passed    0.05 sec
      Start  6: test_sparc
 6/12 Test  #6: test_sparc .......................   Passed    0.01 sec
      Start  7: test_ppc
 7/12 Test  #7: test_ppc .........................   Passed    0.04 sec
      Start  8: test_riscv
 8/12 Test  #8: test_riscv .......................   Passed    0.16 sec
      Start  9: test_s390x
 9/12 Test  #9: test_s390x .......................   Passed    0.01 sec
      Start 10: test_tricore
10/12 Test #10: test_tricore .....................   Passed    0.01 sec
      Start 11: test_mem
11/12 Test #11: test_mem .........................   Passed    0.10 sec
      Start 12: test_ctl
12/12 Test #12: test_ctl .........................   Passed    0.08 sec

100% tests passed, 0 tests failed out of 12

Total Test time (real) =   2.11 sec
relapids@relapids-win1 MINGW32 /e/Dev/unicorn/build
$ ./test_arm
Test test_arm_nop...                            [ OK ]
Test test_arm_thumb_sub...                      [ OK ]
Test test_armeb_sub...                          [ OK ]
Test test_armeb_be8_sub...                      [ OK ]
Test test_arm_thumbeb_sub...                    [ OK ]
Test test_arm_thumb_ite...                      [ OK ]
Test test_arm_m_thumb_mrs...                    [ OK ]
Test test_arm_m_control...                      [ OK ]
Test test_arm_m_exc_return...                   [ OK ]
Test test_arm_und32_to_svc32...                 [ OK ]
Test test_arm_usr32_to_svc32...                 [ OK ]
Test test_arm_v8...                             [ OK ]
Test test_arm_thumb_smlabb...                   [ OK ]
Test test_arm_not_allow_privilege_escalation... [ OK ]
Test test_arm_mrc...                            [ OK ]
Test test_arm_hflags_rebuilt...                 [ OK ]
Test test_arm_mem_access_abort...               [ OK ]
Test test_arm_read_sctlr...                     [ OK ]
Test test_arm_be_cpsr_sctlr...                  [ OK ]
Test test_arm_switch_endian...                  [ OK ]
Test test_armeb_ldrb...                         [ OK ]
SUCCESS: All unit tests have passed.

@wtdcode
Copy link
Member

wtdcode commented Aug 15, 2022

Nvm, this is a known Github runner bug. I disabled the wrong test before....

@wtdcode wtdcode merged commit c9d0f86 into unicorn-engine:dev Aug 15, 2022
@wtdcode
Copy link
Member

wtdcode commented Aug 15, 2022

Thanks & welcome!

@relapids relapids deleted the test_mem_leak branch August 16, 2022 07:19
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