Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler warning: xxxx called on pointer returned from a mismatched allocation function #10085

Closed
floppym opened this issue Apr 16, 2024 · 6 comments · Fixed by #10086
Closed

Comments

@floppym
Copy link
Contributor

floppym commented Apr 16, 2024

When building FreeRDP on Gentoo Linux with GCC 13.2.1_p20240210, the following warnings appear:

winpr/libwinpr/file/generic.c:928:9: warning: ‘FindClose’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
winpr/libwinpr/comm/comm.c:1346:9: warning: ‘CloseHandle’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
winpr/libwinpr/clipboard/synthetic_file.c:1109:25: warning: ‘CloseHandle’ called on a pointer to an unallocated object ‘18446744073709551615’ [-Wfree-nonheap-object]
libfreerdp/core/orders.c:3998:33: warning: ‘free_cache_bitmap_v3_order’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/core/orders.c:4011:33: warning: ‘free_cache_color_table_order’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/planar.c:1750:17: warning: ‘freerdp_bitmap_planar_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/interleaved.c:738:9: warning: ‘bitmap_interleaved_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/progressive.c:2634:9: warning: ‘progressive_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/rfx.c:345:9: warning: ‘rfx_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/nsc.c:366:9: warning: ‘nsc_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/clear.c:1172:9: warning: ‘clear_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
libfreerdp/codec/yuv.c:254:9: warning: ‘yuv_context_free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
winpr/libwinpr/file/test/TestFileFindFirstFile.c:101:9: warning: ‘FindClose’ called on a pointer to an unallocated object ‘18446744073709551615’ [-Wfree-nonheap-object]
winpr/libwinpr/utils/test/TestStream.c:127:9: warning: ‘Stream_Free’ called on unallocated object ‘staticStream’ [-Wfree-nonheap-object]
libfreerdp/gdi/test/TestGdiCreate.c:127:17: warning: ‘free’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
@akallabeth
Copy link
Member

@floppym

  1. which version did you compile? I can´t reproduce here on fedora 39 with 3.5.0
  2. I hope this was a test compile? -DBUILD_TESTING=ON must not be used for packaging as it changes API/ABI (exposes everyting to allow unit tests of internals, ...)

@akallabeth
Copy link
Member

@floppym ok, managed to find the reason. (mostly forgotten pragma to silence the warnings, but a few actual issues in unit tests too)

@akallabeth akallabeth added this to the next-3.0 milestone Apr 17, 2024
@akallabeth akallabeth linked a pull request Apr 17, 2024 that will close this issue
@floppym
Copy link
Contributor Author

floppym commented Apr 17, 2024

which version did you compile? I can´t reproduce here on fedora 39 with 3.5.0

This happened both with 3.5.0 and tip of master.

I hope this was a test compile? -DBUILD_TESTING=ON must not be used for packaging as it changes API/ABI (exposes everyting to allow unit tests of internals, ...)

Yes, this was a build with testing enabled. Here's the full cmake command:

cmake -C /x/portage/net-misc/freerdp-9999/work/freerdp-9999_build/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -Wno-dev -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DBUILD_TESTING=ON -DCHANNEL_URBDRC=ON -DWITH_AAD=OFF -DWITH_ALSA=ON -DWITH_CCACHE=OFF -DWITH_CLIENT=ON -DWITH_CLIENT_SDL=ON -DWITH_SAMPLE=OFF -DWITH_CUPS=ON -DWITH_DEBUG_ALL=OFF -DWITH_MANPAGES=ON -DWITH_FFMPEG=ON -DWITH_FREERDP_DEPRECATED_COMMANDLINE=ON -DWITH_SWSCALE=ON -DWITH_CAIRO=OFF -DWITH_DSP_FFMPEG=ON -DWITH_FUSE=ON -DWITH_GSTREAMER_1_0=ON -DWITH_JPEG=ON -DWITH_KRB5=OFF -DWITH_NEON=OFF -DWITH_OPENH264=OFF -DWITH_OSS=OFF -DWITH_PCSC=OFF -DWITH_PKCS11=OFF -DWITH_PULSE=ON -DWITH_SERVER=ON -DWITH_LIBSYSTEMD=ON -DWITH_UNICODE_BUILTIN=OFF -DWITH_VALGRIND_MEMCHECK=OFF -DWITH_X11=ON -DWITH_XINERAMA=OFF -DWITH_XV=ON -DWITH_WAYLAND=ON -DWITH_WEBVIEW=OFF -DWITH_WINPR_TOOLS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/x/portage/net-misc/freerdp-9999/work/freerdp-9999_build/gentoo_toolchain.cmake /x/portage/net-misc/freerdp-9999/work/freerdp-9999

@floppym
Copy link
Contributor Author

floppym commented Apr 17, 2024

Full build log for reference.
build-log.txt

@eli-schwartz
Copy link

@floppym

  1. I hope this was a test compile? -DBUILD_TESTING=ON must not be used for packaging as it changes API/ABI (exposes everyting to allow unit tests of internals, ...)

This means it is impossible to test that the software works when packaging for a Linux distro. Very unfortunate.

Wouldn't it make more sense to e.g. build an object library and link both the unittests and the installable library to the object library?

@akallabeth
Copy link
Member

@floppym

  1. I hope this was a test compile? -DBUILD_TESTING=ON must not be used for packaging as it changes API/ABI (exposes everyting to allow unit tests of internals, ...)

This means it is impossible to test that the software works when packaging for a Linux distro. Very unfortunate.

Wouldn't it make more sense to e.g. build an object library and link both the unittests and the installable library to the object library?

well, pull requests welcome, but the effort is wasted time and adds quite some complexity to the build system without any meaningful gain.
if you insist on running these tests just compile it twice, once with tests, once without (more or less the same result like your suggestion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants