Modify

Ticket #1848 (closed Bugs: wontfix)

Opened 6 years ago

Last modified 6 years ago

Boost.Thread is incompatible with UPX

Reported by: Gordon Magnusson <gordon.magnusson@…> Owned by: anthonyw
Milestone: Boost 1.36.0 Component: thread
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:

Description

Programs using Boost.Thread can't be compressed with UPX ( http://upx.sourceforge.net). This is a regression from 1.34.1 (which UPX could compress) to 1.35.0 (which UPX can't compress). Example, with MinGW GCC 4.2.1 and statically-linked Boost.Thread 1.35.0:

C:\Temp>type foo.cpp
#include <iostream>
#include <ostream>
#include <boost/thread/thread.hpp>
using namespace std;
using namespace boost;

void foo() {
    cout << "foo()" << endl;
}

int main() {
    thread t(foo);
    t.join();
}

C:\Temp>g++ -Wall -Wextra foo.cpp -o foo.exe -lboost_thread

C:\Temp>foo
foo()

C:\Temp>upx --best foo.exe
                       Ultimate Packer for eXecutables
  Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007
UPX 3.02w       Markus Oberhumer, Laszlo Molnar & John Reiser   Dec 16th 2007

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
upx: foo.exe: CantPackException: TLS callbacks are not supported

Packed 1 file: 0 ok, 1 error.

Presumably, "TLS callbacks" are providing some feature.

  1. It would be nice if this was documented: what the feature is, why it requires TLS callbacks, and that they prevent UPX from working. (Some users might not figure out the connection here.)
  1. If some users could live without this feature (i.e. if the feature is not universally required for correctness), it would be nice to have a way to disable it, either by defining some macro before including the Boost.Thread headers or by building a special configuration of Boost.Thread.

It appears that TLS callbacks are being used to support thread exit handlers, but I don't know what they provide over Boost 1.34.1, or whether my program can live without them.

Attachments

Change History

comment:1 Changed 6 years ago by anthonyw

  • Status changed from new to closed
  • Resolution set to wontfix

TLS callbacks are indeed being used to support thread exit handlers. This allows thread-specific data to be cleaned up on threads launched outside of boost::thread. This has always been supported for those compilers that we knew how to (Mostly MSVC), and is now supported in gcc/mingw as well.

Thread-specific data that needs this cleanup is used by thread_specific_ptr, this_thread::get_id(), and at_thread_exit(). If you use any of these from a thread not managed by boost::thread, you need the cleanup, or you need to call on_thread_exit() from each of those threads before they finish.

Defining tss_cleanup_implemented in your main cpp file will prevent the automatic cleanup machinery being linked in, as your code is assumed to provide it. This should therefore allow your use of UPX.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.