mreal has asked for the wisdom of the Perl Monks concerning the following question:

Hey all, I'm writing this script which takes information which contains addresses and other information, scrubs it down and cross-references the addresses with a database to get the latitude and longitude. The database I'm using is the Geocoder::US database. The problem I'm having is that when it gets about 260 records in, the script will stop and only the words 'Bus Error' appear for the error. I've figured that the code bombs out when trying to reference the address via the database. The script has bombed out at different addresses and there is nothing unusual about the addresses. The box I'm trying to run this on has SunOS 5.9. Any ideas? thanks for the help!

Replies are listed 'Best First'.
Re: Bus Error
by Fletch (Bishop) on Dec 04, 2007 at 16:08 UTC

    Without any more specific code samples you're probably just going to get generalities and hints (like this . . .).

    Normal Perl code shouldn't be generating bus errors. The most likely culprit is a buggy XS extension, or an XS extension that's being passed "bad" data that it's not validating. Check that you're checking the return values from things like module initialization calls (e.g. maybe you're getting an error when you attempt to open the database (hand waving here because I've never used the module in question) but you don't catch that and pass an invalid handle to a query routine; or maybe you're getting an error back from one of your lookups and there's something that needs to be done to put the handle back into a "sane" state before you continue making queries).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      All the actual code, that I wrote, is this:

      my ($ora) = Geo::Coder::US->geocode("$office_address, $office_address +_city, $office_address_state, $search_zip_code" );

      The actual modules that are being called are located here:

      Geo::Coder::US -> http://search.cpan.org/src/SDERLE/Geo-Coder-US-1.00/ +US.pm Geo::StreetAddress::US -> http://search.cpan.org/src/SDERLE/Geo-Street +Address-US-0.99/US.pm DB_File -> http://search.cpan.org/src/PMQS/DB_File-1.816/DB_File.pm

      I know, from research I've done on PERL, that Bus Errors don't happen in PERL and I think it might be attributed with the DB_File. I've gotten it to work on Mac OS X 10.4 and 10.5 as well as ActivePerl. I'm just not sure what's wrong with this.

      Edit: g0n - code tags and formatting

Re: Bus Error
by ww (Archbishop) on Dec 04, 2007 at 16:10 UTC
    Including a (stripped down) code sample may help you get better answers.

    and, random thoughts re "about 260 records:"

    • How big are the records?
    • is "about 260" perhaps precisely == 0xff?
      I know 'about' is one of the worst things to say when trying to debug. However, I use the word about because it is different. I've tried to filter out last names that being caught in this bus error but it keeps coming at different line intervals. I've posted the code in a reply to the previous post-reply. Thanks again.