|
I am "porting" C code into C++, mainly to gain an experience.
Run into this , undocumented , piece of code.
Did some reading and have basic understanding WHAT is suppose to do.
Preventing multiprocessors to clobber each other or multiple access to shared devices / memory.
So far my software is for single CPU and no sharing of I/O , not yet.
That is NOT my concern.
What I would like to know why it stops running the process PAST the first usage of
__sync_synchronize();
It compiles just fine.
<pre lang="c++">
__sync_synchronize();
STOPS HERE
ret = *paddr;
__sync_synchronize();
</pre>
Thanks
Cheers Vaclav
|
|
|
|
|
Hi,
You obviously have a race condition somewhere in your code. As you have probably discovered... that intrinsic function is a memory barrier.
There's no way to fix this without learning how to debug your code. If you are developing on the Windows platform then fire up WinDbg and attach it to the process and type '!locks'
Debugging a Deadlock[^]
Best Wishes,
-David Delaune
|
|
|
|
|
David, thanks for reply.
Upon further invetsigation I believe "my problem" is elsewhere in code since it stops on the line between the calls to the __sync_synchronize.
Vaclav
|
|
|
|
|
Well,
Yes; deadlocks, race conditions by the very definition means "somewhere else" is holding a lock.
You are looking at the code not me. But I wouldn't recommend using the "Current Line" in the source-view as my error indicator. You need to be looking at the callstack and instructions. My recommendations remain: Attach a debugger to the process. If you want an automated analysis of the deadlock you can attach WinDbg and do: analyze -v -hang
Are you developing on Windows? My mind reading skills are not working today.
Best Wishes,
-David Delaune
|
|
|
|
|
David,
I have "discovered" the real problem - nothing to do with
synchronization. ( see my recent "volatile misbehaves " post. )
I am sorry for wasting your time on this, my apology.
|
|
|
|
|
Is it possible to install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine. Will there be any problem.
|
|
|
|
|
I guess it is possible.
Why didn't you try?
|
|
|
|
|
I tried it...but installed VS2008 at the last. But i was unable to open the VS2008 project which was originally created in VS2008.
|
|
|
|
|
|
We had a project created in VS2008. When we copied the project to this machine, the project files and all associated files had the icon appearance changed to VS2013. And when we tried to open the project solution file (Originally created in VS2008), the VS2013 opens up and didnt have any files associated with the project in the solution explorer.
|
|
|
|
|
Did you try to first open the VS2008 IDE, and open the project from this IDE?
|
|
|
|
|
Yes. I tried in Vs2008 only
|
|
|
|
|
You have always been able to install Visual Studio in side by side format with earlier versions.
However that said unless you targetting windows O/S prior to XP or had a mountain of difficult legacy code there would be little point.
The free version of Visual Studio 2017 is much easier and going to cause you less problems than libraries written for the old windows O/S.
In vino veritas
|
|
|
|
|
Strange...
A few years back I had in my XP virtual machine VC++6.0, VS2008 and VS2010 installed. And I could choose any of them to build the project.
And I never saw the problem similar to what you have described.
|
|
|
|
|
Yes, but;
1) I highly suggest you install them from oldest to newest.
2) Do NOT open a solution by double-clicking in explorer. Rather, open the visual studio you want to use and then open the solution from there. Also be aware that once you move a solution to a newer version, you typically cannot move back.
Also note that starting with either 2013 or 2015, you can use an earlier toolset.
|
|
|
|
|
Hi. I am trying to get the source code of a web page in order to analyze it. And here is the code for code retrieving:
BOOL CCIFDoc::GetRemoteFile(CString sServer, CString sRemotePath, CString sParameter, CStringArray& saData)
{
BOOL bRet = FALSE;
CInternetSession ISession;
CInternetFile* pIFile = NULL;
CHttpFile* pHttpFile = NULL;
LPCTSTR lpszAccept[] = {_T("*/*"), NULL};
try
{
pIFile = (CInternetFile*)ISession.OpenURL(_T("http://") + sServer + sRemotePath + sParameter, 1, INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD);
if(NULL != pIFile)
{
CString sTemp;
while(pIFile->ReadString(sTemp))
saData.Add(sTemp + _T("\n"));
}
bRet = (saData.GetSize() > 0);
}
catch(CInternetException* pException)
{
pException->GetErrorMessage(m_sError.GetBuffer(_MAX_PATH), _MAX_PATH);
m_sError.ReleaseBuffer();
pException->Delete();
}
catch(CMemoryException* pMemException)
{
pMemException->GetErrorMessage(m_sError.GetBuffer(_MAX_PATH), _MAX_PATH);
m_sError.ReleaseBuffer();
pMemException->Delete();
}
if(NULL != pIFile)
{
pIFile->Close();
delete pIFile;
}
if(NULL != pHttpConnect)
{
pHttpConnect->Close();
delete pHttpConnect;
}
ISession.Close();
return bRet;
}
Classic code.
But there is some web pages which is retrieving without html body, or with other body than I have seen in my browser. Let's take an example: type www.bnr.ro in your browser, and see the page. But when I retrieve this address with code from above, here is the result:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Eroare/ Error</title>
<style type="text/css">
* { margin: 0; padding: 0; border: 0; outline: none; font-size: 100%; }
body { font-family: Arial, sans-serif; }
#wrapper { text-align: center; margin: 3em auto;}
p { padding: 0.5em 0; }
a { color: #0039a6; text-decoration: none; }
a:hover, a:focus { color: #e9994a; }
</style>
</head>
<body>
<div id="wrapper">
<a href="http://www.bnr.ro"><img src="http://www.bnr.ro/images/logo.png"></a>
<p>Eroare neprevazută / Unexpected error.</p>
<p><a href="http://www.bnr.ro">Înapoi pe prima pagină / Back to the homepage</a>.</p>
</div>
</body>
</html>
How can I retrieve the source code just I seen in my browser ?
Thank you.
modified 14-May-18 7:34am.
|
|
|
|
|
That is an error message. The server was not able to answer the request.
If you enter that address in your browser you should have noticed that it redirects to an ASPX page.
A possible reason might be that the server script tries to access a request header which is not present and the code does not handle that. Candidates are (among others) User-Agent , Content-Type , and Accept . But finally only the administrator of that web site can tell you.
|
|
|
|
|
Ok, and if I know them (User-Agent, Content-Type, etc.), how can I use it in OpenURL method ?
|
|
|
|
|
Fourth parameter of OpenURL() .
|
|
|
|
|
|
I have tried something like this:
_T("Cache-Control: no-store\r\nPragma: no-cache\r\nExpires: 0\r\nContent-Type: text/html; charset=utf-8\r\nX-UA-Compatible: IE=edge,chrome=1\r\nauthor: Ministerul Finantelor Publice\r\ndescription: \r\nkeywords: \r\n\r\n")
The same result … very strange …
|
|
|
|
|
And a similar problem, where I get only headers, without body web source: http://mfinante.ro/infocodfiscal.html[^]
and when I have tried to get the web source, where is the result:
<!DOCTYPE html>
<html><head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="-1"/>
<meta http-equiv="CacheControl" content="no-cache"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="data:;base64,iVBORw0KGgo="/>
<script>
(function(){
var securemsg;
var dosl7_common;
window.KBov=!!window.KBov;try{(function(){try{var ll,Ll,Ol=1,Sl=1,il=1,jl=1,Jl=1;for(var ZL=0;ZL<Ll;++ZL)Ol+=2,Sl+=2,il+=2,jl+=2,Jl+=3;ll=Ol+Sl+il+jl+Jl;window.JL===ll&&(window.JL=++ll)}catch(sL){window.JL=ll}var iL=!0;function lo(l){!l||document.visibilityState&&"visible"!==document.visibilityState||(iL=!1,document.cookie="brav=ad");return iL}function Lo(){}lo(window[Lo.name]===Lo);lo("function"!==typeof ie9rgb4);lo(/\x3c/.test(function(){return"\x3c"})&!/x3d/.test(function(){return"'x3'+'d';"}));
var Oo=window.attachEvent||/mobi/i.test(window["\x6e\x61vi\x67a\x74\x6f\x72"]["\x75\x73e\x72A\x67\x65\x6et"]),Io=+new Date+6E5,lO,LO,oO,zO=setTimeout,ZO=Oo?3E4:6E3;function SO(){if(!document.querySelector)return!0;var l=+new Date,z=l>Io;if(z)return lo(!1);z=LO&&!oO&&lO+ZO<l;z=lo(z);lO=l;LO||(LO=!0,zO(function(){LO=!1},1));return z}SO();
document.addEventListener&&document.addEventListener("visibilitychange",function(l){document.visibilityState&&("hidden"===document.visibilityState&&l.isTrusted?oO=!0:"visible"===document.visibilityState&&(lO=+new Date,oO=!1,SO()))});var iO=[17795081,27611931586,1558153217];function jO(l){l="string"===typeof l?l:l.toString(36);var z=window[l];if(!z.toString)return;var s=""+z;window[l]=function(l,s){LO=!1;return z(l,s)};window[l].toString=function(){return s}}for(var JO=0;JO<iO.length;++JO)jO(iO[JO]);
})();
</script>
<script type="text/javascript" src="/TSPD/08b919fd7aab200047a61aa409c2e6d600e069e74eb7044d6800f6e68db33d85b37ab015d70c1c5d?type=8"></script>
<script>
(function(){
var securemsg;
var dosl7_common;
window["blobfp"] = "1111111110112000003e825d0550f830000004a71d70c295b19a7f2005afaa33b00001c20eac9549cdc897b01acfc003937e6e0f02eceda17300000020http://re.security.f5aas.com/re/";
})();
</script>
<script type="text/javascript" src="/TSPD/08b919fd7aab200047a61aa409c2e6d600e069e74eb7044d6800f6e68db33d85b37ab015d70c1c5d?type=11"></script>
<noscript>Please enable JavaScript to view the page content.</noscript>
</head><body>
</body></html>
headers, without body ...
|
|
|
|
|
It is a valid reply and the important parts are the script tags which are executed by web browsers showing the final content. If JavaScript is disabled in a browser, the content of the noscript tag is shown:
<noscript>Please enable JavaScript to view the page content.</noscript>
That is the problem with todays web sites: They don't use plain HTML anymore.
Even well known tools like wget don't support JavaScript and can't be therefore used to download the "visible" content (which may vary with attributes like media type and screen resolution). You would have to use a client that is able to do all the stuff that a web browser can do besides the final rendering.
|
|
|
|
|
Thank you Jochen. I had tried to create an html client with CHtmlView, and here is the result:
void CTestHTMLView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
Navigate2(_T("http://www.mfinante.ro/pagina.html"), NULL, NULL);
}
result is blank page … is there impossible to solve this programmatically, in this case ?
|
|
|
|
|
Use the CHtmlView GetSource() method to inspect the source. It will probably like those you have already got and should contain hints about what is missing.
Note also that the IE settings are used which might be too restrictive.
|
|
|
|