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

Use binary representation in assert crash log, cleanup in crash log #1410

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

enjoy-binbin
Copy link
Member

Change assert crash log to also use binary representation like 5bdd72b.
And do not print the password in assert crash log like 56eef6f.

In addition, for 5bdd72b, we will print '"argv"',
because originally the code would print a '', and sdscatrepr will add an extra "",
so now removing the extra '' here.

Extract the getArgvReprString method and clean up the code a bit.

Examples:

debug assert "\x00abc"

before:
client->argv[0] = "debug" (refcount: 1)
client->argv[1] = "assert" (refcount: 1)
client->argv[2] = "" (refcount: 1)

after:
client->argv[0] = "debug" (refcount: 1)
client->argv[1] = "assert" (refcount: 1)
client->argv[2] = "\x00abc" (refcount: 1)

debug panic "\x00abc"

before:
argc: '3'
argv[0]: '"debug"'
argv[1]: '"panic"'
argv[2]: '"\x00abc"'

after:
argc: 3
argv[0]: "debug"
argv[1]: "panic"
argv[2]: "\x00abc"

Change assert crash log to also use binary representation like 5bdd72b.
And do not print the password in assert crash log like 56eef6f.

In addition, for 5bdd72b, we will print '"argv"',
because originally the code would print a '', and sdscatrepr will add an extra "",
so now removing the extra '' here.

Extract the getArgvReprString method and clean up the code a bit.

Examples:
```
debug assert "\x00abc"

before:
client->argv[0] = "debug" (refcount: 1)
client->argv[1] = "assert" (refcount: 1)
client->argv[2] = "" (refcount: 1)

after:
client->argv[0] = "debug" (refcount: 1)
client->argv[1] = "assert" (refcount: 1)
client->argv[2] = "\x00abc" (refcount: 1)

debug panic "\x00abc"

before:
argc: '3'
argv[0]: '"debug"'
argv[1]: '"panic"'
argv[2]: '"\x00abc"'

after:
argc: 3
argv[0]: "debug"
argv[1]: "panic"
argv[2]: "\x00abc"
```

Signed-off-by: Binbin <[email protected]>
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 70.81%. Comparing base (b09db3e) to head (8e642ac).
Report is 3 commits behind head on unstable.

Files with missing lines Patch % Lines
src/debug.c 0.00% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1410      +/-   ##
============================================
- Coverage     70.83%   70.81%   -0.03%     
============================================
  Files           118      118              
  Lines         63561    63558       -3     
============================================
- Hits          45026    45011      -15     
- Misses        18535    18547      +12     
Files with missing lines Coverage Δ
src/debug.c 53.36% <0.00%> (+0.18%) ⬆️

... and 15 files with indirect coverage changes

Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crash report looks better with this change. Just I'm not sure about stack vs heap allocation in crash handler code.

@enjoy-binbin enjoy-binbin merged commit 1ba85d0 into valkey-io:unstable Dec 9, 2024
48 checks passed
@enjoy-binbin enjoy-binbin deleted the crash_log branch December 9, 2024 16:37
vudiep411 pushed a commit to Autxmaton/valkey that referenced this pull request Dec 15, 2024
…alkey-io#1410)

Change assert crash log to also use binary representation like 5bdd72b.
And do not print the password in assert crash log like 56eef6f.

In addition, for 5bdd72b, we will print '"argv"',
because originally the code would print a '', and sdscatrepr will add an extra "",
so now removing the extra '' here.

Extract the getArgvReprString method and clean up the code a bit.

Examples:
```
debug assert "\x00abc"

before:
client->argv[0] = "debug" (refcount: 1)
client->argv[1] = "assert" (refcount: 1)
client->argv[2] = "" (refcount: 1)

after:
client->argv[0] = "debug" (refcount: 1)
client->argv[1] = "assert" (refcount: 1)
client->argv[2] = "\x00abc" (refcount: 1)

debug panic "\x00abc"

before:
argc: '3'
argv[0]: '"debug"'
argv[1]: '"panic"'
argv[2]: '"\x00abc"'

after:
argc: 3
argv[0]: "debug"
argv[1]: "panic"
argv[2]: "\x00abc"
```

Signed-off-by: Binbin <[email protected]>
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