Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Thread Local Storage Exception Handler error

Featured Replies

Posted

I've add Thread Local Storage in C++ project but Exception Handler error,  What's the solution?

Win32Project14.rar

Your issue is how you are linking to the CRT, change to:

Multi-threaded Debug DLL (/MDd)

Edited by atom0s

  • Author

I want make portable executable so should compiled by (Multi-threaded (/MT))

The actual problem (most likely) is that you're using functions from MS CRT library - which gets initialized by code at EXE entrypoint. During TLS callback it's not initialized yet.

10 hours ago, Perplex said:

I want make portable executable so should compiled by (Multi-threaded (/MT))

Like I said, the way you are linking is preventing it from working properly. The CRT is loaded after TLS callbacks occur when you statically link to it. Meaning the calls and data you are trying to use are not ready yet. When you link dynamically to it, things are loaded as they are requested so you can use them anywhere. If you want to keep things portable, you need to avoid using CRT specific calls (for example in your case wprintf) within the TLS callback. You shouldn't be doing things like that in a TLS callback anyway, it is used to initialize data.

That's right. TLS callbacks are called very early in the loading process. Maybe not all things are initialized at this point. This depends on loading order e.g. of DLL's, etc. You should not do there any "big" things inside a TLS Callback.

It's nearly the same kind of problems as you should not do extensive things in DllMain().

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.