Problem with memory allocation

Hi,

   I have a multi-threaded application where in one of the functions that is 
called inside one of the threads, I have declared a CString variable called 
ErrorText. I leave the application  to run overnight in the Debug mode. 
Somehow, the application runs successfully for a few hours and then freezes 
at a random time and displays a message box " User Breakpoint called from 
code at 0x10212ad0". I see this message when I come back in the morning. It 
stops at one of the statements in dbgheap.c... then I step through the code 
and it goes through many functions of which one of them is a CString function 
AllocBuffer. After stepping through all the code in the library, it returns 
to the function where the following line was called:

        ErrorText = "Some String";

I believe this assignment statement is causing some memory allocation 
problems. I am also not sure if there are any memory leaks in my application. 
 I remember another problem in the past, where this string was overwriting 
another string. To solve that problem, I just had to initialize that 
variable's memory using memset and it started working fine...

Has someone seen such problems before? If yes, please suggest what I should 
do. I would also like to understand the memory allocation stuff... I shall 
post the function if anybody wants to have a look at it.
0
Kaur (1)
5/2/2007 4:29:02 PM
vc.mfc 33608 articles. 0 followers. Follow

13 Replies
1478 Views

Similar Articles

[PageSpeed] 22

I've never seen this problem, but since you mention that you have multiple 
threads maybe more than one thread is trying to update the data at the same 
time.  Or, perhaps you're running into a reference counting problem and you 
really are running out of memory from simply allocating the string (fresh) 
over and over.

Tom

"Punit Kaur" <Punit Kaur@discussions.microsoft.com> wrote in message 
news:0D8E7195-9798-471C-831E-F8F383847DBD@microsoft.com...
> Hi,
>
>   I have a multi-threaded application where in one of the functions that 
> is
> called inside one of the threads, I have declared a CString variable 
> called
> ErrorText. I leave the application  to run overnight in the Debug mode.
> Somehow, the application runs successfully for a few hours and then 
> freezes
> at a random time and displays a message box " User Breakpoint called from
> code at 0x10212ad0". I see this message when I come back in the morning. 
> It
> stops at one of the statements in dbgheap.c... then I step through the 
> code
> and it goes through many functions of which one of them is a CString 
> function
> AllocBuffer. After stepping through all the code in the library, it 
> returns
> to the function where the following line was called:
>
>        ErrorText = "Some String";
>
> I believe this assignment statement is causing some memory allocation
> problems. I am also not sure if there are any memory leaks in my 
> application.
> I remember another problem in the past, where this string was overwriting
> another string. To solve that problem, I just had to initialize that
> variable's memory using memset and it started working fine...
>
> Has someone seen such problems before? If yes, please suggest what I 
> should
> do. I would also like to understand the memory allocation stuff... I shall
> post the function if anybody wants to have a look at it. 

0
tom.nospam (3240)
5/2/2007 4:58:59 PM
Hi,

 This variable is a local variable, only one thread can access it and no 
other thread is accessing it concurrently. But, you were right, this 
assignment stmt is called again and again becos the thread is a while loop 
and calls this function very very often. How should i avoid that problem. 
This text in the variable changes according to some error condition that is 
raised and is assigned the value in a switch statement inside the function.

 I changed the variable to char array and instead of assignment stmt, I am 
using sprintf. I dont know if that will change anything.


"Tom Serface" wrote:

> I've never seen this problem, but since you mention that you have multiple 
> threads maybe more than one thread is trying to update the data at the same 
> time.  Or, perhaps you're running into a reference counting problem and you 
> really are running out of memory from simply allocating the string (fresh) 
> over and over.
> 
> Tom
> 
> "Punit Kaur" <Punit Kaur@discussions.microsoft.com> wrote in message 
> news:0D8E7195-9798-471C-831E-F8F383847DBD@microsoft.com...
> > Hi,
> >
> >   I have a multi-threaded application where in one of the functions that 
> > is
> > called inside one of the threads, I have declared a CString variable 
> > called
> > ErrorText. I leave the application  to run overnight in the Debug mode.
> > Somehow, the application runs successfully for a few hours and then 
> > freezes
> > at a random time and displays a message box " User Breakpoint called from
> > code at 0x10212ad0". I see this message when I come back in the morning. 
> > It
> > stops at one of the statements in dbgheap.c... then I step through the 
> > code
> > and it goes through many functions of which one of them is a CString 
> > function
> > AllocBuffer. After stepping through all the code in the library, it 
> > returns
> > to the function where the following line was called:
> >
> >        ErrorText = "Some String";
> >
> > I believe this assignment statement is causing some memory allocation
> > problems. I am also not sure if there are any memory leaks in my 
> > application.
> > I remember another problem in the past, where this string was overwriting
> > another string. To solve that problem, I just had to initialize that
> > variable's memory using memset and it started working fine...
> >
> > Has someone seen such problems before? If yes, please suggest what I 
> > should
> > do. I would also like to understand the memory allocation stuff... I shall
> > post the function if anybody wants to have a look at it. 
> 
0
PunitKaur (24)
5/2/2007 5:24:02 PM
First, is that string shared with any other thread?  If it is, then you MUST synchronize
any attempt to read or modify it.  Note also that it did NOT stop at "one of the
statements in dbghep.c", it stopped at a VERY SPECIFIC STATEMENT in dbgheap.c, and knowing
what that statement is tells us a lot about what is going on.  We also need to know which
version of VS you are using: 6, .NET2002, .NET2003, 2005.

It may not be a synchronization issue at all; it might be a memory overwrite caused by
some other part of your program malfunctioning, and the CString assignment was the first
place it was detected.  But by omitting the crucial information about the actual line that
failed, you have rendered a meaningful analysis nearly impossible.

Note that if you have multiple threads, it is your responsibility to make sure that
anything that can modify any shared value is properly synchronized so that only one thread
at a time can be doing the modification.
					joe

On Wed, 2 May 2007 09:29:02 -0700, Punit Kaur <Punit Kaur@discussions.microsoft.com>
wrote:

>Hi,
>
>   I have a multi-threaded application where in one of the functions that is 
>called inside one of the threads, I have declared a CString variable called 
>ErrorText. I leave the application  to run overnight in the Debug mode. 
>Somehow, the application runs successfully for a few hours and then freezes 
>at a random time and displays a message box " User Breakpoint called from 
>code at 0x10212ad0". I see this message when I come back in the morning. It 
>stops at one of the statements in dbgheap.c... then I step through the code 
>and it goes through many functions of which one of them is a CString function 
>AllocBuffer. After stepping through all the code in the library, it returns 
>to the function where the following line was called:
>
>        ErrorText = "Some String";
>
>I believe this assignment statement is causing some memory allocation 
>problems. I am also not sure if there are any memory leaks in my application. 
> I remember another problem in the past, where this string was overwriting 
>another string. To solve that problem, I just had to initialize that 
>variable's memory using memset and it started working fine...
>
>Has someone seen such problems before? If yes, please suggest what I should 
>do. I would also like to understand the memory allocation stuff... I shall 
>post the function if anybody wants to have a look at it.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/2/2007 5:43:19 PM
CString should be able to handle that without fragmenting memory, but if you 
can use a buffer you will certainly minimize the problem since you'll be 
using the same memory over and over.  However, you will run into a problem 
if the string exceeds the size of the buffer.  You'll have to check for that 
condition.

I'd be curious to know if this makes any difference.

Tom

"Punit Kaur" <PunitKaur@discussions.microsoft.com> wrote in message 
news:5CB997BA-E74F-4E3E-B1C8-E7A406033358@microsoft.com...
>
> Hi,
>
> This variable is a local variable, only one thread can access it and no
> other thread is accessing it concurrently. But, you were right, this
> assignment stmt is called again and again becos the thread is a while loop
> and calls this function very very often. How should i avoid that problem.
> This text in the variable changes according to some error condition that 
> is
> raised and is assigned the value in a switch statement inside the 
> function.
>
> I changed the variable to char array and instead of assignment stmt, I am
> using sprintf. I dont know if that will change anything.
>
> 

0
tom.nospam (3240)
5/2/2007 5:44:37 PM
Hi,

I noticed something that was causing an error to look like it was =
something else.
I did not allocate a long enough buffer for Module.
The error showed up at the last String. (Path in the following code)
It took a while to figure out what was causing the error.
I originally suspected it was something other than the char buffer, =
since it didn't break at that part.
I am not sure if you are using a char buffer, but you might want to =
check it out if you are.
I should have used String.GetBuffer() paired with =
String.ReleaseBuffer(). The code is old.
I just thought I would mention it.

char cExeFile[100];
 GetModuleFileName(NULL, cExeFile, sizeof(cExeFile));
 String.Format("Module Name: %s", cExeFile);
 AddMessage(String);

 AddMessage("Doc Messages");
 String.Format("Is Modified: %d", IsModified());
 AddMessage(String);
// String.Format("Timer Enable %d", m_bTimerEnable);
// sprintf(cBuffer, "Timer Enable %d", m_bTimerEnable);
// String =3D cBuffer;
// AddMessage(String);

 String.Format( "Title: %s", GetTitle());
 AddMessage(String);

 String.Format("Path Name: %s", GetPathName());
 AddMessage(String);


"Punit Kaur" <Punit Kaur@discussions.microsoft.com> wrote in message =
news:0D8E7195-9798-471C-831E-F8F383847DBD@microsoft.com...
> Hi,
>=20
>   I have a multi-threaded application where in one of the functions =
that is=20
> called inside one of the threads, I have declared a CString variable =
called=20
> ErrorText. I leave the application  to run overnight in the Debug =
mode.=20
> Somehow, the application runs successfully for a few hours and then =
freezes=20
> at a random time and displays a message box " User Breakpoint called =
from=20
> code at 0x10212ad0". I see this message when I come back in the =
morning. It=20
> stops at one of the statements in dbgheap.c... then I step through the =
code=20
> and it goes through many functions of which one of them is a CString =
function=20
> AllocBuffer. After stepping through all the code in the library, it =
returns=20
> to the function where the following line was called:
>=20
>        ErrorText =3D "Some String";
>=20
> I believe this assignment statement is causing some memory allocation=20
> problems. I am also not sure if there are any memory leaks in my =
application.=20
> I remember another problem in the past, where this string was =
overwriting=20
> another string. To solve that problem, I just had to initialize that=20
> variable's memory using memset and it started working fine...
>=20
> Has someone seen such problems before? If yes, please suggest what I =
should=20
> do. I would also like to understand the memory allocation stuff... I =
shall=20
> post the function if anybody wants to have a look at it.
0
Nobody530 (222)
5/2/2007 5:45:46 PM
See below...
On Wed, 2 May 2007 10:24:02 -0700, Punit Kaur <PunitKaur@discussions.microsoft.com> wrote:

>
>Hi,
>
> This variable is a local variable, only one thread can access it and no 
>other thread is accessing it concurrently. But, you were right, this 
>assignment stmt is called again and again becos the thread is a while loop 
>and calls this function very very often. How should i avoid that problem. 
****
Not a problem.  Nothing to avoid.
****
>This text in the variable changes according to some error condition that is 
>raised and is assigned the value in a switch statement inside the function.
>
> I changed the variable to char array and instead of assignment stmt, I am 
>using sprintf. I dont know if that will change anything.
****
Bad mistake.  Change it back to a CString.  DO NOT use sprintf.  This is a pointless
change and it will not make your problem go away.

When reporting bugs, report everything.  Vague reports about "it got an error someplace"
(which is all you told us, really) don't help us much.
					joe
****
>
>
>"Tom Serface" wrote:
>
>> I've never seen this problem, but since you mention that you have multiple 
>> threads maybe more than one thread is trying to update the data at the same 
>> time.  Or, perhaps you're running into a reference counting problem and you 
>> really are running out of memory from simply allocating the string (fresh) 
>> over and over.
>> 
>> Tom
>> 
>> "Punit Kaur" <Punit Kaur@discussions.microsoft.com> wrote in message 
>> news:0D8E7195-9798-471C-831E-F8F383847DBD@microsoft.com...
>> > Hi,
>> >
>> >   I have a multi-threaded application where in one of the functions that 
>> > is
>> > called inside one of the threads, I have declared a CString variable 
>> > called
>> > ErrorText. I leave the application  to run overnight in the Debug mode.
>> > Somehow, the application runs successfully for a few hours and then 
>> > freezes
>> > at a random time and displays a message box " User Breakpoint called from
>> > code at 0x10212ad0". I see this message when I come back in the morning. 
>> > It
>> > stops at one of the statements in dbgheap.c... then I step through the 
>> > code
>> > and it goes through many functions of which one of them is a CString 
>> > function
>> > AllocBuffer. After stepping through all the code in the library, it 
>> > returns
>> > to the function where the following line was called:
>> >
>> >        ErrorText = "Some String";
>> >
>> > I believe this assignment statement is causing some memory allocation
>> > problems. I am also not sure if there are any memory leaks in my 
>> > application.
>> > I remember another problem in the past, where this string was overwriting
>> > another string. To solve that problem, I just had to initialize that
>> > variable's memory using memset and it started working fine...
>> >
>> > Has someone seen such problems before? If yes, please suggest what I 
>> > should
>> > do. I would also like to understand the memory allocation stuff... I shall
>> > post the function if anybody wants to have a look at it. 
>> 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/2/2007 5:45:52 PM
This string is accessed by only one thread that calls the function( where 
this string is declared and modified)again and again in a loop. No other 
threads call this function, so I am sure its not being accessed by any other 
thread. 

I am sorry I forgot to note the exact stmt in dbgheap.c where it stopped. I 
am sure I will get this error again tonight, I shall note every detail down 
and post it by tomorrow.

I am using Visual Studio 6.0 . 

Also I remember seeing something wierd, when I checked through the task 
manager how much memory the application was taking it showed around 11K which 
is a lot more than it normally has , around 5k, when it doesn't produce any 
error and is running normally. Right now its running and is consuming around 
5k. It remains around the same for a number of hours... and I believe its 
supposed to remain the same over time when there is no change in the 
environment...

Does that increase in memory indicate anything?

Meanwhile I shall gather more information.



"Joseph M. Newcomer" wrote:

> First, is that string shared with any other thread?  If it is, then you MUST synchronize
> any attempt to read or modify it.  Note also that it did NOT stop at "one of the
> statements in dbghep.c", it stopped at a VERY SPECIFIC STATEMENT in dbgheap.c, and knowing
> what that statement is tells us a lot about what is going on.  We also need to know which
> version of VS you are using: 6, .NET2002, .NET2003, 2005.
> 
> It may not be a synchronization issue at all; it might be a memory overwrite caused by
> some other part of your program malfunctioning, and the CString assignment was the first
> place it was detected.  But by omitting the crucial information about the actual line that
> failed, you have rendered a meaningful analysis nearly impossible.
> 
> Note that if you have multiple threads, it is your responsibility to make sure that
> anything that can modify any shared value is properly synchronized so that only one thread
> at a time can be doing the modification.
> 					joe
> 
> On Wed, 2 May 2007 09:29:02 -0700, Punit Kaur <Punit Kaur@discussions.microsoft.com>
> wrote:
> 
> >Hi,
> >
> >   I have a multi-threaded application where in one of the functions that is 
> >called inside one of the threads, I have declared a CString variable called 
> >ErrorText. I leave the application  to run overnight in the Debug mode. 
> >Somehow, the application runs successfully for a few hours and then freezes 
> >at a random time and displays a message box " User Breakpoint called from 
> >code at 0x10212ad0". I see this message when I come back in the morning. It 
> >stops at one of the statements in dbgheap.c... then I step through the code 
> >and it goes through many functions of which one of them is a CString function 
> >AllocBuffer. After stepping through all the code in the library, it returns 
> >to the function where the following line was called:
> >
> >        ErrorText = "Some String";
> >
> >I believe this assignment statement is causing some memory allocation 
> >problems. I am also not sure if there are any memory leaks in my application. 
> > I remember another problem in the past, where this string was overwriting 
> >another string. To solve that problem, I just had to initialize that 
> >variable's memory using memset and it started working fine...
> >
> >Has someone seen such problems before? If yes, please suggest what I should 
> >do. I would also like to understand the memory allocation stuff... I shall 
> >post the function if anybody wants to have a look at it.
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm
> 
0
PunitKaur (24)
5/2/2007 6:42:01 PM
There are issues that arise if you try to free an object twice, free an object and
continue to use the pointer, allocation n bytes and write in m > n bytes, and so on.  The
exact line on which the error occurs tends to be highly informative.  Entering the
debugger and reading the source is a valuable piece of information.

It looks suspiciously like a memory overwrite problem that was caught at some later time.
I refer to the allocation that fails as the "innocent bystander" who is shot.  My other
analogy is that someone takes the cover off a manhole on the street.  The person who falls
in is not the guilty party, and the trick is to find the party that took the cover off. So
it is more likely that what you are seeing here is the assignment in question fell into
the hole.  But who created the hole?

On technique is to toss an
	ASSERT(_heapchk() == HEAPOK);
(check the docs to be sure I remembered the right spelling) in various places.  A good
place to start is to add it to the OnIdle handler of your CWinApp class.  This catches the
error fairly early.  (You may have to add an OnIdle handler to do this).

See my essay on memory damage on my MVP Tips site.
				joe

On Wed, 2 May 2007 11:42:01 -0700, Punit Kaur <PunitKaur@discussions.microsoft.com> wrote:

>This string is accessed by only one thread that calls the function( where 
>this string is declared and modified)again and again in a loop. No other 
>threads call this function, so I am sure its not being accessed by any other 
>thread. 
>
>I am sorry I forgot to note the exact stmt in dbgheap.c where it stopped. I 
>am sure I will get this error again tonight, I shall note every detail down 
>and post it by tomorrow.
>
>I am using Visual Studio 6.0 . 
>
>Also I remember seeing something wierd, when I checked through the task 
>manager how much memory the application was taking it showed around 11K which 
>is a lot more than it normally has , around 5k, when it doesn't produce any 
>error and is running normally. Right now its running and is consuming around 
>5k. It remains around the same for a number of hours... and I believe its 
>supposed to remain the same over time when there is no change in the 
>environment...
>
>Does that increase in memory indicate anything?
>
>Meanwhile I shall gather more information.
>
>
>
>"Joseph M. Newcomer" wrote:
>
>> First, is that string shared with any other thread?  If it is, then you MUST synchronize
>> any attempt to read or modify it.  Note also that it did NOT stop at "one of the
>> statements in dbghep.c", it stopped at a VERY SPECIFIC STATEMENT in dbgheap.c, and knowing
>> what that statement is tells us a lot about what is going on.  We also need to know which
>> version of VS you are using: 6, .NET2002, .NET2003, 2005.
>> 
>> It may not be a synchronization issue at all; it might be a memory overwrite caused by
>> some other part of your program malfunctioning, and the CString assignment was the first
>> place it was detected.  But by omitting the crucial information about the actual line that
>> failed, you have rendered a meaningful analysis nearly impossible.
>> 
>> Note that if you have multiple threads, it is your responsibility to make sure that
>> anything that can modify any shared value is properly synchronized so that only one thread
>> at a time can be doing the modification.
>> 					joe
>> 
>> On Wed, 2 May 2007 09:29:02 -0700, Punit Kaur <Punit Kaur@discussions.microsoft.com>
>> wrote:
>> 
>> >Hi,
>> >
>> >   I have a multi-threaded application where in one of the functions that is 
>> >called inside one of the threads, I have declared a CString variable called 
>> >ErrorText. I leave the application  to run overnight in the Debug mode. 
>> >Somehow, the application runs successfully for a few hours and then freezes 
>> >at a random time and displays a message box " User Breakpoint called from 
>> >code at 0x10212ad0". I see this message when I come back in the morning. It 
>> >stops at one of the statements in dbgheap.c... then I step through the code 
>> >and it goes through many functions of which one of them is a CString function 
>> >AllocBuffer. After stepping through all the code in the library, it returns 
>> >to the function where the following line was called:
>> >
>> >        ErrorText = "Some String";
>> >
>> >I believe this assignment statement is causing some memory allocation 
>> >problems. I am also not sure if there are any memory leaks in my application. 
>> > I remember another problem in the past, where this string was overwriting 
>> >another string. To solve that problem, I just had to initialize that 
>> >variable's memory using memset and it started working fine...
>> >
>> >Has someone seen such problems before? If yes, please suggest what I should 
>> >do. I would also like to understand the memory allocation stuff... I shall 
>> >post the function if anybody wants to have a look at it.
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/2/2007 7:17:37 PM
ok.. here are more details: the message box says "User Breakpoint called from 
code at 0x10212ad0", and it breaks into the dbgheap.c file in the following 
function :

 void * __cdecl _heap_alloc_dbg(size_t nSize, int nBlockUse, const char * 
szFileName, int nLine)
{

   long lRequest;
        size_t blockSize;
        int fIgnore = FALSE;
        _CrtMemBlockHeader * pHead;

        /* verify heap before allocation */
        if (_crtDbgFlag & _CRTDBG_CHECK_ALWAYS_DF)
            _ASSERTE(_CrtCheckMemory());

        lRequest = _lRequestCurr; 

/***********************************************
this is where it breaks, at the "if" statement. , the values of lRequest and 
_crtBreakAlloc =-1
*************************************************/
    /* break into debugger at specific memory allocation */
        if (lRequest == _crtBreakAlloc)
            _CrtDbgBreak();

/********************************************************
here onwards it does not execute the stmts inside "if"
*******************************************************/
/* forced failure */
        if (!(*_pfnAllocHook)(_HOOK_ALLOC, NULL, nSize, nBlockUse, lRequest, 
szFileName, nLine))
        {
            if (szFileName)
                _RPT2(_CRT_WARN, "Client hook allocation failure at file %hs 
line %d.\n",
                    szFileName, nLine);
            else
                _RPT0(_CRT_WARN, "Client hook allocation failure.\n");

            return NULL;
        }

 /* cannot ignore CRT allocations */
        if (_BLOCK_TYPE(nBlockUse) != _CRT_BLOCK &&
            !(_crtDbgFlag & _CRTDBG_ALLOC_MEM_DF))
            fIgnore = TRUE;

        /* Diagnostic memory allocation from this point on */

        if (nSize > (size_t)_HEAP_MAXREQ ||
            nSize + nNoMansLandSize + sizeof(_CrtMemBlockHeader) > 
(size_t)_HEAP_MAXREQ)
        {
            _RPT1(_CRT_ERROR, "Invalid allocation size: %u bytes.\n", nSize);
            return NULL;
        }

        if (!_BLOCK_TYPE_IS_VALID(nBlockUse))
        {
            _RPT0(_CRT_ERROR, "Error: memory allocation: bad memory block 
type.\n");
        }
/******************************************************
until here  in all the above "if" statements, the stmts inside "if" are not 
executed
******************************************************/
/****** it allocates block size ***************/        
blockSize = sizeof(_CrtMemBlockHeader) + nSize + nNoMansLandSize;

#ifndef WINHEAP
        /* round requested size */
        blockSize = _ROUND2(blockSize, _GRANULARITY);
#endif  /* WINHEAP */

        pHead = (_CrtMemBlockHeader *)_heap_alloc_base(blockSize);

        if (pHead == NULL)
            return NULL;

        /* commit allocation */

        ++_lRequestCurr; 
/**** at this point after applying the increment operator, the value of 
_lRequestCurr = 0********/

/***** does not execute the stmts in the following if block since fIgnore =0 
***/
        if (fIgnore)
        {
            pHead->pBlockHeaderNext = NULL;
            pHead->pBlockHeaderPrev = NULL;
            pHead->szFileName = NULL;
            pHead->nLine = IGNORE_LINE;
            pHead->nDataSize = nSize;
            pHead->nBlockUse = _IGNORE_BLOCK;
            pHead->lRequest = IGNORE_REQ;
        }
        else {
            /* keep track of total amount of memory allocated */
            _lTotalAlloc += nSize;
            _lCurAlloc += nSize;

            if (_lCurAlloc > _lMaxAlloc)
                _lMaxAlloc = _lCurAlloc;

            if (_pFirstBlock)
                _pFirstBlock->pBlockHeaderPrev = pHead;
            else
                _pLastBlock = pHead;

            pHead->pBlockHeaderNext = _pFirstBlock;
            pHead->pBlockHeaderPrev = NULL;
            pHead->szFileName = (char *)szFileName;

     /**** Here the szFileName has strcore.cpp as its value *****/

            pHead->nLine = nLine;
            pHead->nDataSize = nSize;
            pHead->nBlockUse = nBlockUse;
            pHead->lRequest = lRequest;

            /* link blocks together */
            _pFirstBlock = pHead;
        }

 /*** executes everything below with no problems ****/

        /* fill in gap before and after real block */
        memset((void *)pHead->gap, _bNoMansLandFill, nNoMansLandSize);
        memset((void *)(pbData(pHead) + nSize), _bNoMansLandFill, 
nNoMansLandSize);

        /* fill data with silly value (but non-zero) */
        memset((void *)pbData(pHead), _bCleanLandFill, nSize);

        return (void *)pbData(pHead);

}

Here are the values of the variables after this function is executed:

   	nSize	15
	nBlockUse	1
	szFileName	0x5f4ccb18 "strcore.cpp"
	nLine	118
	blockSize	51
	fIgnore	0
	lRequest	-1
	pHead	0x015f55c0
	_bCleanLandFill	205 'Í'
	nSize	15
	pHead	0x015f55c0

And after this it returns to the following function where it was called :

void * __cdecl _nh_malloc_dbg (
        size_t nSize,
        int nhFlag,
        int nBlockUse,
        const char * szFileName,
        int nLine
        )

{

  // some stmts
  ....
  ....
  /***** this is where it was called *****/
   pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine); 
    
// some more stmts

/*******Values of variables 
Values of variables after exec this function.

	nhFlag	0
	pvBlk	0x015f55e0
*******************/
/******* the following if stmt is executed to return the value pvBlk *******/
 if (pvBlk || nhFlag == 0)
                return pvBlk;

            /* call installed new handler */
            if (!_callnewh(nSize))
                return NULL;

            /* new handler was successful -- try to allocate again */
        }

}
 

   /******After executing the above  function, it returns to the following 
caller function 
****************/
_CRTIMP void * __cdecl _malloc_dbg (
        size_t nSize,
        int nBlockUse,
        const char * szFileName,
        int nLine
        )
{
        void *res = _nh_malloc_dbg(nSize, _newmode, nBlockUse, szFileName, 
nLine);
        return res;
}

/*******************************************************
This returns res which is a non zero value 	res=0x015f55e0
******************************************************/

/*****After this it returns to the following function in AFXMEM.CPP******/
void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int 
nLine)

{

   // some stmts
for (;;)
	{
		pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
		if (pResult != NULL)
			return pResult;  
            /**** returns pResult - a non zero value in the stmt above 
**********/
             // some more  stmts
            ......
           .....
      }

/******Then returns to the following function********/
 void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
{
	return ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);


/******* Then returns to the function in strcore.cpp file ************/
void CString::AllocBuffer(int nLen) 
{ 
    // some stmts
   	{
                     /********* it was called in this stmt **********/
			pData = (CStringData*)
				new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
			pData->nAllocLength = nLen;
		}
		pData->nRefs = 1;
		pData->data()[nLen] = '\0';
		pData->nDataLength = nLen;
		m_pchData = pData->data();
	}
}

/*******Values of variables after function finishes exec 
m_pchData	0x015f55ec "ÍÍ"
pData	0x015f55e0
this	0x01ecfb8c {"ÍÍ"}
	CStringData::data returned	0x015f55ec "ÍÍ"
********************/
/***** returns to the following function *****/
CString::CString(LPCTSTR lpsz)
{
	//some stmts
        .......
		if (nLen != 0)
		{
                       /***** called in the stmts below ******/
			AllocBuffer(nLen);   
			memcpy(m_pchData, lpsz, nLen*sizeof(TCHAR));
		}
	}
}

/**********Values of variables ***********/
+	lpsz	0x00491078 "TX"
+	m_pchData	0x015f55ec "TX"
	nLen	2
+	this	0x01ecfb8c {"TX"}
	memcpy returned	<void>
/************************************/

/* the following is the source code stmt  inside a while loop in a thread 
where it breaks *****/
ErrorOccurred = CheckForWinSockError(ch, "TX", 0);

Please let me know if you require more details...
Sorry for the very long post!!! 


0
PunitKaur (24)
5/3/2007 3:12:03 PM
See below...

On Thu, 3 May 2007 08:12:03 -0700, Punit Kaur <PunitKaur@discussions.microsoft.com> wrote:

>ok.. here are more details: the message box says "User Breakpoint called from 
>code at 0x10212ad0", and it breaks into the dbgheap.c file in the following 
>function :
>
> void * __cdecl _heap_alloc_dbg(size_t nSize, int nBlockUse, const char * 
>szFileName, int nLine)
>{
>
>   long lRequest;
>        size_t blockSize;
>        int fIgnore = FALSE;
>        _CrtMemBlockHeader * pHead;
>
>        /* verify heap before allocation */
>        if (_crtDbgFlag & _CRTDBG_CHECK_ALWAYS_DF) //*** THIS LINE (see at end)
>            _ASSERTE(_CrtCheckMemory());
>
>        lRequest = _lRequestCurr; 
>
>/***********************************************
>this is where it breaks, at the "if" statement. , the values of lRequest and 
>_crtBreakAlloc =-1
>*************************************************/
>    /* break into debugger at specific memory allocation */
>        if (lRequest == _crtBreakAlloc)
>            _CrtDbgBreak();
*****
This looks like the contents of the block, which are expected to be 0xDFDFDFDF...DFDFDF
are in fact not that value.  This can be caused by either of two problems.  The first is
that you have done something like
	whatever * p = new whatever;
	... use it
  	delete whatever;
	p->field = ...;

which is called the "dangling pointer" problem.  One way to avoid this is that immediately
after doing a delete, you set the pointer field to NULL, which will catch such errors.

Another possible cause is that you did an allocation of n bytes and wrote m > n bytes,
overwriting the 0xDFDFDF...DFDF of a free block.  Look for memory overwrites.

Beyond this point, nothing else is interesting.  The heap is trashed.

I suggest trying the Application Verifier to help track this down.  Download it from the
Microsoft Web site (search for Application Verifier)
				joe
*****
>
>/********************************************************
>here onwards it does not execute the stmts inside "if"
>*******************************************************/
****
At this point, single stepping into the call might have been informative.
****
>/* forced failure */
>        if (!(*_pfnAllocHook)(_HOOK_ALLOC, NULL, nSize, nBlockUse, lRequest, 
>szFileName, nLine))
>        {
>            if (szFileName)
>                _RPT2(_CRT_WARN, "Client hook allocation failure at file %hs 
>line %d.\n",
>                    szFileName, nLine);
>            else
>                _RPT0(_CRT_WARN, "Client hook allocation failure.\n");
>
>            return NULL;
>        }
>
> /* cannot ignore CRT allocations */
>        if (_BLOCK_TYPE(nBlockUse) != _CRT_BLOCK &&
>            !(_crtDbgFlag & _CRTDBG_ALLOC_MEM_DF))
>            fIgnore = TRUE;
>
>        /* Diagnostic memory allocation from this point on */
>
>        if (nSize > (size_t)_HEAP_MAXREQ ||
>            nSize + nNoMansLandSize + sizeof(_CrtMemBlockHeader) > 
>(size_t)_HEAP_MAXREQ)
>        {
>            _RPT1(_CRT_ERROR, "Invalid allocation size: %u bytes.\n", nSize);
>            return NULL;
>        }
>
>        if (!_BLOCK_TYPE_IS_VALID(nBlockUse))
>        {
>            _RPT0(_CRT_ERROR, "Error: memory allocation: bad memory block 
>type.\n");
>        }
>/******************************************************
>until here  in all the above "if" statements, the stmts inside "if" are not 
>executed
>******************************************************/
>/****** it allocates block size ***************/        
>blockSize = sizeof(_CrtMemBlockHeader) + nSize + nNoMansLandSize;
>
>#ifndef WINHEAP
>        /* round requested size */
>        blockSize = _ROUND2(blockSize, _GRANULARITY);
>#endif  /* WINHEAP */
>
>        pHead = (_CrtMemBlockHeader *)_heap_alloc_base(blockSize);
>
>        if (pHead == NULL)
>            return NULL;
>
>        /* commit allocation */
>
>        ++_lRequestCurr; 
>/**** at this point after applying the increment operator, the value of 
>_lRequestCurr = 0********/
>
>/***** does not execute the stmts in the following if block since fIgnore =0 
>***/
>        if (fIgnore)
>        {
>            pHead->pBlockHeaderNext = NULL;
>            pHead->pBlockHeaderPrev = NULL;
>            pHead->szFileName = NULL;
>            pHead->nLine = IGNORE_LINE;
>            pHead->nDataSize = nSize;
>            pHead->nBlockUse = _IGNORE_BLOCK;
>            pHead->lRequest = IGNORE_REQ;
>        }
>        else {
>            /* keep track of total amount of memory allocated */
>            _lTotalAlloc += nSize;
>            _lCurAlloc += nSize;
>
>            if (_lCurAlloc > _lMaxAlloc)
>                _lMaxAlloc = _lCurAlloc;
>
>            if (_pFirstBlock)
>                _pFirstBlock->pBlockHeaderPrev = pHead;
>            else
>                _pLastBlock = pHead;
>
>            pHead->pBlockHeaderNext = _pFirstBlock;
>            pHead->pBlockHeaderPrev = NULL;
>            pHead->szFileName = (char *)szFileName;
>
>     /**** Here the szFileName has strcore.cpp as its value *****/
>
>            pHead->nLine = nLine;
>            pHead->nDataSize = nSize;
>            pHead->nBlockUse = nBlockUse;
>            pHead->lRequest = lRequest;
>
>            /* link blocks together */
>            _pFirstBlock = pHead;
>        }
>
> /*** executes everything below with no problems ****/
>
>        /* fill in gap before and after real block */
>        memset((void *)pHead->gap, _bNoMansLandFill, nNoMansLandSize);
>        memset((void *)(pbData(pHead) + nSize), _bNoMansLandFill, 
>nNoMansLandSize);
>
>        /* fill data with silly value (but non-zero) */
>        memset((void *)pbData(pHead), _bCleanLandFill, nSize);
>
>        return (void *)pbData(pHead);
>
>}
>
>Here are the values of the variables after this function is executed:
>
>   	nSize	15
>	nBlockUse	1
>	szFileName	0x5f4ccb18 "strcore.cpp"
>	nLine	118
>	blockSize	51
>	fIgnore	0
>	lRequest	-1
>	pHead	0x015f55c0
>	_bCleanLandFill	205 '�'
>	nSize	15
>	pHead	0x015f55c0
>
>And after this it returns to the following function where it was called :
>
>void * __cdecl _nh_malloc_dbg (
>        size_t nSize,
>        int nhFlag,
>        int nBlockUse,
>        const char * szFileName,
>        int nLine
>        )
>
>{
>
>  // some stmts
>  ....
>  ....
>  /***** this is where it was called *****/
>   pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine); 
>    
>// some more stmts
>
>/*******Values of variables 
>Values of variables after exec this function.
>
>	nhFlag	0
>	pvBlk	0x015f55e0
>*******************/
>/******* the following if stmt is executed to return the value pvBlk *******/
> if (pvBlk || nhFlag == 0)
>                return pvBlk;
>
>            /* call installed new handler */
>            if (!_callnewh(nSize))
>                return NULL;
>
>            /* new handler was successful -- try to allocate again */
>        }
>
>}
> 
>
>   /******After executing the above  function, it returns to the following 
>caller function 
>****************/
>_CRTIMP void * __cdecl _malloc_dbg (
>        size_t nSize,
>        int nBlockUse,
>        const char * szFileName,
>        int nLine
>        )
>{
>        void *res = _nh_malloc_dbg(nSize, _newmode, nBlockUse, szFileName, 
>nLine);
>        return res;
>}
>
>/*******************************************************
>This returns res which is a non zero value 	res=0x015f55e0
>******************************************************/
>
>/*****After this it returns to the following function in AFXMEM.CPP******/
>void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int 
>nLine)
>
>{
>
>   // some stmts
>for (;;)
>	{
>		pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
>		if (pResult != NULL)
>			return pResult;  
>            /**** returns pResult - a non zero value in the stmt above 
>**********/
>             // some more  stmts
>            ......
>           .....
>      }
>
>/******Then returns to the following function********/
> void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
>{
>	return ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
>
>
>/******* Then returns to the function in strcore.cpp file ************/
>void CString::AllocBuffer(int nLen) 
>{ 
>    // some stmts
>   	{
>                     /********* it was called in this stmt **********/
>			pData = (CStringData*)
>				new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
>			pData->nAllocLength = nLen;
>		}
>		pData->nRefs = 1;
>		pData->data()[nLen] = '\0';
>		pData->nDataLength = nLen;
>		m_pchData = pData->data();
>	}
>}
>
>/*******Values of variables after function finishes exec 
>m_pchData	0x015f55ec "��"
>pData	0x015f55e0
>this	0x01ecfb8c {"��"}
>	CStringData::data returned	0x015f55ec "��"
>********************/
>/***** returns to the following function *****/
>CString::CString(LPCTSTR lpsz)
>{
>	//some stmts
>        .......
>		if (nLen != 0)
>		{
>                       /***** called in the stmts below ******/
>			AllocBuffer(nLen);   
>			memcpy(m_pchData, lpsz, nLen*sizeof(TCHAR));
>		}
>	}
>}
>
>/**********Values of variables ***********/
>+	lpsz	0x00491078 "TX"
>+	m_pchData	0x015f55ec "TX"
>	nLen	2
>+	this	0x01ecfb8c {"TX"}
>	memcpy returned	<void>
>/************************************/
>
>/* the following is the source code stmt  inside a while loop in a thread 
>where it breaks *****/
>ErrorOccurred = CheckForWinSockError(ch, "TX", 0);
>
>Please let me know if you require more details...
>Sorry for the very long post!!! 
*****
Very detailed, but the critical piece of information was at the point where the breakpoint
was taken.  The code suggests that a freed block has been overwritten.  This is very
serious error, which in the release build would not be detected unless it caused some
other destruction, which would then depend on whatever allocation patterns might have
happened.  You need to find and fix the dangling pointer/overwrite problem.

Note that you can click on the line I indicated as "This line", above, and right click on
it, select Set Next Statement, and start single-stepping-into.  Also, you should have seen
in the output window a message saying what went wrong.  Don't step into _heapchk, or it
will be boring; try setting breakpoints at all the error messages (RPT...), and let it
run.  This will identify exactly what block is bad.  But I suspect you have a dangling
pointer problem.
				joe
***** 

>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/3/2007 5:03:16 PM
I think you misunderstood.

The break occurred here :


/* break into debugger at specific memory allocation */
if (lRequest == _crtBreakAlloc)
  _CrtDbgBreak(); 

and not in the "if" stmt above this one that checks the value of 
_CRTDBG_CHECK_ALWAYS_DF.

And the message always says "user breakpoint called at xyz". Why does it 
call it user breakpoint. I haven't set any breakpoints in my application.

Sorry if I conveyed it wrong in the previous post. I would like to know if 
whatever you explained is still valid for this case?

Thank you.
---------------------------------------------------------------------------


"Joseph M. Newcomer" wrote:

> See below...
> 
> On Thu, 3 May 2007 08:12:03 -0700, Punit Kaur <PunitKaur@discussions.microsoft.com> wrote:
> 
> >ok.. here are more details: the message box says "User Breakpoint called from 
> >code at 0x10212ad0", and it breaks into the dbgheap.c file in the following 
> >function :
> >
> > void * __cdecl _heap_alloc_dbg(size_t nSize, int nBlockUse, const char * 
> >szFileName, int nLine)
> >{
> >
> >   long lRequest;
> >        size_t blockSize;
> >        int fIgnore = FALSE;
> >        _CrtMemBlockHeader * pHead;
> >
> >        /* verify heap before allocation */
> >        if (_crtDbgFlag & _CRTDBG_CHECK_ALWAYS_DF) //*** THIS LINE (see at end)
> >            _ASSERTE(_CrtCheckMemory());
> >
> >        lRequest = _lRequestCurr; 
> >
> >/***********************************************
> >this is where it breaks, at the "if" statement. , the values of lRequest and 
> >_crtBreakAlloc =-1
> >*************************************************/
> >    /* break into debugger at specific memory allocation */
> >        if (lRequest == _crtBreakAlloc)
> >            _CrtDbgBreak();
> *****
> This looks like the contents of the block, which are expected to be 0xDFDFDFDF...DFDFDF
> are in fact not that value.  This can be caused by either of two problems.  The first is
> that you have done something like
> 	whatever * p = new whatever;
> 	... use it
>   	delete whatever;
> 	p->field = ...;
> 
> which is called the "dangling pointer" problem.  One way to avoid this is that immediately
> after doing a delete, you set the pointer field to NULL, which will catch such errors.
> 
> Another possible cause is that you did an allocation of n bytes and wrote m > n bytes,
> overwriting the 0xDFDFDF...DFDF of a free block.  Look for memory overwrites.
> 
> Beyond this point, nothing else is interesting.  The heap is trashed.
> 
> I suggest trying the Application Verifier to help track this down.  Download it from the
> Microsoft Web site (search for Application Verifier)
> 				joe
> *****
> >
> >/********************************************************
> >here onwards it does not execute the stmts inside "if"
> >*******************************************************/
> ****
> At this point, single stepping into the call might have been informative.
> ****
> >/* forced failure */
> >        if (!(*_pfnAllocHook)(_HOOK_ALLOC, NULL, nSize, nBlockUse, lRequest, 
> >szFileName, nLine))
> >        {
> >            if (szFileName)
> >                _RPT2(_CRT_WARN, "Client hook allocation failure at file %hs 
> >line %d.\n",
> >                    szFileName, nLine);
> >            else
> >                _RPT0(_CRT_WARN, "Client hook allocation failure.\n");
> >
> >            return NULL;
> >        }
> >
> > /* cannot ignore CRT allocations */
> >        if (_BLOCK_TYPE(nBlockUse) != _CRT_BLOCK &&
> >            !(_crtDbgFlag & _CRTDBG_ALLOC_MEM_DF))
> >            fIgnore = TRUE;
> >
> >        /* Diagnostic memory allocation from this point on */
> >
> >        if (nSize > (size_t)_HEAP_MAXREQ ||
> >            nSize + nNoMansLandSize + sizeof(_CrtMemBlockHeader) > 
> >(size_t)_HEAP_MAXREQ)
> >        {
> >            _RPT1(_CRT_ERROR, "Invalid allocation size: %u bytes.\n", nSize);
> >            return NULL;
> >        }
> >
> >        if (!_BLOCK_TYPE_IS_VALID(nBlockUse))
> >        {
> >            _RPT0(_CRT_ERROR, "Error: memory allocation: bad memory block 
> >type.\n");
> >        }
> >/******************************************************
> >until here  in all the above "if" statements, the stmts inside "if" are not 
> >executed
> >******************************************************/
> >/****** it allocates block size ***************/        
> >blockSize = sizeof(_CrtMemBlockHeader) + nSize + nNoMansLandSize;
> >
> >#ifndef WINHEAP
> >        /* round requested size */
> >        blockSize = _ROUND2(blockSize, _GRANULARITY);
> >#endif  /* WINHEAP */
> >
> >        pHead = (_CrtMemBlockHeader *)_heap_alloc_base(blockSize);
> >
> >        if (pHead == NULL)
> >            return NULL;
> >
> >        /* commit allocation */
> >
> >        ++_lRequestCurr; 
> >/**** at this point after applying the increment operator, the value of 
> >_lRequestCurr = 0********/
> >
> >/***** does not execute the stmts in the following if block since fIgnore =0 
> >***/
> >        if (fIgnore)
> >        {
> >            pHead->pBlockHeaderNext = NULL;
> >            pHead->pBlockHeaderPrev = NULL;
> >            pHead->szFileName = NULL;
> >            pHead->nLine = IGNORE_LINE;
> >            pHead->nDataSize = nSize;
> >            pHead->nBlockUse = _IGNORE_BLOCK;
> >            pHead->lRequest = IGNORE_REQ;
> >        }
> >        else {
> >            /* keep track of total amount of memory allocated */
> >            _lTotalAlloc += nSize;
> >            _lCurAlloc += nSize;
> >
> >            if (_lCurAlloc > _lMaxAlloc)
> >                _lMaxAlloc = _lCurAlloc;
> >
> >            if (_pFirstBlock)
> >                _pFirstBlock->pBlockHeaderPrev = pHead;
> >            else
> >                _pLastBlock = pHead;
> >
> >            pHead->pBlockHeaderNext = _pFirstBlock;
> >            pHead->pBlockHeaderPrev = NULL;
> >            pHead->szFileName = (char *)szFileName;
> >
> >     /**** Here the szFileName has strcore.cpp as its value *****/
> >
> >            pHead->nLine = nLine;
> >            pHead->nDataSize = nSize;
> >            pHead->nBlockUse = nBlockUse;
> >            pHead->lRequest = lRequest;
> >
> >            /* link blocks together */
> >            _pFirstBlock = pHead;
> >        }
> >
> > /*** executes everything below with no problems ****/
> >
> >        /* fill in gap before and after real block */
> >        memset((void *)pHead->gap, _bNoMansLandFill, nNoMansLandSize);
> >        memset((void *)(pbData(pHead) + nSize), _bNoMansLandFill, 
> >nNoMansLandSize);
> >
> >        /* fill data with silly value (but non-zero) */
> >        memset((void *)pbData(pHead), _bCleanLandFill, nSize);
> >
> >        return (void *)pbData(pHead);
> >
> >}
> >
> >Here are the values of the variables after this function is executed:
> >
> >   	nSize	15
> >	nBlockUse	1
> >	szFileName	0x5f4ccb18 "strcore.cpp"
> >	nLine	118
> >	blockSize	51
> >	fIgnore	0
> >	lRequest	-1
> >	pHead	0x015f55c0
> >	_bCleanLandFill	205 'Í'
> >	nSize	15
> >	pHead	0x015f55c0
> >
> >And after this it returns to the following function where it was called :
> >
> >void * __cdecl _nh_malloc_dbg (
> >        size_t nSize,
> >        int nhFlag,
> >        int nBlockUse,
> >        const char * szFileName,
> >        int nLine
> >        )
> >
> >{
> >
> >  // some stmts
> >  ....
> >  ....
> >  /***** this is where it was called *****/
> >   pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine); 
> >    
> >// some more stmts
> >
> >/*******Values of variables 
> >Values of variables after exec this function.
> >
> >	nhFlag	0
> >	pvBlk	0x015f55e0
> >*******************/
> >/******* the following if stmt is executed to return the value pvBlk *******/
> > if (pvBlk || nhFlag == 0)
> >                return pvBlk;
> >
> >            /* call installed new handler */
> >            if (!_callnewh(nSize))
> >                return NULL;
> >
> >            /* new handler was successful -- try to allocate again */
> >        }
> >
> >}
> > 
> >
> >   /******After executing the above  function, it returns to the following 
> >caller function 
> >****************/
> >_CRTIMP void * __cdecl _malloc_dbg (
> >        size_t nSize,
> >        int nBlockUse,
> >        const char * szFileName,
> >        int nLine
> >        )
> >{
> >        void *res = _nh_malloc_dbg(nSize, _newmode, nBlockUse, szFileName, 
> >nLine);
> >        return res;
> >}
> >
> >/*******************************************************
> >This returns res which is a non zero value 	res=0x015f55e0
> >******************************************************/
> >
> >/*****After this it returns to the following function in AFXMEM.CPP******/
> >void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int 
> >nLine)
> >
> >{
> >
> >   // some stmts
> >for (;;)
> >	{
> >		pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
> >		if (pResult != NULL)
> >			return pResult;  
> >            /**** returns pResult - a non zero value in the stmt above 
> >**********/
> >             // some more  stmts
> >            ......
> >           .....
> >      }
> >
> >/******Then returns to the following function********/
> > void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
> >{
> >	return ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
> >
> >
> >/******* Then returns to the function in strcore.cpp file ************/
> >void CString::AllocBuffer(int nLen) 
> >{ 
> >    // some stmts
> >   	{
> >                     /********* it was called in this stmt **********/
> >			pData = (CStringData*)
> >				new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
> >			pData->nAllocLength = nLen;
> >		}
> >		pData->nRefs = 1;
> >		pData->data()[nLen] = '\0';
> >		pData->nDataLength = nLen;
> >		m_pchData = pData->data();
> >	}
> >}
> >
> >/*******Values of variables after function finishes exec 
> >m_pchData	0x015f55ec "ÍÍ"
> >pData	0x015f55e0
> >this	0x01ecfb8c {"ÍÍ"}
> >	CStringData::data returned	0x015f55ec "ÍÍ"
> >********************/
> >/***** returns to the following function *****/
> >CString::CString(LPCTSTR lpsz)
> >{
> >	//some stmts
> >        .......
> >		if (nLen != 0)
> >		{
> >                       /***** called in the stmts below ******/
> >			AllocBuffer(nLen);   
> >			memcpy(m_pchData, lpsz, nLen*sizeof(TCHAR));
0
PunitKaur (24)
5/3/2007 6:40:02 PM
Punit Kaur schrieb:

> I think you misunderstood.
> 
> The break occurred here :
> 
> 
> /* break into debugger at specific memory allocation */
> if (lRequest == _crtBreakAlloc)
>   _CrtDbgBreak(); 
> 
> and not in the "if" stmt above this one that checks the value of 
> _CRTDBG_CHECK_ALWAYS_DF.
> 
> And the message always says "user breakpoint called at xyz". Why does it 
> call it user breakpoint. I haven't set any breakpoints in my application.
> 
> Sorry if I conveyed it wrong in the previous post. I would like to know if 
> whatever you explained is still valid for this case?

The debugger message about the user breakpoint is misleading.
The code you post is a memory check function inside of the C runtime library. 
The debug code in the library detectes one of the conditions Joseph explained. 
But now the dug code wants to tell the user (you) what happened, and give you a 
chance to look at the call stack and variables. The only way for library code to 
halt the debugger is to generate a breakpoint. It does so by calling 
_CrtDbgBreak(). This function contains the same opcodes that the debugger 
injects into the app when you set a real breakpoint.
That's why the debugger reports a "user breakpoint".

All the other things that Jo told you still apply.

Norbert

0
nunterberg (207)
5/3/2007 7:57:08 PM
Well, in that case, it is supposed to, because the value of lRequest == the value in
_crtBreakAlloc.  Now, the question is, who set those values.  Note that _lRequestCur
should not be -1 unless you have managed to allocate 4.2billion times, which is a lot of
years of allocation requests.  _crtBreakAlloc is initialized to -1, but how did
_lRequestCurr get set to -1?  If it has this value, it has been set erroneously, probably
by a memory overwrite.  It is initialized to 1 and increments on each allocation (this is
where those {112234} style numbers appear in the storage leak dump: they are the
allocation number).  It can't be reset to -1 by any known mechanism short of a bug.  So
set a value breakpoint on that location and set it to stop when the value is set to -1.
					joe

On Thu, 3 May 2007 11:40:02 -0700, Punit Kaur <PunitKaur@discussions.microsoft.com> wrote:

>
>I think you misunderstood.
>
>The break occurred here :
>
>
>/* break into debugger at specific memory allocation */
>if (lRequest == _crtBreakAlloc)
>  _CrtDbgBreak(); 
>
>and not in the "if" stmt above this one that checks the value of 
>_CRTDBG_CHECK_ALWAYS_DF.
>
>And the message always says "user breakpoint called at xyz". Why does it 
>call it user breakpoint. I haven't set any breakpoints in my application.
>
>Sorry if I conveyed it wrong in the previous post. I would like to know if 
>whatever you explained is still valid for this case?
>
>Thank you.
>---------------------------------------------------------------------------
>
>
>"Joseph M. Newcomer" wrote:
>
>> See below...
>> 
>> On Thu, 3 May 2007 08:12:03 -0700, Punit Kaur <PunitKaur@discussions.microsoft.com> wrote:
>> 
>> >ok.. here are more details: the message box says "User Breakpoint called from 
>> >code at 0x10212ad0", and it breaks into the dbgheap.c file in the following 
>> >function :
>> >
>> > void * __cdecl _heap_alloc_dbg(size_t nSize, int nBlockUse, const char * 
>> >szFileName, int nLine)
>> >{
>> >
>> >   long lRequest;
>> >        size_t blockSize;
>> >        int fIgnore = FALSE;
>> >        _CrtMemBlockHeader * pHead;
>> >
>> >        /* verify heap before allocation */
>> >        if (_crtDbgFlag & _CRTDBG_CHECK_ALWAYS_DF) //*** THIS LINE (see at end)
>> >            _ASSERTE(_CrtCheckMemory());
>> >
>> >        lRequest = _lRequestCurr; 
>> >
>> >/***********************************************
>> >this is where it breaks, at the "if" statement. , the values of lRequest and 
>> >_crtBreakAlloc =-1
>> >*************************************************/
>> >    /* break into debugger at specific memory allocation */
>> >        if (lRequest == _crtBreakAlloc)
>> >            _CrtDbgBreak();
>> *****
>> This looks like the contents of the block, which are expected to be 0xDFDFDFDF...DFDFDF
>> are in fact not that value.  This can be caused by either of two problems.  The first is
>> that you have done something like
>> 	whatever * p = new whatever;
>> 	... use it
>>   	delete whatever;
>> 	p->field = ...;
>> 
>> which is called the "dangling pointer" problem.  One way to avoid this is that immediately
>> after doing a delete, you set the pointer field to NULL, which will catch such errors.
>> 
>> Another possible cause is that you did an allocation of n bytes and wrote m > n bytes,
>> overwriting the 0xDFDFDF...DFDF of a free block.  Look for memory overwrites.
>> 
>> Beyond this point, nothing else is interesting.  The heap is trashed.
>> 
>> I suggest trying the Application Verifier to help track this down.  Download it from the
>> Microsoft Web site (search for Application Verifier)
>> 				joe
>> *****
>> >
>> >/********************************************************
>> >here onwards it does not execute the stmts inside "if"
>> >*******************************************************/
>> ****
>> At this point, single stepping into the call might have been informative.
>> ****
>> >/* forced failure */
>> >        if (!(*_pfnAllocHook)(_HOOK_ALLOC, NULL, nSize, nBlockUse, lRequest, 
>> >szFileName, nLine))
>> >        {
>> >            if (szFileName)
>> >                _RPT2(_CRT_WARN, "Client hook allocation failure at file %hs 
>> >line %d.\n",
>> >                    szFileName, nLine);
>> >            else
>> >                _RPT0(_CRT_WARN, "Client hook allocation failure.\n");
>> >
>> >            return NULL;
>> >        }
>> >
>> > /* cannot ignore CRT allocations */
>> >        if (_BLOCK_TYPE(nBlockUse) != _CRT_BLOCK &&
>> >            !(_crtDbgFlag & _CRTDBG_ALLOC_MEM_DF))
>> >            fIgnore = TRUE;
>> >
>> >        /* Diagnostic memory allocation from this point on */
>> >
>> >        if (nSize > (size_t)_HEAP_MAXREQ ||
>> >            nSize + nNoMansLandSize + sizeof(_CrtMemBlockHeader) > 
>> >(size_t)_HEAP_MAXREQ)
>> >        {
>> >            _RPT1(_CRT_ERROR, "Invalid allocation size: %u bytes.\n", nSize);
>> >            return NULL;
>> >        }
>> >
>> >        if (!_BLOCK_TYPE_IS_VALID(nBlockUse))
>> >        {
>> >            _RPT0(_CRT_ERROR, "Error: memory allocation: bad memory block 
>> >type.\n");
>> >        }
>> >/******************************************************
>> >until here  in all the above "if" statements, the stmts inside "if" are not 
>> >executed
>> >******************************************************/
>> >/****** it allocates block size ***************/        
>> >blockSize = sizeof(_CrtMemBlockHeader) + nSize + nNoMansLandSize;
>> >
>> >#ifndef WINHEAP
>> >        /* round requested size */
>> >        blockSize = _ROUND2(blockSize, _GRANULARITY);
>> >#endif  /* WINHEAP */
>> >
>> >        pHead = (_CrtMemBlockHeader *)_heap_alloc_base(blockSize);
>> >
>> >        if (pHead == NULL)
>> >            return NULL;
>> >
>> >        /* commit allocation */
>> >
>> >        ++_lRequestCurr; 
>> >/**** at this point after applying the increment operator, the value of 
>> >_lRequestCurr = 0********/
>> >
>> >/***** does not execute the stmts in the following if block since fIgnore =0 
>> >***/
>> >        if (fIgnore)
>> >        {
>> >            pHead->pBlockHeaderNext = NULL;
>> >            pHead->pBlockHeaderPrev = NULL;
>> >            pHead->szFileName = NULL;
>> >            pHead->nLine = IGNORE_LINE;
>> >            pHead->nDataSize = nSize;
>> >            pHead->nBlockUse = _IGNORE_BLOCK;
>> >            pHead->lRequest = IGNORE_REQ;
>> >        }
>> >        else {
>> >            /* keep track of total amount of memory allocated */
>> >            _lTotalAlloc += nSize;
>> >            _lCurAlloc += nSize;
>> >
>> >            if (_lCurAlloc > _lMaxAlloc)
>> >                _lMaxAlloc = _lCurAlloc;
>> >
>> >            if (_pFirstBlock)
>> >                _pFirstBlock->pBlockHeaderPrev = pHead;
>> >            else
>> >                _pLastBlock = pHead;
>> >
>> >            pHead->pBlockHeaderNext = _pFirstBlock;
>> >            pHead->pBlockHeaderPrev = NULL;
>> >            pHead->szFileName = (char *)szFileName;
>> >
>> >     /**** Here the szFileName has strcore.cpp as its value *****/
>> >
>> >            pHead->nLine = nLine;
>> >            pHead->nDataSize = nSize;
>> >            pHead->nBlockUse = nBlockUse;
>> >            pHead->lRequest = lRequest;
>> >
>> >            /* link blocks together */
>> >            _pFirstBlock = pHead;
>> >        }
>> >
>> > /*** executes everything below with no problems ****/
>> >
>> >        /* fill in gap before and after real block */
>> >        memset((void *)pHead->gap, _bNoMansLandFill, nNoMansLandSize);
>> >        memset((void *)(pbData(pHead) + nSize), _bNoMansLandFill, 
>> >nNoMansLandSize);
>> >
>> >        /* fill data with silly value (but non-zero) */
>> >        memset((void *)pbData(pHead), _bCleanLandFill, nSize);
>> >
>> >        return (void *)pbData(pHead);
>> >
>> >}
>> >
>> >Here are the values of the variables after this function is executed:
>> >
>> >   	nSize	15
>> >	nBlockUse	1
>> >	szFileName	0x5f4ccb18 "strcore.cpp"
>> >	nLine	118
>> >	blockSize	51
>> >	fIgnore	0
>> >	lRequest	-1
>> >	pHead	0x015f55c0
>> >	_bCleanLandFill	205 '�'
>> >	nSize	15
>> >	pHead	0x015f55c0
>> >
>> >And after this it returns to the following function where it was called :
>> >
>> >void * __cdecl _nh_malloc_dbg (
>> >        size_t nSize,
>> >        int nhFlag,
>> >        int nBlockUse,
>> >        const char * szFileName,
>> >        int nLine
>> >        )
>> >
>> >{
>> >
>> >  // some stmts
>> >  ....
>> >  ....
>> >  /***** this is where it was called *****/
>> >   pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine); 
>> >    
>> >// some more stmts
>> >
>> >/*******Values of variables 
>> >Values of variables after exec this function.
>> >
>> >	nhFlag	0
>> >	pvBlk	0x015f55e0
>> >*******************/
>> >/******* the following if stmt is executed to return the value pvBlk *******/
>> > if (pvBlk || nhFlag == 0)
>> >                return pvBlk;
>> >
>> >            /* call installed new handler */
>> >            if (!_callnewh(nSize))
>> >                return NULL;
>> >
>> >            /* new handler was successful -- try to allocate again */
>> >        }
>> >
>> >}
>> > 
>> >
>> >   /******After executing the above  function, it returns to the following 
>> >caller function 
>> >****************/
>> >_CRTIMP void * __cdecl _malloc_dbg (
>> >        size_t nSize,
>> >        int nBlockUse,
>> >        const char * szFileName,
>> >        int nLine
>> >        )
>> >{
>> >        void *res = _nh_malloc_dbg(nSize, _newmode, nBlockUse, szFileName, 
>> >nLine);
>> >        return res;
>> >}
>> >
>> >/*******************************************************
>> >This returns res which is a non zero value 	res=0x015f55e0
>> >******************************************************/
>> >
>> >/*****After this it returns to the following function in AFXMEM.CPP******/
>> >void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int 
>> >nLine)
>> >
>> >{
>> >
>> >   // some stmts
>> >for (;;)
>> >	{
>> >		pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
>> >		if (pResult != NULL)
>> >			return pResult;  
>> >            /**** returns pResult - a non zero value in the stmt above 
>> >**********/
>> >             // some more  stmts
>> >            ......
>> >           .....
>> >      }
>> >
>> >/******Then returns to the following function********/
>> > void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
>> >{
>> >	return ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
>> >
>> >
>> >/******* Then returns to the function in strcore.cpp file ************/
>> >void CString::AllocBuffer(int nLen) 
>> >{ 
>> >    // some stmts
>> >   	{
>> >                     /********* it was called in this stmt **********/
>> >			pData = (CStringData*)
>> >				new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
>> >			pData->nAllocLength = nLen;
>> >		}
>> >		pData->nRefs = 1;
>> >		pData->data()[nLen] = '\0';
>> >		pData->nDataLength = nLen;
>> >		m_pchData = pData->data();
>> >	}
>> >}
>> >
>> >/*******Values of variables after function finishes exec 
>> >m_pchData	0x015f55ec "��"
>> >pData	0x015f55e0
>> >this	0x01ecfb8c {"��"}
>> >	CStringData::data returned	0x015f55ec "��"
>> >********************/
>> >/***** returns to the following function *****/
>> >CString::CString(LPCTSTR lpsz)
>> >{
>> >	//some stmts
>> >        .......
>> >		if (nLen != 0)
>> >		{
>> >                       /***** called in the stmts below ******/
>> >			AllocBuffer(nLen);   
>> >			memcpy(m_pchData, lpsz, nLen*sizeof(TCHAR));
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/3/2007 9:03:30 PM
Reply:

Similar Artilces:

WAB and Office 2k3 problem
Greetings All: I've Outlook 2003 connected to an Exchange 2003 server. The only addresses that appear in my address book are the Global Addresses from the server, my contacts do not appear. Now when I go to the appropriate "Outlook Address Book" tab in the contacts properties dialog, the "Show this folder as an e-mail Address Book" checkbox is grayed out. I have several other contact folders that exhibit the same grayed out checkbox. If I try to add them from the Options dialog in the Address Book specifically, they don't even show up in the as being avail...

money 2006 problems importing from bank
whenever I import information from my bank uccu, it says that the import is complete and that I have one statement to read with 150 transactions to review, but when it opens to the account register, none of the new transactions show up. It shows the correct amount and date from my bank in the left hand corner, and it says that I still have 150 transactions to review. I have tried changing the online settings, emptying the temporary internet files, repairing the money file, and setting the account register to show all transactions, but so far nothing has worked. I have been able to i...

Money2004 (No MSN, no Passport) -> Monwy2006 Any problems?
I use M2004 without MSN, Passport or passwords. My financial institutions (Citi cards, Fidelity, Bank One) download into M2004 without any problems. Will I be able to transition into M2006 without any problems? I'll be happy to maintain the current M2004 features and capabilities. I'm thinking of M2006 only because the on-line stuff for M2004 will expire next year. -- Aloke ---- to reply by e-mail remove 123 and change invalid to com I imported without a problem but cannot now use MSN. I did not before and did not have a Passport. Adding the Passport works but synching with MS...

Where Does Outlook Store Info? Computer Problems
Recently the power supply, motherboard, & CPU on my computer died. So I had a new motherboard, power supply, CPU and hard drive installed. The new hard drive is larger and faster than the old one. This required that Windows XP, Microsoft Office, etc, had to be installed. But before any of that was done, the technician took everything off the old hard drive and saved it into a file on the new one. All of the old data files, etc, are supposed to be there. My question, though, is how to find the address book and the saved emails that were on the old computer & put them into Outlook on the...

Update Download problem
I downloaded the latest update for Outlook 2000. I did NOT have the installation cd handy. Okay, usually no problem, the instal quits. However this time, it did quit, yet now I am unable to open excel. It launches the instal program. The download was for Outlook. It has me boggled. Outlook, Word and Access open with no known problems. I have tried to open excel different times/ways. It continues to try to load the update. Any reasoning on the subject??? Thanks* ...

Bank Recon GP 10 problem
Hi We are a VAR that's upgraded one client to GP 10 and installed GP 10 for another new client, both on SQL 2000. In both cases there's an incorrect balance showing for Cashbook Balance field (cashbook maintenance screen) using the Bank Recon module. Also the cashbook balance is not re-calculated (recon screen) when "Incl Trans To Date" field is changed, for both clients. We can update the balance in Cashbook Master table (CM00100) in SQL but this doesn't solve the problem. Any suggestions? ...

Protection Problem #3
I have a 3 sheet excel file with protection on all 3 sheets (let's call them A, B and C). These 3 pages have formulas that link to each other. Sheet A has a few checkboxes that link to sheet C. The problem is that when I try to check any of the check boxes on sheet A an error box pops up that says "The cell or chart you are trying to change is protected and therefore read only". Is there a way to protect a sheet while being able to check a box off that is linked to another sheet? What protection options would allow me to do this? Thanks in advance. Dave -- Dave123 ----------...

Connectivity Problems
Sorry about the length of this post, but I have no idea what I'm talking about, let alone explain it! We have two sites (Head Office and Remote) with a Netgear FVS338 VPN firewall at each end. The remote site connects via a Terminal Server and runs a couple of EPOS systems. Our setup in the Head Office is thus: Workstation -> SBS 2003 R2 Standard -> FVS338 VPN Firewall -> Internet Router Recently, the VPN keeps dropping and if I set up a permanent ping I can see that several times a day we get 7 or 8 pings timing out. This is enough to kill the EPOS connect...

The instruction at "0x77fc8fe3" referenced memory at "0x00746e69"
Does anyone know what this is from. It occurs at the end of the install when starting the crmsecurity service. Before the installation finishes the install crashes. Yes, I get the famous 80004005 error which I researched endlessly. Nevertheless, CRM is running into something on my system. Keith ...

problem with csv
When I export from a database I get the top line all in csv which appears to be in row A (which is the names of all the columns and the rest of the sheet is correct with all the data in relevant columns. How do I split that top row (which is Comma Separated) into coulumns automatically. I'm sure it is a simply process. thanks plato There is an easy way in Excel to split apart a cell without having to re-type its contents. Click on the cell. Pull-down Data > Text to Columns... > then check delimited and next check comma. The single cell should then split. Good Luck -- G...

Multiple problems with WLM
Multiple problems with WLM I realize that this problems list is long enough that it's unlikely that just one person will be able to solve them all. Therefore, it's OK to reply only for the one you can handle. Since some of these problems may be related, I decided to list them all in one post. 1. The All news view in the Quick views is either mislabelled, or unable to handle very large collections of unread newsgroups posts (I first saw this problem when the count was over 1,000,000, WLM was restarted, and the count dropped much lower (under 50,000). Since then I&#...

Moving Range Problem
Hi all, I'm trying to build a 6 Sigma control chart into an excel workbook. In order to do this i need to be able to work out a formula for the moving range. I need the following : Eg Data sample : 210 , 425 , 600 , 550 , 450 , 470 The moving range is the distance from second to the first, third to the second etc eg A B C D E F Data Sample 210 , 425 , 600 , 550 , 450 , 470 Moving Range 215, 175 , 50 , 100 , 20 The problem I'm having is trying to get excel to work it out. If say 210 was in A1 i ...

Allocation Method set to None
Not sure I understand Allocation Method set to None. Orders must be allocated before they can be fulfilled. So what exactly does setting Allocation Method set to None do? How then does the order get allocated? Thx ...

Timesheet Problem #2
I am trying to populate a timesheet with dates depending on the start date in B2. If B2 is the 16th of the month of Sept, I don't want anything to show up on the calendar for the 31th (blank in other words). Here is the formula I am using, but not working. Help. TIA =IF(($B$2)="","31",IF(EOMONTH(B2,0)=TEXT(($B$2)+ROW()-14,"DDD dd"),"",TEXT(($B$2)+ROW()-14,"DDD dd"))) Greg Hi Greg, With seed date in cell $B$2 and using rows down to leave the 31st blank. But show all other dates no exceptions for weekends and holidays. EOMONTH is in ...

Pivot Table Refresh error "Problems Obtaining Data"
I can't seem to get data or change the data source. When I refresh, I get the error message "Problems Obtaining Data" When I start the Pivot Table Wizard, the back button is grayed out so that I can't go back and change data sources. Any help is appreciated. ...

Admin Problem from 5.5 to 2k3 Exchange
We just migrated all of our email boxes to Exchange 2k3 from Exchange 5.5. Now our administrators can't look at any of the users outlook information unless they are given the rights from that users. Before the administrators could look at the persons information and remove or help the people with problems and questions if need be. How can our Administrators gain access to these exchange boxes again? There are several articles out there on this. In E2K3, domain admins and enterprise admins are explicitly denied this access. There are work arounds. try this: http://www.winnetma...

XML DATASET problem
I am having big problem manipulating XML in a dataset. I am reading in a schema based on the following XML document. The minute I try to e.g. create a new row I get 'Object reference not set to an instance of an object' error <?xml version="1.0" encoding="utf-8"?> <DocumentElement xmlns="http://tempuri.org/dseditted2.xsd"> <TableInfo> <FieldName>column value</FieldName> <ControlType>column value</ControlType> <IsNull>column value</IsNull> <MaxLength>column value</MaxLength> </TableInfo&g...

Problem with external data and #reference error
Hi, my Excel workbook has 2 sheets: 1. Source: with an external data reference to a MS Access database Query property "If number of rows changes after refresh" is set to option #1: "Insert cells for new data, delete unused cells" User chooses external query selection criteria and therefore can have different result sets. 2. Target: Formular B4: =Source!P5 Formular B5: =Source!P6 Formular B6: =Source!P7 Problem: When Source has data in rows 5, 6 and 7 formular gets calculated correctly. If Source row #5 has data and #6 and ...

Problem with copying and pasting tasks and keeping predecessors in
I am doing a consulting project for an organization that has a bit of an unusual request. We are doing a conversion from an old mail system to Microsoft Exchange 2007. We have developed a checklist for the technicians to follow with about 50 detailed tasks (things like, "Open up Exchange Management Console", "Assure the 'Forward' Button is unchecked", etc.). The CIO expects me to enter each of the tasks from the checklist into the project plan. Instead of having a line on the project plan with a task, "Covert Leroy Smith's Mailbox" wi...

Charting Problem #2
I have a problem with charting a Dynamic chart. I goes ok to set up the dynamic function as a range. It also shows the correct series. The range is as follows: =OFFSET(Sheet3!$A$1;1;Sheet3!$P$2-1;COUNTA(INDIRECT("C"&Sheet3!$P$2;FALSE));1) Where P2 is an input from a listbox, and the name of the range is: Sheet3!Dato. When I try to change the reference for the series i get the following message: "Your formula contains an invalid external reference to a worksheet. Verify the path, workbook, and range name or cell reference are correct, and try again." The serie...

Case strFormat = acFormatRTF, Problem
All my other Case scenarios are working except fpr "Word". But word is working on another case code on another form Can any see why this word not work? Case "WORD" strFormat = acFormatRTF ------------------------------------------------- Private Sub SendMailButton_Click() On Error GoTo ErrorHandler If Me.Dirty = True Then Me.Dirty = False End If Dim lngID As Long, strMail As String, strBodyMsg As String, _ blEditMail As Boolean, sndReport As String, strCompany As String Dim msgPmt As String, msgBtns As Integer, msgTitle As ...

XmlDataDocument problem
Hi, I have a problem reading xml into a dataset using the XmlDataDocument. In a test project, I created the following xml file: <?xml version="1.0" standalone="yes"?> <Customer> <OrderDetails> <OrderID>5</OrderID> <ProductID>6</ProductID> </OrderDetails> </Customer> And I use the following code to read it: TestDataSet ds = new TestDataSet(); // TestDataSet is a typed dataset with 1 table "OrderDetails", with 1 column "OrderID" System.Xml.XmlDataDocument doc = new System.Xml.XmlDataDocument(d...

Outlook Calendar views problem
Hey all... going to describe this to the best of my ability... but its one of those 'a picture would be worth a 1000 words' deals. Outlook Calendar views. We have a calendar shared among our entire company. In that Calendar we wish to create a timeline view availbale to anyone with permissions to view the calendar. We have created this view called 'timeline' and it appears that it is available to users of that folder. Sort of. Its there, but in teh outlook calendar / shared calendar / views pane, the view will ONLY show up when the calendars are in a timeline state as oppose...

Problems with Lead/Contact sharing?
Has anyone else had problems with Leads/Contact sharing themselves between users for no reason? We're having some issues where our leads/contacts are randomly being shared between SCs and TSCs. Doesn't make any sense at all... We had the same problem with Opportunities being shared without anyone actually sharing them. We poked around at it a bit and discovered that when a record is Assigned to another sales person, the person doing the assigning is automatically setup with sharing on that record. Our problem is that we can't seem to figure out how to get rid of the sharin...

sign-in Problems with Money Plus 2007
I changed my MS Passport Password and now can't log in to online Money. I have to use my old passport password to log in to Money but neither works to go to online services. How do I resynchronize the passwords? -- Manticorr In microsoft.public.money, Manticorr wrote: >I changed my MS Passport Password and now can't log in to online Money. I >have to use my old passport password to log in to Money but neither works to >go to online services. How do I resynchronize the passwords? Hold on to you backup files. You may want to increase the number of backup files f...