#5551(undetermined:new): av_bsf_send_packet can't take ownership on not reference-counted packets
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets -------------------------------------+------------------------------------- Reporter: mrlika | Type: defect Status: new | Priority: normal Component: | Version: undetermined | unspecified Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Because it doesn't know how to release it. And caller also doesn't know when to delete the packet passed to black-box algorithm. For not reference-counted packets it is more correct to create referenced- counted copy of the packet and leave ownership to the caller. For example av_grow_packet h264_mp4toannexb and h265_mp4toannexb already call av_grow_packet on input packets that just overwrites pkt->data field with newly allocated buffer for not reference-counted packets. It leads to memory leak. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Changes (by mrlika): * version: unspecified => git-master * component: undetermined => avcodec -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:1> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by gjdfgh): Simple: don't pass non-refcounted packets to these APIs. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:2> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by mrlika): Replying to [comment:2 gjdfgh]:
Simple: don't pass non-refcounted packets to these APIs.
Yes it is simple but not obvious unless you investigate the source code. And in this case it is better to validate input packets for reference- countness. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:3> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by gjdfgh): Maybe it should be better documented. Still, "taking ownership" implies the user can't access the packet after passing it to the API. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:4> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by mrlika): I see the following ways to fix this: 1) Restrict to use the API with not reference-counted packets by updating documentation and\or adding asserts validation for reference-countness. 2) Create referenced-counted copy of not reference-counted packets and leave ownership to the caller. Update documentation. 3) Change API to always leave paket ownership to the caller. Update documentation. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:5> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by mrlika): And latst variant: 0) Do not touch anything Do you have any thoughts on this? -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:6> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#5551: av_bsf_send_packet can't take ownership on not reference-counted packets ------------------------------------+----------------------------------- Reporter: mrlika | Owner: Type: defect | Status: closed Priority: normal | Component: avcodec Version: git-master | Resolution: fixed Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Changes (by mkver): * status: new => closed * resolution: => fixed Comment: Since ed1f08bfb5500340463e630290360609a90d2886, a copy of the data of non- refcounted packets is made, i.e. your second option has been implemented. And h264/hevc_mp4toannexb called (and call) av_grow_packet() on the output packet, not the input packet. So there is no danger of memleaks by this. -- Ticket URL: <https://trac.ffmpeg.org/ticket/5551#comment:7> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg