There are several motivations to enable ctor/dtor support:
1. ASan. This is not just about my wine-asan work, this is important for @bernhardu's PE asan work as well. The compiler generates ctors that poisons memory around global variables so misuses of them can be caught. This is the same both of our implementations of ASan.
2. Building third-party codebases against wine's CRT. This is not necessary for mingw-gcc or llvm-mingw, but the MSVC frontend of clang is another option for cross-compiling to Windows. However right now that requires Windows SDK. Bringing wine CRT to the point of being functional enough will give us another option. Could be useful for things like Proton.
3. (Controversial) Many dlls perform init/deinit tasks in `DllMain`. Some of them might benefit from a conversion to ctor/dtor.
Since nothing in wine uses ctor/dtor right now, this change shouldn't have any impact by itself.
--
v5: msvcrt: Run ctors and dtors from mainCRTStartup.
winecrt0: Run ctors and dtors from DllMainCRTStartup.
https://gitlab.winehq.org/wine/wine/-/merge_requests/9265
Streams hold a reference to the source, but this reference should not be taken until `Start()` is called because freeing the media source depends on release in `Shutdown()` of the stream's reference to the source. We could create the streams in `media_source_create()` and take source refs for them in `Start()`, but that's potentially confusing and fragile.
Streams can persist after the media source is destroyed. In that case, they cannot access the source object and it should be released and set to null. Windows behaviour is to release references to the source in `Shutdown()`. If we don't do this and a buggy app were to leak a stream object, the media source object would also leak and `wg_parser_destroy()` would not be called.
--
v9: mf/tests: Fix object leaks caused by the test source and stream.
mf/session: Shut down both the sink activate object and the media sink if present.
winegstreamer: Release stream references to the media source in Shutdown().
winegstreamer: Do not create MF stream objects until the media source is started.
mf/tests: Add some checks for session object leakage.
mfplat/tests: Test video stream release after media source release.
mfplat/tests: Add more media source refcount checks.
https://gitlab.winehq.org/wine/wine/-/merge_requests/6783