Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

New Code in 1.6.4+ fails in VS2015 Release builds #81

Closed
sgodin opened this issue Jul 13, 2016 · 3 comments
Closed

New Code in 1.6.4+ fails in VS2015 Release builds #81

sgodin opened this issue Jul 13, 2016 · 3 comments

Comments

@sgodin
Copy link

sgodin commented Jul 13, 2016

pread.c

Uses code from http://stackoverflow.com/a/2390626/1392778 for static initialization of critical section. This get's optimised out for VS2015 release builds - see comments in the stack overflow article that must have appeared after the code was intergrated into GeoIP pread.c.

Here is the block of code from my fix:

#ifdef _MSC_VER

 #pragma section(".CRT$XCU",read)

 #define INITIALIZER2_(f,p)                                             \
    static void __cdecl f(void);                                        \
    __declspec(allocate(".CRT$XCU")) void(__cdecl * f ## _) (void) = f; \
    __pragma(comment(linker,"/include:" p #f "_"))                      \
    static void __cdecl f(void)
 #ifdef _WIN64
 #define INITIALIZER(f) INITIALIZER2_(f,"")
 #else
 #define INITIALIZER(f) INITIALIZER2_(f,"_")
 #endif
#elif defined(__GNUC__)

 #define INITIALIZER(f)                               \
    static void f(void) __attribute__((constructor)); \
    static void f(void)

#endif
@sgodin sgodin changed the title New Code in 1.6.4 fails in VS2015 Release builds New Code in 1.6.4+ fails in VS2015 Release builds Jul 13, 2016
@oschwald
Copy link
Member

oschwald commented Jul 13, 2016

Would you be willing to make the fix into a pull request?

@sgodin
Copy link
Author

sgodin commented Jul 13, 2016

Sorry I'm pegged right now - just wanted to find the quickest way to make you guys aware, and save some others from the agony of tracking this down. :)

Scott

Sent from my iPhone

On Jul 13, 2016, at 3:28 PM, Gregory Oschwald [email protected] wrote:

Would you be willing to make the fix into a PR?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@oschwald
Copy link
Member

@sgodin, thanks for letting us know.

@tpoechtrager, does this work for you? I think the original change was introduced in #47

oschwald added a commit that referenced this issue Oct 11, 2016
autarch added a commit that referenced this issue Oct 11, 2016
oschwald added a commit that referenced this issue Mar 29, 2017
1.6.10

* GeoIP_database_info now returns the full version string rather than
  incorrectly truncating it. GitHub #79.
* This API is now distributed with a small test copy of GeoIP.dat rather than
  a full copy.
* Fix issue where Visual Studio 2015 was optimizing out initialization code.
  Reported and fixed by Scott Godin. GitHub #81.
* Fix test/benchmark on Windows. Gisle Vanem. GitHub #75.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants