[FFmpeg-devel] configure: Assume MSVCRT when compiling with MingW

Submitted by Carl Eugen Hoyos on April 21, 2018, 8:43 p.m.

Details

Message ID CAB0OVGqM9BYvJFYoGRBiKASvFC-t9JLPLWcyUPtwinoY30yNqQ@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos April 21, 2018, 8:43 p.m.
Hi!

Attached patch is supposed to fix an old issue with debug messages and
a currently reported compilation warning that I believe also indicates
a possible abort() on Windows:
libavformat/hlsenc.c:1676:63: warning: unknown conversion type
character 's' in format
Patch untested.

Please review, Carl Eugen

Comments

Reino Wijnsma April 21, 2018, 10:53 p.m.
On 21-4-2018 22:43, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> Attached patch is supposed to fix an old issue with debug messages and
> a currently reported compilation warning that I believe also indicates
> a possible abort() on Windows:
> libavformat/hlsenc.c:1676:63: warning: unknown conversion type
> character 's' in format
> Patch untested.
>
> Please review, Carl Eugen
I'm hardly an expert, but I'm not sure this is a good idea.
After configuring FFmpeg summarizes:
[...]
C library                 msvcrt
[...]
This has always been "mingw64" before. And next:

$ make libavformat/hlsenc.o
CC      libavformat/hlsenc.o
In file included from ./libavutil/common.h:491:0,
                 from ./libavutil/avutil.h:296,
                 from ./libavutil/avassert.h:31,
                 from libavformat/hlsenc.c:36:
./libavutil/internal.h:250:10: fatal error: crtversion.h: No such file or directory
 #include <crtversion.h>
          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [ffbuild/common.mak:60: libavformat/hlsenc.o] Error 1

Also when I use the makefile it errors out right from the start:

CC      libavdevice/alldevices.o
In file included from ./libavutil/common.h:491:0,
                 from ./libavutil/avutil.h:296,
                 from ./libavutil/samplefmt.h:24,
                 from ./libavcodec/avcodec.h:31,
                 from ./libavformat/avformat.h:319,
                 from ./libavformat/internal.h:27,
                 from libavdevice/alldevices.c:23:
./libavutil/internal.h:250:10: fatal error: crtversion.h: No such file or directory
 #include <crtversion.h>
          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [ffbuild/common.mak:60: libavdevice/alldevices.o] Error 1

-- Reino
Carl Eugen Hoyos April 21, 2018, 11:02 p.m.
2018-04-22 0:53 GMT+02:00, Reino Wijnsma <rwijnsma@xs4all.nl>:
> On 21-4-2018 22:43, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> Attached patch is supposed to fix an old issue with debug messages and
>> a currently reported compilation warning that I believe also indicates
>> a possible abort() on Windows:
>> libavformat/hlsenc.c:1676:63: warning: unknown conversion type
>> character 's' in format
>> Patch untested.
>>
>> Please review, Carl Eugen
> I'm hardly an expert, but I'm not sure this is a good idea.
> After configuring FFmpeg summarizes:
> [...]
> C library                 msvcrt
> [...]
> This has always been "mingw64" before. And next:
>
> $ make libavformat/hlsenc.o
> CC      libavformat/hlsenc.o
> In file included from ./libavutil/common.h:491:0,
>                  from ./libavutil/avutil.h:296,
>                  from ./libavutil/avassert.h:31,
>                  from libavformat/hlsenc.c:36:
> ./libavutil/internal.h:250:10: fatal error: crtversion.h: No such file or
> directory

Thank you for testing.

Note that I believe the warning indicates a possible
crash on runtime.

Carl Eugen
Hendrik Leppkes April 21, 2018, 11:29 p.m.
On Sun, Apr 22, 2018 at 1:02 AM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2018-04-22 0:53 GMT+02:00, Reino Wijnsma <rwijnsma@xs4all.nl>:
>> On 21-4-2018 22:43, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>> Attached patch is supposed to fix an old issue with debug messages and
>>> a currently reported compilation warning that I believe also indicates
>>> a possible abort() on Windows:
>>> libavformat/hlsenc.c:1676:63: warning: unknown conversion type
>>> character 's' in format
>>> Patch untested.
>>>
>>> Please review, Carl Eugen
>> I'm hardly an expert, but I'm not sure this is a good idea.
>> After configuring FFmpeg summarizes:
>> [...]
>> C library                 msvcrt
>> [...]
>> This has always been "mingw64" before. And next:
>>
>> $ make libavformat/hlsenc.o
>> CC      libavformat/hlsenc.o
>> In file included from ./libavutil/common.h:491:0,
>>                  from ./libavutil/avutil.h:296,
>>                  from ./libavutil/avassert.h:31,
>>                  from libavformat/hlsenc.c:36:
>> ./libavutil/internal.h:250:10: fatal error: crtversion.h: No such file or
>> directory
>
> Thank you for testing.

To clarify: The C library flag controls both the build and runtime
environment, not only the runtime environment. Usually thats
identical, but in the case of mingw it is not, so extra care has to be
taken.

>
> Note that I believe the warning indicates a possible
> crash on runtime.
>

It would only crash if you use the security-enhanced versions of the
format functions (ie. with a _s suffix), which we obviously don't.
That particular code in hlsenc has always been very weird though,
maybe configure should just check support for that format code instead
of somehow probing that at runtime.

- Hendrik
Carl Eugen Hoyos April 21, 2018, 11:50 p.m.
2018-04-22 1:29 GMT+02:00, Hendrik Leppkes <h.leppkes@gmail.com>:
> On Sun, Apr 22, 2018 at 1:02 AM, Carl Eugen Hoyos <ceffmpeg@gmail.com>
> wrote:
>> 2018-04-22 0:53 GMT+02:00, Reino Wijnsma <rwijnsma@xs4all.nl>:
>>> On 21-4-2018 22:43, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>> Attached patch is supposed to fix an old issue with debug messages and
>>>> a currently reported compilation warning that I believe also indicates
>>>> a possible abort() on Windows:
>>>> libavformat/hlsenc.c:1676:63: warning: unknown conversion type
>>>> character 's' in format
>>>> Patch untested.
>>>>
>>>> Please review, Carl Eugen
>>> I'm hardly an expert, but I'm not sure this is a good idea.
>>> After configuring FFmpeg summarizes:
>>> [...]
>>> C library                 msvcrt
>>> [...]
>>> This has always been "mingw64" before. And next:
>>>
>>> $ make libavformat/hlsenc.o
>>> CC      libavformat/hlsenc.o
>>> In file included from ./libavutil/common.h:491:0,
>>>                  from ./libavutil/avutil.h:296,
>>>                  from ./libavutil/avassert.h:31,
>>>                  from libavformat/hlsenc.c:36:
>>> ./libavutil/internal.h:250:10: fatal error: crtversion.h: No such file or
>>> directory
>>
>> Thank you for testing.
>
> To clarify: The C library flag controls both the build and runtime
> environment, not only the runtime environment. Usually thats
> identical, but in the case of mingw it is not, so extra care has to be
> taken.
>
>>
>> Note that I believe the warning indicates a possible
>> crash on runtime.
>>
>
> It would only crash if you use the security-enhanced versions of the
> format functions (ie. with a _s suffix), which we obviously don't.

People repeatedly reported such crashes (they only happen
in rare cases because debug output and/or broken streams
are needed) - how did they change the functions?

Carl Eugen
Hendrik Leppkes April 22, 2018, 12:43 a.m.
On Sun, Apr 22, 2018 at 1:50 AM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2018-04-22 1:29 GMT+02:00, Hendrik Leppkes <h.leppkes@gmail.com>:
>> On Sun, Apr 22, 2018 at 1:02 AM, Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> wrote:
>>> 2018-04-22 0:53 GMT+02:00, Reino Wijnsma <rwijnsma@xs4all.nl>:
>>>> On 21-4-2018 22:43, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>>>>> Attached patch is supposed to fix an old issue with debug messages and
>>>>> a currently reported compilation warning that I believe also indicates
>>>>> a possible abort() on Windows:
>>>>> libavformat/hlsenc.c:1676:63: warning: unknown conversion type
>>>>> character 's' in format
>>>>> Patch untested.
>>>>>
>>>>> Please review, Carl Eugen
>>>> I'm hardly an expert, but I'm not sure this is a good idea.
>>>> After configuring FFmpeg summarizes:
>>>> [...]
>>>> C library                 msvcrt
>>>> [...]
>>>> This has always been "mingw64" before. And next:
>>>>
>>>> $ make libavformat/hlsenc.o
>>>> CC      libavformat/hlsenc.o
>>>> In file included from ./libavutil/common.h:491:0,
>>>>                  from ./libavutil/avutil.h:296,
>>>>                  from ./libavutil/avassert.h:31,
>>>>                  from libavformat/hlsenc.c:36:
>>>> ./libavutil/internal.h:250:10: fatal error: crtversion.h: No such file or
>>>> directory
>>>
>>> Thank you for testing.
>>
>> To clarify: The C library flag controls both the build and runtime
>> environment, not only the runtime environment. Usually thats
>> identical, but in the case of mingw it is not, so extra care has to be
>> taken.
>>
>>>
>>> Note that I believe the warning indicates a possible
>>> crash on runtime.
>>>
>>
>> It would only crash if you use the security-enhanced versions of the
>> format functions (ie. with a _s suffix), which we obviously don't.
>
> People repeatedly reported such crashes (they only happen
> in rare cases because debug output and/or broken streams
> are needed) - how did they change the functions?
>

This hlsenc thing is unrelated to any input data or any debug logging,
its always executed if you request the date-based filename scheme.
What you are referring to is probably related to using unsupported
format specifiers in av_log statements, which may end up in a custom
log callback that the user wrote, possibly using the secure printf
functions. But this is strftime.

Anyway nothing wrong with fixing this warning, but this was just not
the way to do it.

- Hendrik

Patch hide | download patch | download mbox

From 7a1ceb3c66c477edf83a29845efe42a52452b98f Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sat, 21 Apr 2018 22:37:02 +0200
Subject: [PATCH] configure: Assume MSVCRT when compiling with MingW.

Should fix several issues with format conversions unsupported on Windows
and a compilation warning:
libavformat/hlsenc.c:1676:63: warning: unknown conversion type character 's' in format
---
 configure |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index dee507c..ab2f490 100755
--- a/configure
+++ b/configure
@@ -5304,6 +5304,7 @@  probe_libc(){
             add_${pfx}cppflags -D__printf__=__gnu_printf__
         test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
             add_${pfx}cppflags -D_WIN32_WINNT=0x0600
+        eval ${pfx}libc_type=msvcrt
     elif test_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
          test_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
         eval ${pfx}libc_type=mingw32
@@ -5317,6 +5318,7 @@  probe_libc(){
             add_${pfx}cppflags -D_WIN32_WINNT=0x0600
         eval test \$${pfx_no_}cc_type = "gcc" &&
             add_${pfx}cppflags -D__printf__=__gnu_printf__
+        eval ${pfx}libc_type=msvcrt
     elif test_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
         eval ${pfx}libc_type=msvcrt
         if test_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
-- 
1.7.10.4