Opened 3 weeks ago

Closed 3 weeks ago

#27461 closed defect (fixed)

Windows: cast between incompatible function types in main

Reported by: teor Owned by: teor
Priority: Medium Milestone: Tor: 0.3.4.x-final
Component: Core Tor/Tor Version: Tor: 0.2.2.23-alpha
Severity: Normal Keywords: 035-must, 034-must, 034-backport, 033-backport, 032-backport, 029-backport
Cc: mikeperry Actual Points:
Parent ID: #27389 Points:
Reviewer: Sponsor:

Description

x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I..  -I../src/ext -Isrc/ext -I../src/ext/trunnel -I../src/trunnel -I../src/common -Isrc/common -I../src/ext/trunnel -I../src/trunnel -I../src/or -Isrc/or -DSHARE_DATADIR="\"/mingw64/share\"" -DLOCALSTATEDIR="\"/mingw64/var\"" -DBINDIR="\"/mingw64/bin\"" -I../src -I../src/common  -I/c/OpenSSL-Win64/include  -IC:/msys64/mingw64/include  -g -O2 -fasynchronous-unwind-tables -Wall -fno-strict-aliasing -Waddress -Warray-bounds -Wdate-time -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicated-cond -Wextra -Wfloat-conversion -Wignored-attributes -Wimplicit-fallthrough -Winit-self -Wlogical-op -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wnormalized=nfkc -Wnull-dereference -Woverlength-strings -Woverride-init -Wshadow -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wshift-overflow=2 -Wsizeof-array-argument -Wstrict-overflow=1 -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wswitch-bool -Wsync-nand -Wtrampolines -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable=2 -Wunused-local-typedefs -Wvariadic-macros -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wnested-externs -Wbad-function-cast -Wswitch-enum -Waggregate-return -Wpacked -Wunused -Wunused-parameter  -Wold-style-definition -Wmissing-declarations -Werror -MT src/or/main.o -MD -MP -MF $depbase.Tpo -c -o src/or/main.o ../src/or/main.c &&\
...
bash.exe : ../src/or/main.c: In function 'tor_run_main':
At line:2 char:5
+     & $commandPath $args 2>&1
+     ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (../src/or/main....'tor_run_main'::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
../src/or/main.c:4215:28: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(DWORD)' {aka 'int (*)(long unsigned int)'} [-Werror=cast-function-type]
     PSETDEP setdeppolicy = (PSETDEP)GetProcAddress(hMod,
                            ^

https://ci.appveyor.com/project/teor2345/tor/build/1.0.138/job/691be5b3uror0sok#L1146

Child Tickets

Change History (6)

comment:1 Changed 3 weeks ago by teor

Status: assignedneeds_revision

SetDEPPolicy is only supported on 32-bit Windows:
https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-setprocessdeppolicy

64-bit Windows defines _WIN32 and _WIN64:
https://stackoverflow.com/questions/2989810/which-cross-platform-preprocessor-defines-win32-or-win32-or-win32

(HeapSetInformation is supported on 32-bit and 64-bit:
https://docs.microsoft.com/en-us/windows/desktop/api/heapapi/nf-heapapi-heapsetinformation )

I am running a build to see if disabling SetDEPPolicy on 64-bit Windows resolves this issue.

My branch windows-dep-32-bit has diagnostics, this fix, and the #27460 fix, but no changes files:

comment:2 Changed 3 weeks ago by teor

Summary: Appveyor: cast between incompatible function types in mainWindows: cast between incompatible function types in main

comment:3 Changed 3 weeks ago by nickm

We talked about this in #tor-dev -- casting FARPROC through 'void (*)()' is probably the answer.

comment:4 in reply to:  3 Changed 3 weeks ago by teor

Replying to nickm:

We talked about this in #tor-dev -- casting FARPROC through 'void (*)()' is probably the answer.

In this specific case, I think we can stop calling the function on 64-bit Windows, because it will never work there.

comment:5 Changed 3 weeks ago by teor

Keywords: 033-backport 032-backport 029-backport added
Status: needs_revisionneeds_review
Version: Tor: 0.3.4.1-alphaTor: 0.2.2.23-alpha

Please see my branches bug27463-029 and bug27463-032 on ​https://github.com/teor2345/tor.git

The 032 branch fixes a minor merge conflict due to an #endif comment.

The CI is here, but it will fail Appveyor until all the children of #27389 are merged:

The passing CI for all the #27389 fixes on 0.3.4 is here:

comment:6 Changed 3 weeks ago by nickm

Resolution: fixed
Status: needs_reviewclosed

I think you meant bug27461-029 and bug27461-032 -- I merged those.

Note: See TracTickets for help on using tickets.