Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi thread help!!!!!!!!!!

Status
Not open for further replies.

ceodav

Programmer
Feb 21, 2003
106
IT
hi anybody,
i really need help to solve a little proble with my multi thread application.....
I'm using afxbeginthread (visual c++ )to process a simple loop in background. The sintax is ok, but when i lounch the exe file i got an acces memory violation.
why??????
i'm not able going through......
anybody could help me?

thanks.
bye

 
you know that's really difficult to answer. There could be a limitless amount of reasons for this happening, like:

1. Pointing to memory that doesn't exist or is not committed

2. In some way (read, write, execute) non-existant memory address

3. Attempting to access protected memory space

If your thread code is "okay" as you say, then I'd suggest tracing your code one line at a time and see exactly WHERE the access violation is occuring. Have you tried running the thread code on its own (ie. not via a spawned thread)?

As a side note, why not use _beginthreadex() to start your threads?


flipcode
 
Thank you for your answer.

unfortunately I cannot trace the code step by step because when i start the debug i got the access violation in mfc42d.dll. This happens before the compiler enters in main subroutine!!!!! This really strange.

I'll try with _beginthreadex as you suggest, but i'm working with cpp files, not c therefore i think there will be some problems.....

anyway..thank you very much.

ceodav
 
If you do not have any service pack installed you can get some strange ms bugs error. I sugest you install at least SP3 for Visual Studio although SP5 is available at Microsft's site.

(Note:if your error happens in CHtmlView class, that is a sure sign of MS bug that is fixed by service packs)

HTH, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top