0

I'm trying to create a mailbox on a Windows 7 OS in Eclipse IDE and in debug mode. I'm trying to create a RTOS(Real time operating system) like mailbox in Windows using Eclipse.

This is what my code for the mailbox looks like so far:

RTX_Mailbox RTX_CreateMailbox (unsigned long nSlotSize, unsigned long nSlots, char* szName)
{
    ::EnterCriticalSection (&csMailboxLock);
    CMailBox* pNewMailbox = new CMailBox (nSlotSize, szName);
    aMailBoxes.push_back (pNewMailbox);
    RTX_Mailbox mailBox = ((unsigned int)aMailBoxes.size ()) - 1;
    ::LeaveCriticalSection (&csMailboxLock);
    return mailBox;
}

My application keeps crashing on run-time as soon as it hits ::EnterCriticalSection(&csMailboxLock);

It returns this error message(highlighted in the pic attached):

enter image description here

Error message in text: No source available for ntdll!TpCallbackMayRunLong() at 0x77d78e19

Please let me know if further details are required...

Clifford
  • 88,407
  • 13
  • 85
  • 165
Algorithmic
  • 138
  • 12
  • 1
    The "picture" of your error message is unreadable. The error message is plain text - what's so hard about copy & pasting it as text directly into the question? – Clifford Sep 23 '14 at 18:41
  • Its not unreadable on my PC and I've answered questions like this before. I put the picture up because I thought it would show more details and would be more comprehensible.Is this why you've down voted my question?? Did you even look down to find that I had found a solution?? If you can't help, at least don't be mean for no good reason. – Algorithmic Sep 24 '14 at 09:14
  • I am not sure how letting you know that essential information in your question is not readable is "being mean". You are right however; if I set the Zoom in my browser to 250% it is legible! You might have reduced the window size to reduce the redundant space, but I suggest text messages are still best rendered as text. The readability may explain why you had to answer the question yourself. – Clifford Sep 24 '14 at 11:23
  • I'm not sure if you downgraded the question or if this happens through some other mechanism on the site that I don't know about but its the downgrading that I thought was just uncalled for. I will put my error messages in text from now on as you've suggested. In the meantime, I'd appreciate it if you could upgrade my question back(if you have any control over this). Also, I edited the question to include the error message. I'll keep in mind that most people won't bother zooming into pictures posted with the question. – Algorithmic Sep 25 '14 at 12:28
  • I could not withdraw the down-vote until the question was edited - done. The mechanisms of commenting, editing and voting are intended to maintain the quality of Q&A on SO so that questions are generally useful to the community. No offence was intended, but SO is not a discussion forum - it works differently. – Clifford Sep 25 '14 at 20:21

2 Answers2

1

So I did find a solution if anyone else had the same issue.

Turns out you need to initialize the Critical Section before you use it. So the following fixed it:

InitializeCriticalSection(&csMailboxLock);

This is the link that helped me: https://sites.google.com/site/jeff00coder00seattle/home/coding/cpp-coding/c-win32-critical-section-example

Algorithmic
  • 138
  • 12
1

The "error message" is not an error message, it simply indicates that the source for the current program-counter location (inside an OS call) is not available.

The documentation for EnterCriticalSection is pretty clear:

Before using a critical section, some thread of the process must call InitializeCriticalSection or InitializeCriticalSectionAndSpinCount to initialize the object.

I would advise consulting the documentation first in such cases.

Clifford
  • 88,407
  • 13
  • 85
  • 165