Problems to find out code changes that seems not to lead into a bug but does ?

L

Lothar Behrens

Hi,

this is an unusual question here, but I think, it is C++ related due to
the fact that my code is written with it.

I have written an ODBC wrapper that - if checked out with my last working
tag - works fine.

I have identified the reason, why the update of a column fails with
updating the column with an empty string. I have corrected it and it runs.

But if I checkout the latest version of all files, I see the corrected code
but it does not work.

I can not explain the why. I don't cope with the code changes.
I tought I can correct the problem in one file and solve the problem.

It seems not.

The problem was an instance - containing a pointer to a memory structure,
that where bound to an ODBC column. The instance was inserted into a container
and this container clones the object instance - therefore the pointer of
the orginal object instance was copied to a new pointer.

The result was, the orginal instance has been destroied and the pointer in it
was reset to p[0] = 0.

Now my questions:

My code is actually corrected in both variants, why can it be, that the error
comes again ?

Can it be that other code areas would be involved ?

I have found a bug with the help of Electric Fence. Is it possible to
use a similar tool under Windows ?

You can find the complete code at http://sourceforge.net/projects/lbdmf/
It is too much to put it here.

Hint: The relevant code is at line 486 in file lbDB.cpp.
The file is located in Basedevelopment/lbDB
The following code is in a loop of amount of columns.

lbErrCodes err = ERR_NONE;
printf("Bind a column\n");
// Create the instance ...
lbBoundColumn* bc = new lbBoundColumn();
bc->setModuleManager(*&manager, __FILE__, __LINE__);
bc->prepareBoundColumn(q, i);
integerKey->setData(i);
UAP(lb_I_Unknown, uk, __FILE__, __LINE__)
UAP(lb_I_KeyBase, key, __FILE__, __LINE__)
bc->queryInterface("lb_I_Unknown", (void**) &uk, __FILE__, __LINE__);
integerKey->queryInterface("lb_I_KeyBase", (void**) &key, __FILE__, __LINE__);
printf("Insert the bound column\n");

// Clones the instance
boundColumns->insert(&uk, &key);
UAP(lb_I_BoundColumn, bc1, __FILE__, __LINE__)
printf("Get the bound column back\n");
bc1 = getBoundColumn(i);

// Avoid the '' by binding the column to the cloned instance.
// Retrieving the column returns a reference, not a clone.
bc1->bindColumn(q, i);

I hope that any can help me with that problem.

Thanks

Lothar
 
L

Lothar Behrens

Christopher Benson-Manica said:
From a cursory glance, it appears that you have a version control
problem, not a C++ problem. In any case, reading the following URLs
can't hurt:

http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/

Hi,

thanks for the link to the FAQ.

It is not a version control problem. Currently I have checked deeply that
the pointer for the bound column is the same. It is.

At least I tried to activate the PostgreSQL ODBC logging functionality.
If activated detailed logs, the problem is away.

I do not have a C++ problem, I have a triky ODBC driver problem.
It would also be a tricky memory overrun, or a stack problem.

Therefore another question:
Where can I find or ask for tools to check my code under Windows ?
Under Linux I found Electric Fence.

Now I will go to a postgreSQL group, that is hopefully vital.

Thanks

Lothar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top