$#%@@ Berlin - Access Violation

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

$#%@@ Berlin - Access Violation

Postby theLizard » Sat Jul 09, 2016 6:43 pm

How do you get an access violation in a unit that is not included in any of the projects of a project group?

I have checked, double checked and triple checked that the unit where an access violation is encountered is NOT in any of the units in the project group.

It is NOT included in any of my component packages or the test application I am using to learn my way around Berlin C++.

I can't show you code that triggers the violation because it does not exist.

Methods in the unit are NOT called by any unit in the project group.

Can someone please explain this to me.

:evil: :evil: :evil: :evil: :evil:
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm

Re: $#%@@ Berlin - Access Violation

Postby rlebeau » Sun Jul 10, 2016 12:05 am

Have you tried debugging the project yet? Does the debugger show breakpoint enabled lines in the unit in question? Have you tried putting any breakpoints in the unit to see if the code is ever executed? You might not think the code is part of the project, but if the debugger says otherwise then it actually is. Could be a mistake on the linker's part, or maybe a misconfiguration that you are not seeing.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1419
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: $#%@@ Berlin - Access Violation

Postby theLizard » Sun Jul 10, 2016 1:09 am

rlebeau wrote:Have you tried debugging the project yet?

Yes.

rlebeau wrote:Does the debugger show breakpoint enabled lines in the unit in question?

Yes, even though the whole block is commented out with /* */

rlebeau wrote:Have you tried putting any breakpoints in the unit to see if the code is ever executed?


There is NO code that calls it in any unit in the project.

rlebeau wrote:You might not think the code is part of the project, but if the debugger says otherwise then it actually is.


I agree but, I have made sure that there is NO link to the unit at all in any of my other units and I have removed the unit in question from the project all together.

rlebeau wrote: Could be a mistake on the linker's part


Could very well be, but why?

rlebeau wrote:or maybe a misconfiguration that you are not seeing.


I guess I am not seeing it because I don't know what the hell is going on, any idea as to what could be misconfigured, I had not done much in configuration other than setting Link with runtime packages to false and back again in my attempts to work out what is going on, also added include paths to my projects and set basic editor preferences, which I am sure have no effect on linker execution.

I also cannot understand why when I clear text boxes of their Text property, the names of the component appear at run time, there is no code in the TextBox unit that sets it. refer my other post "Help, I am going nuts" nor can I understand why check boxes lose their caption if link with runtime packages is false and magically reappear when set to true, why tree nodes have white background when set to false and normal when set to true.

I will concede that some of the issues may relate to my packages but, using debug the way you suggested has not put any light on the matter, in fact it confuses me even more.

For example, this code should check if in design mode or not (I think) either way nothing happens, putting a break point anywhere does not do anything AND the throw does not throw when I run the executable outside the ide.

I will accept that these may be wrong but, in Rad 2010, there are no issues with this approach (none that the compiler complains about any way).

Code: Select all
   if( ComponentState.Contains(csDesigning) )
      {
      //To Do...
      }
   else
      {
      Text = "";
    throw Exception("Here");
    }

//or

   if(FfieldName != value)
      {
      FfieldName = value;

      if( ComponentState.Contains(csDesigning) )
         {
         UnicodeString s = UpperCase(FfieldName[1]);
         s += FfieldName.SubString(2, FieldName.Length()-1);
         Name = FnamePrefix + s;
         Text = Name;
         }
      }



Would having Rad 2010 Professional and XE2 Professional installed on the same machine have any bearing on the issues I am facing?

I completely uninstalled the trial AND the licensed C++ Builder and left configuration to the installer and it does the same thing.

The issues seem to be random and illogical, however, if I execute code in my units, like loading a combo box from an sqlite database parsing a string and ref to the combo box in my odbc unit it works WITHOUT any problem, as do other methods.

With all these issues I am having I would have expected that tried and proven methods from Rad 2010 would fail if there were problems.

I am tearing my hair out trying to understand where to look.

Cheers.
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm

Re: $#%@@ Berlin - Access Violation

Postby rlebeau » Sun Jul 10, 2016 9:07 pm

theLizard wrote:
rlebeau wrote:Does the debugger show breakpoint enabled lines in the unit in question?

Yes, even though the whole block is commented out with /* */


So there is no actual code in the unit? EVERYTHING is commented out?

theLizard wrote:
rlebeau wrote:Have you tried putting any breakpoints in the unit to see if the code is ever executed?


There is NO code that calls it in any unit in the project.


That is not what I asked. YOU might not be calling into the unit, but SOMETHING ELSE you are not aware of might be.

theLizard wrote:
rlebeau wrote:You might not think the code is part of the project, but if the debugger says otherwise then it actually is.


I agree but, I have made sure that there is NO link to the unit at all in any of my other units and I have removed the unit in question from the project all together.


Have you tried deleting/renaming the unit so the compiler/linker cannot find it at all? Does the compile/link still succeed, or does it now fail?

Have you tried using ProcessMonitor to see which specific files the compiler/linker is accessing? Maybe there is an old .obj file you are not aware of that has a reference to the unit, and that .obj is getting linked in to the executable.

theLizard wrote:I will concede that some of the issues may relate to my packages but, using debug the way you suggested has not put any light on the matter, in fact it confuses me even more.


Using a second instance of the IDE for debugging is only meant for debugging *design-time* code that runs inside the IDE itself, not for debugging *run-time* code in a compiled executable.

theLizard wrote:For example, this code should check if in design mode or not (I think) either way nothing happens, putting a break point anywhere does not do anything AND the throw does not throw when I run the executable outside the ide.


Well, the only way that could happen is if this piece of code is not actually being executed at run-time.

theLizard wrote:Would having Rad 2010 Professional and XE2 Professional installed on the same machine have any bearing on the issues I am facing?


No. Many people have multiple versions installed together, and the IDEs are designed to run separately from each other.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1419
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: $#%@@ Berlin - Access Violation

Postby theLizard » Sun Jul 10, 2016 10:03 pm

rlebeau wrote:So there is no actual code in the unit? EVERYTHING is commented out?


There was code but the block that was being executed WAS commented out.

rlebeau wrote:That is not what I asked. YOU might not be calling into the unit, but SOMETHING ELSE you are not aware of might be.


That crossed my mind as well so I painstakingly went through ALL my units making sure that nothing was calling it's code, then removed the code from the project, deleted the contents of the debug folder using Shift + Delete, checked the project file for any sign of the unit and still, it executed the code that did not exist.

rlebeau wrote:Have you tried deleting/renaming the unit so the compiler/linker cannot find it at all? Does the compile/link still succeed, or does it now fail?


Yes.

rlebeau wrote:Have you tried using ProcessMonitor


No. Where is it?

rlebeau wrote:Using a second instance of the IDE for debugging is only meant for debugging *design-time* code that runs inside the IDE itself, not for debugging *run-time* code in a compiled executable.


Yes, I am aware of that.

rlebeau wrote:Well, the only way that could happen is if this piece of code is not actually being executed at run-time.


That's exactly the case.

rlebeau wrote:No. Many people have multiple versions installed together, and the IDEs are designed to run separately from each other


Happy to hear this, means I do not have to uninstall those to see if they wer the issue.

Cheers for your replies.
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm

Re: $#%@@ Berlin - Access Violation

Postby rlebeau » Mon Jul 11, 2016 12:18 am

theLizard wrote:There was code but the block that was being executed WAS commented out.


That makes me think you are linking to an old version of the unit.

theLizard wrote:
rlebeau wrote:Have you tried deleting/renaming the unit so the compiler/linker cannot find it at all? Does the compile/link still succeed, or does it now fail?


Yes.


Yes what? Yes, it succeeds, or yes it fails?

theLizard wrote:
rlebeau wrote:Have you tried using ProcessMonitor


No. Where is it?


SysInternals Process Monitor
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1419
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: $#%@@ Berlin - Access Violation

Postby theLizard » Mon Jul 11, 2016 12:39 am

rlebeau wrote:That makes me think you are linking to an old version of the unit.

From where! Not from any of my units.

rlebeau wrote:Yes what? Yes, it succeeds, or yes it fails?

Yes, it failed.

theLizard wrote:SysInternals Process Monitor

I have that on my system, will use it see if I can find anything.

Now for something interesting, I installed Berlin on a Windows 7 Professional machine and Guess What, everything works with "Link with runtime packages" Off and "Link with RTL" Off

The only thing so far that is a problem is, even though the packages installed correctly and include path and library path was set to point to the header files for the components, I had to explicitly include the component files to the application project.

I can live with that for now but looks like I cannot do much with Berlin on Windows 10, something is going on between Berlin, Windows 10 and maybe the Widows 10 SDK

It could even be that it is just Windows 10 that is an issue.
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm

Re: $#%@@ Berlin - Access Violation

Postby pidgi2009 » Mon Jul 11, 2016 5:32 am

A long time ago, I did have somewhat the same kind of problem, I can't remember well which version of Builder I had. Random crashes, strange behavior, etc.
I have then been lucky enough to have an answer on this very forum that suggested I do uninstall my RAD version, do a complete low level CHKDSK, thus letting the system correct the defective sectors on my hard disk, restart the machine, then reinstall all of my Builder version. I worked flawlessly. It seemed, I did have a few defective sectors that weren't recognized by the system before that manoeuvre.

Pierre Jetté
pidgi2009
BCBJ Veteran
BCBJ Veteran
 
Posts: 53
Joined: Sat Apr 25, 2009 11:44 am

Re: $#%@@ Berlin - Access Violation

Postby rlebeau » Mon Jul 11, 2016 11:03 am

theLizard wrote:From where! Not from any of my units.


If it is not in your own code, then it has to be in something that your project is using.

theLizard wrote:Yes, it failed.


Well, then clearly your project DOES have a dependency on that unit somewhere.

theLizard wrote:Now for something interesting, I installed Berlin on a Windows 7 Professional machine and Guess What, everything works with "Link with runtime packages" Off and "Link with RTL" Off


Don't forget the 3rd option "Link with Delphi runtime library" as well.

theLizard wrote:I had to explicitly include the component files to the application project.


You should not have to do that. Once they are compiled and installed, you should be able to reference them without actually adding them to the project itself. Sounds like you don't have all of the search paths configured correctly afterall.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1419
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: $#%@@ Berlin - Access Violation

Postby theLizard » Mon Jul 11, 2016 6:32 pm

rlebeau wrote:Well, then clearly your project DOES have a dependency on that unit somewhere.


Not that I could find, as I said, I went through everything removing dependencies, ensuring no h files were in any of the other units that could include the unit, deleting the obj's.

However,
rlebeau wrote:Sounds like you don't have all of the search paths configured correctly afterall.


This, as it turns out, is what I discovered today, with Windows 7, I restructured my folders where these projects resided moving them to a new location then deleting all references to packages and recreating the search paths, recompiled and installed packages.

Removed the explicitly linked units in the app project, set it's search paths according to the new structure I created recompiled and run the project, apart from one little problem, it ran correctly.

With this new structure in place on Widows 7, I returned to Windows 10 and did the same thing, it now, apart from the on little problem on Windows 7 it ran correctly.

So, the problem I was having was indeed the search paths not being one hundred % correct, however, the path structure that was set for the project was the same as (excluding name changes to folders) that I have in Rad 2010 where it runs without the issues I was having.

Now, the only apparent (for now) is that of having to Clean the project after each change in anything on the form or in code files due to "Link with runtime packages" and "Link with RTL", including "the Delphi RTL"

This occurs when "Link with runtime packages" = FALSE and RTL = TRUE.

If all set to TRUE, the code runs but exits immediately without showing the forms!!

So, I can now take away the "$#%@@" from the post and move forward with Berlin better behaving.

I would be happy if you could provide some clues as to why I need to Clean that would be great.

Cheers
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm

Re: $#%@@ Berlin - Access Violation

Postby theLizard » Tue Jul 12, 2016 12:27 am

theLizard wrote:So, the problem I was having was indeed the search paths not being one hundred % correct, however, the path structure that was set for the project was the same as (excluding name changes to folders) that I have in Rad 2010 where it runs without the issues I was having.


An update on this, making 100% sure that the paths were set correctly for my new folder structure, I was amazed to see that the paths which were set prior to the change re appeared in my project options, I had seen this change before but put it down to thinking that I had not changed the paths but now it has happened again.

Question is, are the changes to paths committed to the project file on close of project options window?

Why is this so!!!
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm

Re: $#%@@ Berlin - Access Violation

Postby smd » Tue Jul 12, 2016 3:34 pm

Try this:

Copy your source and header files into a new folder. Not your project files, just your source and header files.

Create a New Project from scratch adding your source and header files.

Compile with all optimizations turned off.

Execute with the debugger.

If you do not get the error, then you may have garbage information in the old project files.
-----------------------------
Scott
smd
BCBJ Guru
BCBJ Guru
 
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas

Re: $#%@@ Berlin - Access Violation

Postby theLizard » Tue Jul 12, 2016 5:36 pm

All good now, paths behaving after last changes yesterday.

But not entirely sure if the problem related to the fact that there were 2 links to the same project on the welcome page, and, even though the one that could have been the problem was pointing to a folder that did not exist (renamed the folder in the earlier stages of my head aches).

This project will have had paths set that were part of the problem.

This brings me to a question, I have tried to find where to go to delete links on the welcome page, can't seem to find it.

Also, under Favorite Projects, links that appear there have a Delete option, but when you click it nothing happens.

Cheers
theLizard
BCBJ Master
BCBJ Master
 
Posts: 447
Joined: Wed Mar 18, 2009 2:14 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 9 guests