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

Refine the comment filter while calculating file percentage #4536

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

PeiweiHu
Copy link
Contributor

@PeiweiHu PeiweiHu commented Jun 6, 2024

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

The original code uses the symbol ; to filter the line like ; CALL XREF @ 0x808080 to avoid the addresses in comments affecting the calculation of file percentage. However, the appearance of ; in colorizing the code makes every line being filtered.

The following screenshot shows the file percentage without using tmux (which remains 0 before changing).

image

Test plan

CI is green.

Closing issues

closes #4518

@wargio
Copy link
Member

wargio commented Jun 6, 2024

@PeiweiHu maybe a screenshot can be useful for the changes.

@PeiweiHu
Copy link
Contributor Author

PeiweiHu commented Jun 6, 2024

@PeiweiHu maybe a screenshot can be useful for the changes.

Thank you. I already append a screenshot in the description. 😄

@XVilka
Copy link
Member

XVilka commented Jun 6, 2024

@PeiweiHu try also with the ASAN, then use p/P keys to switch between visual modes, sometimes it causes crashes (it was even before this PR though).

@XVilka
Copy link
Member

XVilka commented Jun 6, 2024

@PeiweiHu:

=================================================================
==74829==ERROR: AddressSanitizer: heap-use-after-free on address 0x631000000800 at pc 0x0001035d3cc4 bp 0x00016dde0e30 sp 0x00016dde05e0
READ of size 3 at 0x631000000800 thread T0 C D  E F  0123456789ABCDEF
    #0 0x1035d3cc0 in strdup+0x33c (libclang_rt.asan_osx_dynamic.dylib:arm64+0x4bcc0)
    #1 0x10b821794 in visual_refresh visual.c:3724c  ..@.............
    #2 0x10b83371c in rz_core_visual visual.c:3919e  ..........Z.....
    #3 0x10b772b70 in rz_cmd_call_parsed_args cmd_api.c:816..........
    #4 0x10b718c38 in handle_ts_arged_stmt cmd.c:3507    x2 0x0000000000000000     x3 0x0000000000000000
    #5 0x10b757ce4 in handle_ts_stmt cmd.c:511700000     x6 0x0000000000000000     x7 0x0000000000000000
    #6 0x10b717568 in handle_ts_statements cmd.c:5139   x10 0x0000000000000000    x11 0x0000000000000000
    #7 0x10b72fbac in core_cmd_tsrzcmd cmd.c:5286000    x14 0x0000000000000000    x15 0x0000000000000000
    #8 0x10b613fc4 in rz_core_cmd cmd.c:533400000000    x18 0x0000000000000000    x19 0x0000000000000000
    #9 0x10b4968cc in rz_core_prompt_exec core.c:1936   x22 0x0000000000000000    x23 0x0000000000000000
    #10 0x10b494eec in rz_core_prompt_loop core.c:1805  x26 0x0000000000000000    x27 0x0000000000000000
    #11 0x1025b5f14 in rz_main_rizin rizin.c:1447000    x30 0x0000000000000000    tmp 0x0000000000000000
    #12 0x19171e0dc  (<unknown module>)00000000000     lr 0x0000000000000000     sp 0x0000000000000000
    #13 0x78757ffffffffffc  (<unknown module>)000000    xzr 0x0000000000000000 pstate 0x0000000000000000
            ;-- main:
0x631000000800 is located 0 bytes inside of 65676-byte region [0x631000000800,0x63100001088c)
freed by thread T0 here:003a84:
    #0 0x1035da6f8 in realloc+0x78 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x526f8)
    #1 0x1029811d4 in palloc cons.c:715     stp   x28, x27, [sp, -0x60]!
    #2 0x102980cd8 in rz_cons_printf_list cons.c:1193, x25, [sp, 0x10]
    #3 0x102976a58 in rz_cons_printf cons.c:1219  x24, x23, [sp, 0x20]
    #4 0x10b6fc794 in rz_cmd_print_raw_colors_handler cmd_print.c:6454
    #5 0x10b7736b8 in rz_cmd_call_parsed_args cmd_api.c:816 [sp, 0x40]
    #6 0x10b718c38 in handle_ts_arged_stmt cmd.c:3507 lr, [sp, 0x50]
    #7 0x10b757ce4 in handle_ts_stmt cmd.c:5117   fp, sp, 0x50
    #8 0x10b717568 in handle_ts_statements cmd.c:5139 sp, 0x640
    #9 0x10b72fbac in core_cmd_tsrzcmd cmd.c:5286 x19, x1
    #10 0x10b686a10 in rz_core_cmd0 cmd.c:5434v   x20, x0
    #11 0x10b8216a4 in visual_refresh visual.c:371221, fp, 0x70
    #12 0x10b83371c in rz_core_visual visual.c:3919zr, [x21, 0x10]
    #13 0x10b772b70 in rz_cmd_call_parsed_args cmd_api.c:816-0x64]
    #14 0x10b718c38 in handle_ts_arged_stmt cmd.c:3507 [x21]
    #15 0x10b757ce4 in handle_ts_stmt cmd.c:5117  x8, sp, 0x20
    #16 0x10b717568 in handle_ts_statements cmd.c:5139[sp, 0x18]
    #17 0x10b72fbac in core_cmd_tsrzcmd cmd.c:5286w0, 0
    #18 0x10b613fc4 in rz_core_cmd cmd.c:5334.gt  0x100003ad4
    #19 0x10b4968cc in rz_core_prompt_exec core.c:1936.100007178       ;[1]
    #20 0x10b494eec in rz_core_prompt_loop core.c:1805section.3.__TEXT.__cstring    ; 0x100007a35
    #21 0x1025b5f14 in rz_main_rizin rizin.c:1447
    #22 0x19171e0dc  (<unknown module>)     mov   w0, 0
    #23 0x78757ffffffffffc  (<unknown module>)    setlocale            ;[2]
            0x100003ae4      80fa0150       adr   x0, str.bin_ls       ; 0x100007a36
previously allocated by thread T0 here:     nop                                                                                                                                                                 4.6%
    #0 0x1035da7f4 in calloc+0x78 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x527f4)
    #1 0x10298122c in palloc cons.c:702
    #2 0x102980cd8 in rz_cons_printf_list cons.c:1193
    #3 0x102976a58 in rz_cons_printf cons.c:1219
    #4 0x10b535808 in rz_core_fortune_print_random fortune.c:70
    #5 0x1025b5d4c in rz_main_rizin rizin.c:1427
    #6 0x19171e0dc  (<unknown module>)
    #7 0x78757ffffffffffc  (<unknown module>)

SUMMARY: AddressSanitizer: heap-use-after-free visual.c:3724 in visual_refresh
Shadow bytes around the buggy address:
  0x631000000580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x631000000600: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x631000000680: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x631000000700: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x631000000780: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x631000000800:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x631000000880: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x631000000900: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x631000000980: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x631000000a00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x631000000a80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==74829==ABORTING
zsh: abort      rizin /bin/ls

@XVilka XVilka merged commit 7297b56 into rizinorg:dev Jun 6, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visual mode percentage doesn't work
3 participants