Re: Sockets in a DLL, access violation
- From: jonharris7@xxxxxxxxx
- Date: 6 Jun 2006 12:25:31 -0700
New information: I don't believe it is a multiple thread problem. I
added a GetCurrentThreadId, and both the case that worked and the case
that didn't gave me the same thread ID. So I am stumped at this point.
Any other ideas?
Jon Harris wrote:
Yes, I have. I initially had a problem when I wasn't doing this with assertions
in attaching handles. When I added that code, the assertions went away, but the
access violation remains. I have verified that for the function call that gives
me the access violation, AFX_MANAGE_STATE is being executed.
--
Jon Harris
SPAM blocker in place:
Remove 99 (but leave 7) to reply
"Norbert Unterberg" <nunterberg@xxxxxxxxxxxxxxxxx> wrote in message
news:u0ZybFXiGHA.3408@xxxxxxxxxxxxxxxxxxxxxxx
Jon,
Have you added this code to the beginning of all our DLL exported functions?
AFX_MANAGE_STATE(AfxGetStaticModuleState());
Norbert
Jon Harris schrieb:
I have a DLL that opens a simple UDP socket and does basic operations. My
DLL is called from a 3rd party app that I neither have control over nor
source code for. Some calls work OK, but with others I can a unhandled
exception, access violation. I've seen the exception on ReceiveFrom, SendTo,
Close, etc. and in all cases it looks like the function calls had all good
parameters.
After doing a bunch of Googling and reading, it looks like the most common
cause of this is creating the socket in one thread and accessing it from
another. (The other common problem, a bug in MSVC 6 with MFC DLL as a static
linked library, shouldn't be an issue since I have the latest service pack
(SP 6) installed.) So I am suspecting a thread problem. However, as I
mentioned above, I am in a DLL and don't have control over the calling app,
so I can't confirm the thread issue and if I could, I'm not sure how to solve
it. So my questions are: 1) is there a way to tell if my DLL code is being
called from different threads? and 2) if so, how can I write my sockets code
in such a way as to survive being called from different threads?
My set-up is MSVC 6.0 SP6, Windows 2000, MFC 4.2 as a shared DLL. Any help
is appreciated!
.
- Follow-Ups:
- Re: Sockets in a DLL, access violation
- From: jonharris7
- Re: Sockets in a DLL, access violation
- References:
- Sockets in a DLL, access violation
- From: Jon Harris
- Re: Sockets in a DLL, access violation
- From: Norbert Unterberg
- Re: Sockets in a DLL, access violation
- From: Jon Harris
- Sockets in a DLL, access violation
- Prev by Date: Re: How to select No Button in AfxMessageBox
- Next by Date: Video on Client area
- Previous by thread: Re: Sockets in a DLL, access violation
- Next by thread: Re: Sockets in a DLL, access violation
- Index(es):
Relevant Pages
|