Comments (8)
Sorry I can't reproduce this problem. The thread_local variable works correctly on my simple test program. Can you provide a code snippet that causes this problem?
from memorymodulepp.
I integrated MMPP into a larger build, cannot provide a small repro now.
There is a.EXE it uses import lib to a b.DLL what links MMPP as a static lib. MMPP lib built crt Debug DLL, /EHa x64.
b.DLL (crt debug dll, /EHa, x64) has a thread_local struct WorkData. In the init section inside b.DLL there is a new std::stread(threadWork,...)
At the very beginning of the threadWork(), the thread wants to access WorkData but crashes with access violation at 0x0000000000000330
There are 2 treads created before MMPP registers itself, that threads can access WorkData without crashing. After the registration, the first new std::thread has this issue.
VS2019
from memorymodulepp.
Please answer these questions to help me build the test program:
- Is MMPP linked to a.EXE or b.DLL?
- When is WorkData initialized?
- Is WorkData a structure or a pointer to a structure?
- Is threadWork created by a.EXE or b.DLL?
from memorymodulepp.
- MMPP linked to the b.DLL.
2.-3. WorkData is a thread_local struct:
thread_local RMTLSDATA g_WorkData;
It is automatically initialized in every thread at the 1st reference to it by the CRT (I guess)
b.dll!RMTLSDATA::RMTLSDATA() Line 84 C++
b.dll!`dynamic initializer for 'g_WorkData''() Line 188 C++
[External Code]
- threadWork created by b.DLL
from memorymodulepp.
If MMPP is statically linked, how did you create the threadWork thread before initializing MMPP and make it run?
from memorymodulepp.
in the b.DLL:
initbDll()
{
pThreadData = new THREAD_DATA;
.
.
hthreadWork = new std::thread(threadWork, pThreadData);
.
}
static unsigned __stdcall threadWork(void *lpParam)
{
// read access violation 0x0000000000000215 <-- always a small number
int a = g_WorkData.a;
}
// if I do not link MMPP.lib to the b.DLL everything works.
// the program calls MMPP api first time later
from memorymodulepp.
When MMPP is not initialized, in the 1st worker thread:
00007FF91708A510 push rdi
00007FF91708A512 sub rsp,40h
if (g_pWorkData == NULL)
00007FF91708A516 mov eax,110h
00007FF91708A51B mov eax,eax
00007FF91708A51D mov ecx,dword ptr [_tls_index (07FF9173357C0h)] <--- tls index looks good
00007FF91708A523 mov rdx,qword ptr gs:[58h] <---- rdx looks real address
00007FF91708A52C mov rcx,qword ptr [rdx+rcx*8]
00007FF91708A530 cmp qword ptr [rax+rcx],0
00007FF91708A535 jne GetRmTLSData+85h (07FF91708A595h)
later, MMPP initialized next new thread(worker 2nd thread) --> and at same code, rdx 0
from memorymodulepp.
Hi! Could you reproduce the issue?
from memorymodulepp.
Related Issues (20)
- TLS in libraries loaded with LoadLibrary is broken when using MemoryModulePP HOT 3
- 好像不能加载user32.dll HOT 7
- 导入表是否可以采用内存加载 HOT 1
- when dll memory loadlibrary dll will be crash! HOT 1
- Win7 SP1 64 位下 处理C++ 异常会导致奔溃 HOT 2
- 编译32位时报错,报错函数_RtlCompareMemory(Utils.cpp) HOT 1
- 在32位下,使用项目自带测试程序不成功 HOT 11
- 一些错误 HOT 9
- 两层内存加载情况下,Win7程序不能运行 (MemoryModule -> MemoryModulePP binary -> APP binary) HOT 6
- SetUnhandledExceptionFilter异常未处理 HOT 1
- 可以用来注入其他进程吗 HOT 1
- 程序静态链接该库后,程序内的LoadLibraryW调用会引发崩溃 HOT 3
- 作者厉害!原版的加载我的dll有问题,用你这个成功了,不过运行一段时间后断言失败 HOT 17
- 32位模式内存加载CoreFoundation失败 HOT 1
- Crash!!! HOT 3
- 帧不在模块中 HOT 11
- 链接器选项 /DYNAMICBASE:NO 引发的崩溃 HOT 1
- Go编译的DLL无法加载 HOT 1
- 加载_运行_释放_再加载_再运行,有很大几率报错:帧不在模块中 HOT 4
- 这句static PVOID _LdrpReleaseTlsEntry_ = (PVOID)~0,我不太懂什么意思 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memorymodulepp.