[Bug 40502] New: Global objects constructors fail when invoking standard libs

wine-bugs at winehq.org wine-bugs at winehq.org
Wed Apr 20 02:37:33 CDT 2016


https://bugs.winehq.org/show_bug.cgi?id=40502

            Bug ID: 40502
           Summary: Global objects constructors fail when invoking
                    standard libs
           Product: Wine
           Version: 1.8.1
          Hardware: x86
                OS: Linux
            Status: UNCONFIRMED
          Severity: major
          Priority: P2
         Component: winelib
          Assignee: wine-bugs at winehq.org
          Reporter: mirko.ortensi at gmail.com
      Distribution: ---

I managed to recompile and link my win32 application but at execution time, it
crashes because of a segmentation fault where memset (or the bare
printf("HELLO")) is invoked in the global object constructor (any call to
standard C library is enough to trigger the crash).

The global object is built in the stack, then it seems that at launch time my
object constructor is called before C Standard Library is ready.
Now, as a workaround I can declare a pointer to global object and instantiate
it in the main (tested, it works)...though...this is something I'd like to
avoid to keep the code as original as possible. Removing the global objects,
everything works like a charm.

As far as I understand, global object constructors are called after Wine
infrastructure is ready to go, though I have doubts now regarding C Standard
Library.
(Please check 8.3.3. Starting a Winelib process
https://www.winehq.org/docs/winedev-guide/x3172)

This code reproduces the error:

#include <stdio.h>

class Printer
{
public:
        Printer(){printf("HI\n");}
};


Printer p;

int main(void)
{
    return 0;
}

The issue is reproduced by this code linking to msvcrt:
wineg++ -mno-cygwin issue.cpp -o issue

Linking to system libs, this code does not reproduce the issue.
wineg++ issue.cpp -o issue

Now, in my code (pretty big software I am porting to Linux) I still need to
isolate root cause, issue is reproduced even linking against system libraries
(not Wine's msvcrt, then). Anyway, I think there's a bug somewhere when linking
to msvcrt even in this silly piece of code.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list