• Welcome to Theos PowerBasic Museum 2017.

Issue with InterlockedCompareExchange64 and #OPTIMIZE CODE OFF

Started by Klaus Henn, February 05, 2013, 08:25:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Klaus Henn

Hello José,

today I had an problem with a PowerBasic program which used your include files ( Thank you for this exellent work!)  and the compiler switch #OPTIMIZE CODE OFF.  I opend a thread on Powerbasic forum. 
http://www.powerbasic.com/support/pbforums/showthread.php?t=52324

Now I found using your include files and #OPTIMIZE CODE Off  will produce EXE and DLL files which are not compatible with WIN XP.
If #OPTIMIZE CODE ON is used every thing is working like expected.

I used #Optimize Code OFF for I had trouble with PBWin. The compiler did hang when the optimization was switched on. To avoid the hanging of the compiler i found two ways. 1st. add an additional function (even if it is not used). 2nd used #Optimize Code OFF. Some month ago I reported this issue to PB support, but they could not confirm it.
PBWin 9 compiles my code without problems.

Thanks!

Klaus


José Roca

By using #OPTIMIZE CODE OFF you're including some inline functions that, otherwise, will be discarded by the compiler.

I have wrapped them with #IF %WINVER >= &H0502 in the attached WinBase.inc file.

You must add %WINVER = &H0501 before any #INCLUDE statement.

Klaus Henn


José Roca

Your problem is to know why your compiler hangs when the optimization is switched on (the default). Disabling optimization you're disabling dead code removal, and this may cause you further problems. Antivirus software has become the usual suspect.

Klaus Henn

You are right.
I would like to avoid the #OPTIMIZE CODE OFF but sometimes  the compiler behaves very strange. I did send my source code to PB support, but they could not confirm the issue, they expected it would be a problem of my PC. So I did some test with fresh formated PCs with different operating systems. The only applications installed had been Firefly 3.6x, PBWin 10, your include files, the CrystallComm  communication library, TTDS and TRMPro.  With the same source I had the issue on a fresh empty operating system (XP,Win7 32, Win 7 64, in English and German language). No Firewall or Antivirus software was installed or activated. My DLL source could be compiled in PBWin9 without any problems. PBWin10 did hang until I used the  #OPTIMIZE CODE OFF or I added some additional code which was not used (Dummy functions which made the source file larger).
The issue was reproduceable on different PCs.
For the DLL source could be compiled by PBWin9 without problems I expect it is not an issue of my source.

José Roca

Don't know. I have had zero problems with Windows 7 32 and 64 bits so far.

Carlo Pagani

Klaus, I had problems with SQLitning DLL returning invalid strings from a function, but only with clients in Hong Kong. I could replicate the problem by changing my System Locale to Chinese.
In the end I modified source and compiled DLL with PB9 and had no more issues.

I reported issue to PB, but cannot replicate error in a sample program. I even output return data to file in DLL which was 100% but returned string was corrupt.
I will test with #OPTIMIZE CODE OFF to see if the problem goes away in PB10

http://www.sqlitening.com/support/index.php?topic=3517.0

Klaus Henn

Carlo, your information is very interesting.
SQLitning is using PB TCP functions.
All my software modules (exe / dll) which produce troubles when compiling are using PBs TCP and UDP functions too. I have had no trouble with programs which do not use TCP UDP.


Christopher Boss

Klaus,

Have you tried using the dependency Walker utility from Microsoft to see wether your EXE or its dependencies actually link to InterlockedCompareExchange64 function ?

You can download it here:

http://support.microsoft.com/kb/256872

This is a very useful tool to have.