Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Soft Works <softworkz@hotmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] av_fopen_utf8 and cross-DLL CRT object sharing issue on Windows
Date: Mon, 9 May 2022 10:53:07 +0000
Message-ID: <DM8P223MB03655DA29EC123BEB880D2F1BAC69@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <f38f662d-6c23-80bd-e0a5-3cf4ba2a97d@martin.st>



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Martin Storsjö
> Sent: Monday, May 9, 2022 12:47 PM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] av_fopen_utf8 and cross-DLL CRT object
> sharing issue on Windows
> 
> On Mon, 9 May 2022, Soft Works wrote:
> 
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Martin Storsjö
> >> Sent: Monday, May 9, 2022 11:42 AM
> >> To: FFmpeg development discussions and patches <ffmpeg-
> >> devel@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] av_fopen_utf8 and cross-DLL CRT object
> >> sharing issue on Windows
> >>
> >> On Mon, 9 May 2022, Soft Works wrote:
> >>
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>> Martin Storsjö
> >>>> Sent: Sunday, May 8, 2022 10:12 PM
> >>>> To: FFmpeg development discussions and patches <ffmpeg-
> >>>> devel@ffmpeg.org>
> >>>> Subject: Re: [FFmpeg-devel] av_fopen_utf8 and cross-DLL CRT
> object
> >>>> sharing issue on Windows
> >>>>
> >>>> On Sat, 7 May 2022, Soft Works wrote:
> >>>>
> >>>>> Ah yes of course, thanks for the explanation. I still wonder
> >> whether
> >>>>> there aren't any other issues when multiple CRTs are being used?
> >>>>>
> >>>>> Or are the file IO APIs the only "weak" point with regards to
> >>>>> multiple CRTs being used?
> >>>>
> >>>> In the case of ffmpeg, yes.
> >>>>
> >>>> For generic library design, you'd have an issue anywhere where
> you
> >>>> pass
> >>>> CRT resources around - file descriptors from open, FILE*, and
> >> indeed
> >>>> as
> >>>> you mentioned - allocating and freeing memory with malloc/free in
> >>>> different DLLs. But as long as the library design is such that
> you
> >>>> don't
> >>>> hand over ownership of allocations and don't pass such objects
> >> across
> >>>> DLL
> >>>> boundaries, there's no issue.
> >>>
> >>> Yup, understood. I thought there would be many more, but I
> realized
> >>> that those "many more" I thought about are all C++ things, not C.
> >>>
> >>> So, putting this all together, I agree that the existence of
> >>> av_fopen_utf8 (as a public API!) is rather unfortunate. To make
> this
> >>> consistent, it would be necessary to provide av_ equivalents to
> >>> all the file APIs as well (but there are quite a few).
> >>
> >> Indeed - for the fopen family of functions, we would need to
> duplicate
> >> all
> >> of fopen/fclose/fprintf/fwrite/fputs and whatever might happen to
> be
> >> used.
> >> So that doesn't seem worthwhile.
> >>
> >>> So I wonder whether it wouldn't make sense to deprecate this as
> >>> a public API member?
> >>
> >> I agree that it probably would be the best way forward, to
> deprecate
> >> it as
> >> a public API, without any suggested replacement. A quick googling
> >> didn't
> >> find any real use of the function outside of ffmpeg itself, I only
> >> found
> >> hits in language wrappers (which try to map every single function
> to
> >> the
> >> other language). So I think that would have minimal impact on
> others.
> >>
> >> We could then adjust the function to be a header inline function
> >> (which
> >> takes care of the duplication into all libraries), just like the
> other
> >> wchar<->utf8 functions we have in libavutil/wchar_filename.h, so we
> >> safely
> >> could use them within fftools too.
> >
> > This would sound good to me, so when nobody objects, that would be
> > the way to go IMO.
> > And in case that somebody would object, the second best option could
> > be to deprecate it for Windows only (while api differences per
> platform
> > are surely not desirable, it might still be justified for a niche
> case
> > like this).
> >
> > BTW - could it be that your original patch missed to apply the same
> for
> > libavfilter?
> 
> At the time, there were no uses of the per-library duplicated
> functions
> within libavfilter, so I didn't add it there. If we add usage of them,

There are 9 uses already and my patch adds 6. 

> would indeed need to add the same duplication logic there too. (But if
> we
> make the function entirely inline in headers, as opposed to
> avpriv_open/ff_open, we don't need to do that for use of that
> function.)

Yup.

Thanks,
softworkz
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-05-09 10:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 12:47 Martin Storsjö
2022-05-07  4:22 ` Soft Works
2022-05-07  4:32   ` Andreas Rheinhardt
2022-05-07  5:02     ` Soft Works
2022-05-08 20:11       ` Martin Storsjö
2022-05-09  0:30         ` Soft Works
2022-05-09  9:41           ` Martin Storsjö
2022-05-09 10:38             ` Soft Works
2022-05-09 10:47               ` Martin Storsjö
2022-05-09 10:53                 ` Soft Works [this message]
2022-05-08 20:01   ` Martin Storsjö
2022-05-09  0:28     ` Soft Works
2022-05-09  9:36       ` Martin Storsjö
2022-05-09 10:59         ` Soft Works

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8P223MB03655DA29EC123BEB880D2F1BAC69@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \
    --to=softworkz@hotmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git