LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Clang

Clang crashes when I compiled my C code which was previous compiled error free.

 

Build Status (Firmware_Update.prj - Debug)
 Firmware_Update.c - 6 warnings
      1, 1   Instruction does not dominate all uses!
      1, 1   %137 = call %4* @_PtrCastToScalar(%4* bitcast (%5* @_UP_var_curFirmwareConfigInfo to %4*), %3* null, i32 40), !dbg !171
      1, 1   %172 = call i8 @_PtrChkDeref(%0* @__cvi_TN21, i8* getelementptr inbounds (%struct.FW_CONFG_REC* @curFirmwareConfigInfo, i32 0, i32 0), %4* %137, %3* %138, i32 1074443265, i32 701468), !dbg !183
      1, 1   Broken module found, compilation aborted!
      1, 1   This application has requested the Runtime to terminate it in an unusual way.
      1, 1   Please contact the application's support team for more information.
Build failed.

 

Unfortunately, it did not tell what error it is. So please help. Is there a way that I could disable Clang. I am using CVI 2013.

 

Thanks.

 

Peter

0 Kudos
Message 1 of 8
(4,988 Views)

Hello Peter,

 

Could you provide us with a code snippet that leads to the compiler crashing? What configuration are you using? Are you using optimizations / run-time checking?

 

Best regards,

Nelu F. || National Instruments.

0 Kudos
Message 2 of 8
(4,972 Views)

I do not know where the code broke so I can not give you a code snippet. I could give you the module and all needed header files for you to try to compile. If we do this, where do I send the source code?

Thanks,

Peter

0 Kudos
Message 3 of 8
(4,948 Views)

Hello PP_Software,

 

 

You can use our FTP server (ftp.ni.com\incoming). We will evaluate the issue in the shortest time possible and fix it in the near future.

 

Best regards,

Nelu F. || National Instruments.

0 Kudos
Message 4 of 8
(4,897 Views)

Hi Nelu,

 

I think that I narrowed the problem: It was due to a long data structure. Now what do I have to do to go around this problem?

 

Thanks,

Peter

0 Kudos
Message 5 of 8
(4,865 Views)

Hi Peter,

 

In order to evaluate the issue we need to have a look at the code. If you think you have a code snippet that reproduces the problem, could you send it to us? 

From the looks of the build status you've attached in your first post, it looks like you're encoutering the problem in a Debug configuration with (possible) run-time checking enabled. The user protection might be misleaded by some particularity of your structure. I cannot propose a viable work-around until I see the code, but an idea that might work would be to disable run-time checking (set the debugging level to "No run-time checking" in the Build Options window).

 

Please not that this is not a compilation error; the compiler is crashing.

 

Best regards,

Nelu F. || National Instruments.

0 Kudos
Message 6 of 8
(4,861 Views)

Ok, the following code crashes the clang.

 

#include <formatio.h>

#include <ansi_c.h>

#include <cvirte.h>  

#include <userint.h>

#include "toolbox.h"

#include <rs232.h>

 

typedef struct{  

unsigned char status;       

unsigned char state;      

unsigned char curBootStatus;     

unsigned char bootErrorId;    

unsigned char bootVersionMajor;     

unsigned char bootVersionMinor;     

unsigned int bootPart1EndAddr;                  

unsigned int bootPart2EndAddr;                 

unsigned short bootChecksum;   

unsigned char curAppStatus;      

unsigned char appErrorId;      

unsigned char appVersionMajor;   

unsigned char appVersionMinor;     

unsigned int appBeginAddr;      

unsigned int appEndAddr;      

unsigned short appChecksum;      

unsigned char appBackup1Status;   

unsigned char backup1ErrorId;   

unsigned char backup1VersionMajor;  

unsigned char backup1VersionMinor;    

unsigned int appBackup1Len;      

unsigned short appBackup1Checksum;   

unsigned int appBackup1Dnld_Time;    

unsigned char appBackup2Status;     

unsigned char backup2ErrorId;     

unsigned char backup2VersionMajor;    

unsigned char backup2VersionMinor;  

unsigned int appBackup2Len;      

unsigned short appBackup2Checksum;     

unsigned int appBackup2Dnld_Time;    

unsigned char reserved[4];      

unsigned short checksum;    

}FW_CONFG_REC;

 

FW_CONFG_REC curFirmwareConfigInfo;

 

int LoadFirmwareConfigInfo(unsigned char *pFirmwareConfigBuf, unsigned int dataLen)

{

 if ((dataLen == 0) || (pFirmwareConfigBuf == (unsigned char *)NULL))

{   // Bin file buffer was not available...  

 memset((void *)&curFirmwareConfigInfo,0,sizeof(FW_CONFG_REC));   

return -1;

 }

 if (dataLen < sizeof(FW_CONFG_REC))

{   return -1;  

}

 curFirmwareConfigInfo.status = *pFirmwareConfigBuf++;           

 curFirmwareConfigInfo.state = *pFirmwareConfigBuf++;            

 curFirmwareConfigInfo.curBootStatus = *pFirmwareConfigBuf++;       

 curFirmwareConfigInfo.bootErrorId = *pFirmwareConfigBuf++;          

curFirmwareConfigInfo.bootVersionMajor = *pFirmwareConfigBuf++;      

 curFirmwareConfigInfo.bootVersionMinor = *pFirmwareConfigBuf++;     

//....  

 //....     

 return 1;

}

0 Kudos
Message 7 of 8
(4,850 Views)

Hey Peter,

 

It looks like the issue has been addressed in a patch that should be released soon. Until then, I can suggest two workarounds: either set Debugging level to No run-time checking (from Build Options), either change the field "status" from unsigned char to int in the structure FW_CONFG_REC. After I did this for the code you provided, the compilation process succeeded.

 

Best regards,

Nelu F. || National Instruments.

 

0 Kudos
Message 8 of 8
(4,832 Views)