Re: Access Violation Problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"dramesh" <rdeekonda@xxxxxxxxxxx> wrote in message
news:1139807814.590988.188990@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yes szValue is null terminated

In a single threaded application, I can't see how a mere assignment to a
CString of a null-terminated string could cause an access violation (if you
run out of memory, then this could indirectly cause an access violation,
depending on how your program responds to this condition). My suspicion
would be that there is a problem elsewhere in your code and the problem only
appears to be caused by the assignment.

In a multi-threaded application, an attempt by two threads to make an
assignment simultaneously could cause an access violation (e.g., two threads
could each call delete [] on the same pointer). Your code certainly needs to
guard against simultaneous assignment if that is a possibility. However, I
still think it is more likely that your problem results from a problem
elsewhere in your code (e.g., failing to allocate enough memory to store
something or reading past the end of a string or array).

--
John Carson


.



Relevant Pages

  • Why does this not fail?
    ... Even if "a" is NULL in the assignment below, ... But something like this will cause an AV because "someVar" is NULL: ... Why does the first assignment not cause any access violation? ...
    (comp.lang.c)
  • Re: WaitForSingleObject() will not deadlock
    ... the line commented out, and assuming there is no other gratuitous assignment to x, then it ... A memory address is a memory address. ... that is awakened by that signal or broadcast. ... even if it occurs before it awakens. ...
    (microsoft.public.vc.mfc)
  • Re: 7.0 wishlist?
    ... The whole point is that sometimes you have a class that effectively does implement some interface, except for lacking the actual "implements" bit, and that you didn't write and don't get to edit. ... There'd only be anything different if the left hand side of assignment was of the "not supposed to be null" variety AND what was being assigned was not either "not supposed to be null" or demonstrably non-null by static analysis. ... Warning, cast can remove. ... My hope was for -Xmx to go away and the process size to tend to hang around a fixed multiple of the actual amount of memory taken up by live objects. ...
    (comp.lang.java.programmer)
  • Re: Controlled types and exception safety
    ... >> constructor throws/raises, the object is considered to be never created ... you'll have memory leaks and other such badness. ... > actually wish is to have access to the left side of assignment. ... Ada doesn't really have user-defined assignment; ...
    (comp.lang.ada)
  • Re: signal handler, atomicity code review/moral support
    ... that myflag could be modified while it is being read, ... Assignment to an integer is always atomic. ... memory with a single instruction (which executes 'atomically' wrt to ... Atomic writes of native word sizes on modern hardware should be a ...
    (comp.unix.programmer)