Click here to Skip to main content
15,894,405 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
General_beginthreadex() problem... Pin
jhoin17-Dec-03 4:04
jhoin17-Dec-03 4:04 
GeneralRe: _beginthreadex() problem... Pin
John M. Drescher17-Dec-03 4:19
John M. Drescher17-Dec-03 4:19 
GeneralRe: _beginthreadex() problem... Pin
jhoin18-Dec-03 23:15
jhoin18-Dec-03 23:15 
GeneralRe: _beginthreadex() problem... Pin
John M. Drescher19-Dec-03 8:07
John M. Drescher19-Dec-03 8:07 
GeneralRe: _beginthreadex() problem... Pin
jhoin19-Dec-03 9:05
jhoin19-Dec-03 9:05 
GeneralRe: _beginthreadex() problem... Pin
John M. Drescher19-Dec-03 9:40
John M. Drescher19-Dec-03 9:40 
GeneralRe: _beginthreadex() problem... Pin
valikac17-Dec-03 4:55
valikac17-Dec-03 4:55 
GeneralRe: _beginthreadex() problem... Pin
jhoin18-Dec-03 23:26
jhoin18-Dec-03 23:26 
Here is the code which has been pared down a bit to get rid of unrelated initialization:

(one note: this routine itself was started as a thread so it is second in line and is trying to start a third thread.)

unsigned __stdcall micro_main(void *dummy)
{
unsigned threadID;

//other unrelated code

PSECURITY_DESCRIPTOR pSD;
SECURITY_ATTRIBUTES sa;

pSD = (PSECURITY_DESCRIPTOR) LocalAlloc( LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);

if (pSD == NULL)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL, GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}

if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL, GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}

if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE))
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL, GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}

sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = TRUE;
MICRO_THREAD_SUB = (HANDLE)_beginthreadex( &sa, 0, &sub_main_MACRO_CONTROL, NULL, 0, &threadID );
if (MICRO_THREAD_SUB == 0)
{
// it is here that that I always get the error
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL, GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}
else
{
WaitForSingleObject(MICRO_THREAD_SUB,INFINITE);
CloseHandle(MICRO_THREAD_SUB);
}

// _endthreadex(0);
}

/*this is the thread which is called which immediately calls another thread-could that char com[200000]; be part of the problem? (it was used for some early debugging and no longer has any functionality.*/

unsigned __stdcall sub_main_MACRO_CONTROL(void *dummy)
{
char com[200000];

Run_Parser_Simulation(Sim->MACRO);

// _endthreadex(0);
return 0;
}

Thanks for looking at this. Regards,

Jay
GeneralRe: _beginthreadex() problem... Pin
valikac19-Dec-03 4:54
valikac19-Dec-03 4:54 
GeneralRe: _beginthreadex() problem... Pin
jhoin19-Dec-03 5:11
jhoin19-Dec-03 5:11 
GeneralRe: _beginthreadex() problem... Pin
Anthony_Yio17-Dec-03 17:25
Anthony_Yio17-Dec-03 17:25 
GeneralRe: _beginthreadex() problem... Pin
jhoin18-Dec-03 23:27
jhoin18-Dec-03 23:27 
GeneralRe: _beginthreadex() problem... Pin
Anthony_Yio18-Dec-03 23:59
Anthony_Yio18-Dec-03 23:59 
GeneralRe: _beginthreadex() problem... Pin
jhoin19-Dec-03 5:06
jhoin19-Dec-03 5:06 
Generalneed urgent help! Pin
YaronNir17-Dec-03 3:37
YaronNir17-Dec-03 3:37 
GeneralRe: need urgent help! Pin
mightyCoCo17-Dec-03 3:58
mightyCoCo17-Dec-03 3:58 
GeneralRe: need urgent help! Pin
YaronNir17-Dec-03 4:00
YaronNir17-Dec-03 4:00 
GeneralRe: need urgent help! Pin
Don Kackman17-Dec-03 4:11
Don Kackman17-Dec-03 4:11 
GeneralRe: need urgent help! Pin
YaronNir17-Dec-03 4:23
YaronNir17-Dec-03 4:23 
GeneralRe: need urgent help! Pin
Don Kackman17-Dec-03 4:29
Don Kackman17-Dec-03 4:29 
GeneralRe: need urgent help! Pin
YaronNir17-Dec-03 4:44
YaronNir17-Dec-03 4:44 
GeneralRe: need urgent help! Pin
Don Kackman17-Dec-03 5:04
Don Kackman17-Dec-03 5:04 
GeneralRe: need urgent help! Pin
YaronNir17-Dec-03 5:06
YaronNir17-Dec-03 5:06 
GeneralRe: need urgent help! Pin
Don Kackman17-Dec-03 5:11
Don Kackman17-Dec-03 5:11 
GeneralRe: need urgent help! Pin
YaronNir17-Dec-03 5:25
YaronNir17-Dec-03 5:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.