Opened 8 years ago

Closed 8 years ago

#10697 closed Bugs (worksforme)

Boost coroutine leaks windows.h into global namespace

Reported by: jarmo.tiitto@… Owned by: olli
Milestone: Boost 1.57.0 Component: coroutine
Version: Boost 1.56.0 Severity: Problem
Keywords: windows.h coroutine namespace Cc: any

Description

I was surprised that file "boost/coroutine/windows/protected_stack_allocator.hpp" from coroutine library from boost release 1.56.0 version just insanely includes windows.h in public header without any protection from the header leaking into global namespace severely polluting it.

Because of this 'boost/coroutine/protected_stack_allocator.hpp' is rendered UNUSABLE/BROKEN on windows (all compilers) and namespace pollution may apply to Unix/Linux as well. The feature is released very hacky and unfinished way by having such code issues.

To fix this cleanly simplest thing would be to contain and move windows.h (or other platform depend) inclusion into a .cpp file which is compiled.

The file "boost/coroutine/<platform>/protected_stack_allocator.hpp" would contain function prototypes something like:

void * allocate_protected_memory(size_t)
void free_protected_memory(void *)

in boost::detail namespace to just allocate protected stack memory area (no original pointer adjusting) and the protected_stack_allocator template that uses the function prototypes. The compiled file then implements the prototypes and the platform depend stuff would be hidden from library user.

Change History (2)

in reply to:  description comment:1 by olli, 8 years ago

Replying to jarmo.tiitto@…:

I was surprised that file "boost/coroutine/windows/protected_stack_allocator.hpp" from coroutine library from boost release 1.56.0 version just insanely includes windows.h in public header without any protection from the header leaking into global namespace severely polluting it.

? windows.h is a system header from Windows, it is legitmi to include it in windows-related code - I don't know why you say 'insanely' etc.

Because of this 'boost/coroutine/protected_stack_allocator.hpp' is rendered UNUSABLE/BROKEN on windows (all compilers) and namespace pollution may apply to Unix/Linux as well. The feature is released very hacky and unfinished way by having such code issues.

it is protected by '#if defined(BOOST_WINDOWS)' - why should this pollute Unix/Linux? if you think the library is hackish - than don't use it

Last edited 8 years ago by olli (previous) (diff)

comment:2 by olli, 8 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.