Re: IOCP critical sections and mutexes



You might encounter a pure virtual call if you call a virtual function on a
just deleted object (in release mode it's not filled with garbage). But
stack shift also shows that you might be using a wrong pointer (or that
memory might be even reallocated to hold an object of different type).

"Alberto Demichelis" <AlbertoDemichelis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:F0926EBC-3AC8-4103-8F3A-E5DE707C67D1@xxxxxxxxxxxxxxxx
Hi all, I'm writing a server app based on a UDP protocol. I have to handle
a
large number of packets
per second so I'm using IOCP for handling my socket. Until this week, I
thought I'd nailed my IOCP
routines but I recently started some preliminary stress test on a new
server
machine and I'm getting
a strange crash that is driving me mad.

My scenario is simple, I have a single UDP socket, I spawn 2 threads per
processor and I have a maximum
concurrency in my CP set to 'number of processors'. I cap a max 2 read
requests per thread and max 5 write
requests queued per thread. My packets never go over 2k in size.
Each IO thread does very little work, just checks if the UDP packet is
actually a valid frame for my app
then pushes it in a queue that will be later processed by my main app
thread(is a realtime simulation).
The queue access is sycronized using a critical section(I'm also testing
with a mutex)

My crash happens when I push a packet in the queue that goes to the app.
The
thing that drives me crazy is that
only happens on my dual Xeon (with hyperthreading Win Server 2003) and
only
if I use critical sections as sycronization.
If I use a mutex instead it works fine.

My test is very simple. I generate about 10Mb of traffic that will be sent
to the app. Eventually on my dual xeon
I'll get an exception that looks like a pure virtual function call. I
reproduced the crash many time and explored
the stack and everything looks just fine, except that my stack seems to be
4
bytes shifted(but I assume is just VS's Debugger that
gets a bit confused with release builds). The problem seems to be around
the
critical section.
The critical section version crashes almost immediately, the mutex version
has been running for hours onder heavy stress and is flawless.

So far I always tested it on my dev machine (dualcore pentium Win XP pro)
and even if I generate a lot of traffic the
app just works fine both with critical section or mutex. On single core
machines obviuosly works well too.
If I use single threaded network IO everthing works fine so I'd exclude a
bug in the app itself.

Does anybody have any idea of what could cause this? is there something
that
I shouldn't do with critical sections?
I'm really curious because I really don't understand the mutex as a
solution.

thanks for your time
Alberto


.



Relevant Pages

  • Re: IOCP critical sections and mutexes
    ... those are pulled from the queue via GetQueuedCompletionStatus ... BTW, for the record, both the user mode accessible mutex and critical ... My packets never go over 2k in size. ... then pushes it in a queue that will be later processed by my main app ...
    (microsoft.public.win32.programmer.kernel)
  • Re: IOCP critical sections and mutexes
    ... the critical section is recursively acquired by a thread through the IOCP? ... My packets never go over 2k in size. ... then pushes it in a queue that will be later processed by my main app ... If I use a mutex instead it works fine. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: IOCP critical sections and mutexes
    ... instance) and I get pretty much the same crash. ... I mush have done something stupid in my main thread app. ... My packets never go over 2k in size. ... If I use a mutex instead it works fine. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: ActiveX.exe more problems
    ... it's not a Streaming device. ... Jungo assumes this too ... App doesn't see an Abort or Stop flag it starts interrogating the USB device ... Packets are received ...
    (microsoft.public.vb.general.discussion)
  • Re: IOCP critical sections and mutexes
    ... then there is some bug in your ... routines but I recently started some preliminary stress test on a new server ... then pushes it in a queue that will be later processed by my main app ... If I use a mutex instead it works fine. ...
    (microsoft.public.win32.programmer.kernel)

Loading