code generation problems
I am having a big problem with BPL. When my extension module is compiled by bjam I think it is giving me bad code. I have a couple of functions in a C++ object that have almost the same signature, just slightly different names. I have a free function in the extension module for each of these that calls into the C++ object: MyObject* gObject; void DoSomethingToObject( int data ) { gObject->DoSomething( data ); } void SomethingElseToObject( int data ) { gObject->SomethingElse( data ); } gObject is a valid ptr. When this code executes, the gObject->DoSomething call actually calls gObject->SomethingElse and vise versa! So I went and changed names thinking maybe it was confused by similar names, that didn't help. I went as far as to add some bogus parameters to SomethingElse but even that did not work. It still happily calls the wrong function even though it was called with a different number of parameters. Now I don't trust the VS debugger at all, but as I step through the code everything seems to make sense. It's executing the code it's stepping through, it's not just displaying the wrong lines of code as it has done before for me. The 2 free functions that are called from Python get called fine. They're called by other C++ code not related to my module and it works fine. It's just the call into gObject that is bad from the wrapped free functions. If you ignore the fact that it's calling a function with different number of parameters and filling those in with garbage, even after the bogus call everything is working OK until an assertion of mine fails because the wrong function has been called at the wrong time. The gObject class looks just fine to me. Calling some other gObject member functions instead works fine. It's just the DoSomething and SomethingElse ones that are problematic. Thinking I probably had bad code elsewhere or something I moved the calls to these 2 free functions up so they're basically the first things called by the Python script, but I get the same result. Are there any known problems with compiling modules that would lead to something like this? I don't even know where to start. I guess I will have to try to come up with a small example demonstrating the problem. This is using boost 1.32 with vc-7_1. -jim
James Mastro wrote:
I am having a big problem with BPL. When my extension module is compiled by bjam I think it is giving me bad code. I have a couple of functions in a C++ object that have almost the same signature, just slightly different names. I have a free function in the extension module for each of these that calls into the C++ object:
MyObject* gObject; void DoSomethingToObject( int data ) { gObject->DoSomething( data ); }
void SomethingElseToObject( int data ) { gObject->SomethingElse( data ); }
gObject is a valid ptr.
When this code executes, the gObject->DoSomething call actually calls gObject->SomethingElse and vise versa!
If that is in fact the case you are not having a BPL problem at all: it's simply a compiler bug. You should reduce the problem to a minimal case that doesn't involve BPL and post it to a microsoft support newsgroup or other such resource at this point.
So I went and changed names thinking maybe it was confused by similar names, that didn't help. I went as far as to add some bogus parameters to SomethingElse but even that did not work. It still happily calls the wrong function even though it was called with a different number of parameters. Now I don't trust the VS debugger at all,
I'm surprised; I find it to be very good.
but as I step through the code everything seems to make sense. It's executing the code it's stepping through, it's not just displaying the wrong lines of code as it has done before for me.
I'm not sure exactly what you mean by "seems to make sense." Do you mean that when you step into the call to DoSomething the PC is shown somewhere inside the source code to DoSomething?
Are there any known problems with compiling modules that would lead to something like this? I don't even know where to start. I guess I will have to try to come up with a small example demonstrating the problem. This is using boost 1.32 with vc-7_1.
Yes, but unless you have a good reason to think this is BPL-related, you should take your problem elsewhere. It's not that I'm unsympathetic, but I don't think there's anything I can do to help you. Sorry, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
David Abrahams wrote:
Yes, but unless you have a good reason to think this is BPL-related, you should take your problem elsewhere. It's not that I'm unsympathetic, but I don't think there's anything I can do to help you.
Except, of course, to Cc: a microsoft compiler engineer, who came back with: There is a linker optimization that we do that describes some of the behavior he is describing. He could try passing -opt:noref to the link.exe and see if the problem goes away. So add "-sBUILD=<linkflags>-opt:noref" to the beginning of your bjam command-line and see what happens. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
David Abrahams wrote:
David Abrahams wrote:
Yes, but unless you have a good reason to think this is BPL-related, you should take your problem elsewhere. It's not that I'm unsympathetic, but I don't think there's anything I can do to help you.
Except, of course, to Cc: a microsoft compiler engineer, who came back with:
There is a linker optimization that we do that describes some of the behavior he is describing. He could try passing -opt:noref to the link.exe and see if the problem goes away.
So add "-sBUILD=<linkflags>-opt:noref" to the beginning of your bjam command-line and see what happens.
And then he said: "Whoops, I told you the wrong option, it should have been -opt:noicf. icf is short for identical comdat folding." So add "-sBUILD=<linkflags>-opt:noicf" HTH, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
David Abrahams wrote:
Yes, but unless you have a good reason to think this is BPL-related, you should take your problem elsewhere. It's not that I'm unsympathetic, but I don't think there's anything I can do to help you.
Except, of course, to Cc: a microsoft compiler engineer, who came back with: "-sBUILD=<linkflags>-opt:noicf"
Great. I'll give that a shot tomorrow. I knew it wasn't bjam or bpl causing the problem, I worded it poorly. That's not one of my finer posts now that I read it again. Thank you for taking the time to look into it despite that.
I'm not sure exactly what you mean by "seems to make sense." Do you mean that when you step into the call to DoSomething the PC is shown somewhere inside the source code to DoSomething?
Yes, but more than that. Files that were supposed to be created or read from were actually being done, etc. So when DoSomething was shown as being stepped into, it was actually doing that despite the caller displaying a different function name than what was actually being stepped into. I agree about the VS debugger being quite good, my comment was idiotic. I went through a period trying to learn a new system (and BPL, actually) with a totally useless debugger, showing me code not what it was really executing, variable info being totally wrong or showing nothing, debugger crashing frequently, but upon further review that wasn't even on Windows. All those problems have since been fixed and that previously nasty debugger works great now last time I checked so I can't complain about any of the debuggers anymore. I jump around to too many systems for my own good, though. -jim
participants (2)
-
David Abrahams -
James Mastro