Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Access Violation on load mainform for clang bcc32c


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Apr 15, 2018 4:31 AM Last Post By: Vladimir Zhuchko Threads: [ Previous | Next ]
Vladimir Zhuchko

Posts: 116
Registered: 1/22/98
Access Violation on load mainform for clang bcc32c  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 12:02 AM
I got Access Violation error for my old program when one was compiled using CBuilder 10.2.3. and clang win32.
The error arised on the program start in the main form loading.
For normal bcc32 or clang win64 this error is absent.

This error is absent for CBuilder 10.2.2 using clang win32 mode.

--
With best regards
Dr. Vladimir Zhuchko
John Gray

Posts: 9
Registered: 3/3/04
Re: Access Violation on load mainform for clang bcc32c  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 7:26 AM   in response to: Vladimir Zhuchko in response to: Vladimir Zhuchko
I've been running into a similar issue with the new version - access violations where there shouldn't be. It's tough to track down and describe because it appears there has to be just the right circumstances for this to happen. I think I have managed to track it down to a reasonably simple test case.

Using C++ Builder 10.2.3 w/ Clang win32:

Create a new VCL project, add a button to the form and a variable to the class.

.h file:

class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TButton *Button1;
	void __fastcall Button1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
 
    int X;
};


Then create a dummy class and the following code for the button in the .cpp:

class TDummy
{
	public:
 
		double A1[37];
		double A2[361];
};
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	X = 1;
 
	char str[1000];
	TDummy dum;
}


Run the program, click the button and you get an access violation that stops on the "X = 1" line. It doesn't matter if you put this before or after the variable declarations. If you remove either of the other lines "char str[1000];" or "TDummy dum;" the access violation doesn't happen.

This appears to be a serious problem.
Vladimir Zhuchko

Posts: 116
Registered: 1/22/98
Re: Access Violation on load mainform for clang bcc32c  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 8:10 AM   in response to: John Gray in response to: John Gray
John Gray wrote:
I've been running into a similar issue with the new version - access violations where there shouldn't be. It's tough to track down and describe because it appears there has to be just the right circumstances for this to happen. I think I have managed to track it down to a reasonably simple test case.

Using C++ Builder 10.2.3 w/ Clang win32:

Create a new VCL project, add a button to the form and a variable to the class.

.h file:

class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TButton *Button1;
	void __fastcall Button1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
 
    int X;
};


Then create a dummy class and the following code for the button in the .cpp:

class TDummy
{
	public:
 
		double A1[37];
		double A2[361];
};
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	X = 1;
 
	char str[1000];
	TDummy dum;
}


Run the program, click the button and you get an access violation that stops on the "X = 1" line. It doesn't matter if you put this before or after the variable declarations. If you remove either of the other lines "char str[1000];" or "TDummy dum;" the access violation doesn't happen.

This appears to be a serious problem.

I put the RSP-20297, but without a sample.
May be you can add your project to this report?

--
With best regards
Dr. Vladimir Zhuchko

Edited by: Vladimir Zhuchko on Apr 6, 2018 8:10 AM
John Gray

Posts: 9
Registered: 3/3/04
Re: Access Violation on load mainform for clang bcc32c  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 6, 2018 8:33 AM   in response to: Vladimir Zhuchko in response to: Vladimir Zhuchko
Ok... I've added the project to RSP-20297. The issue seems to have something to do with fixed sized arrays in some convoluted way (all the instances I've run into of this thus far seem to have that in common).
Vladimir Zhuchko

Posts: 116
Registered: 1/22/98
Re: Access Violation on load mainform for clang bcc32c  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2018 4:31 AM   in response to: John Gray in response to: John Gray
John Gray wrote:
Ok... I've added the project to RSP-20297. The issue seems to have something to do with fixed sized arrays in some convoluted way (all the instances I've run into of this thus far seem to have that in common).

There is a patch preview from Bruneau Babet:
https://www40.zippyshare.com/v/8TU64Rfp/file.html
I've tested this preview, it seems that it works fine.

--
With best regards
Dr. Vladimir Zhuchko
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02