From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b30bd69fa8f63cb2 X-Google-Attributes: gid103376,public X-Google-Thread: fc772,b30bd69fa8f63cb2 X-Google-Attributes: gidfc772,public X-Google-ArrivalTime: 2003-06-05 00:33:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uwm.edu!rpi!not-for-mail From: Raoul Gough Newsgroups: comp.lang.ada,comp.lang.c++.moderated Subject: Re: C bug of the day Date: 5 Jun 2003 03:35:35 -0400 Organization: unknown Sender: cppmods@netlab.cs.rpi.edu Message-ID: References: <3EDCCE72.4020707@cogeco.ca> <1054678322.557157@master.nyc.kbcfp.com> NNTP-Posting-Host: netlab.cs.rpi.edu X-Original-Date: Wed, 04 Jun 2003 19:19:43 +0100 X-Submission-Address: c++-submit@netlab.cs.rpi.edu X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated iQBVAwUAPt7ywkHMCo9UcraBAQGJuQIAhkngw67k73PA5RfaF/51cnPAyajjrSNL YyjebEpiPLzE2AjAdnY9GhCSm0nLSzvvu1n5brJnsZiXQeyKY4lAEQ== =7uU8 Xref: archiver1.google.com comp.lang.ada:38659 comp.lang.c++.moderated:67765 Date: 2003-06-05T03:35:35-04:00 List-Id: Hyman Rosen writes: > Warren W. Gay VE3WWG wrote: > > The problem ended up in an INFORMIX-7.31 library > > > > That little buffer overflow problem cost me 3 months of my life, > > and was a very expensive mistake for the company to correct. > > Oddly enough, the most mysterious bug I had to deal with > recently turned out to be a problem in Sybase ODBC drivers. > I had been programming database code in Visual Basic in Excel. > The company was changing people over from WindowsNT to > Windows2000, and certain of my spreadsheets stopped working. > Stored procedure calls would fail mysteriously. You can only > imagine the number of blind alleys I wandered down trying to > figure out what was going on. > > The ultimate culprit? The ODBC driver when invoked from Excel > sent Sybase its host ID in hex. One of the internal stored > procedures of the same trading system would get the host ID, > which Sybase returns as a string, and try to convert it to > decimal. When there happened to be no hex digits in the ID, > everything would be fine. When there were, the conversion > would cause an error, aborting the procedure. On and off, > that bug cost me a couple of months of hair pulling. I remember a buffer overflow that started crashing some DB access code of ours when we moved the DB from one machine to another (our code was written in C++ and C, so this is mildly on topic). The only thing was, the buffer actually was big enough for the data we were retrieving, and putting magic markers at either end of the buffer showed no past-the-end writing taking place. Nevertheless, certain data sets crashed the program consistently, and only when the database being accessed was on the local machine. I was going bananas trying to figure this out, until I realised that part of our code was dealing with the exact size of the current BLOB, whereas other parts were using the BLOB *segment* size for the DB in general. If the given BLOB was actually smaller than a single segment, we were misreporting the size of our buffer to the DB library. Now, with the DB on the local machine, the smart old Rdb library was mapping the file data into memory, rather than reading and copying it. The buffer was big enough for the BLOB's data, but actually not as big as we claimed, so the memory map system call was failing sometimes. I suspect it happened only when the buffer happened to be near the top of the process's virtual memory. I fixed our code and reported a bug to the Rdb support anyway, because it should have been reporting an error instead of crash dumping. -- Raoul Gough "Let there be one measure for wine throughout our kingdom, and one measure for ale, and one measure for corn" - Magna Carta [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ] [ about comp.lang.c++.moderated. First time posters: do this! ]