Garbage in debug output
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 283
- Forks
- 72
- Avg merge
- 27m
- Merged PRs (30d)
- 1
Description
When there is not enough video memory, often garbage can be seen in debug output, like this:
```
[h264_nvenc @ 0x7f9f50e48f40] InitializeEncoder failed: out of memory (10): R,̒z �H��D��
I��̀��K)4?�??��:��Ȃt��
��>�ٿ�z��{�J��1�
Error opening video encoder
```
It is produced in this function:
```c
static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err,
const char *error_string)
{
const char *desc;
const char *details = "(no details)";
int ret = nvenc_map_error(err, &desc);
#ifdef NVENC_HAVE_GETLASTERRORSTRING
NvencContext *ctx = avctx->priv_data;
NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs;
if (p_nvenc && ctx->nvencoder)
details = p_nvenc->nvEncGetLastErrorString(ctx->nvencoder);
#endif
av_log(avctx, AV_LOG_ERROR, "%s: %s (%d): %s\n", error_string, desc, err, details);
return ret;
}
```
Garbage is the pointer returned by `nvEncGetLastErrorString` function.
It looks like `nvEncGetLastErrorString` is not thread safe.
Potentially this could be vulnerability.
Given that use of this function is guarded by `NVENC_HAVE_GETLASTERRORSTRING` define, I think we should undefine it at configuration stage to disable it usage.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at nvenc_print_error and trace how NVENC_HAVE_GETLASTERRORSTRING is set during configuration. Check the configuration path and the debug-output behavior when encoder initialization fails for lack of video memory; done means the unsafe last-error-string path is disabled and no garbage appears in the logged error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100