Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3407736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:47:16+00:00 2026-05-18T05:47:16+00:00

Receiving a segfault when running this very short script in Ubuntu. from osgeo import

  • 0

Receiving a segfault when running this very short script in Ubuntu.

from osgeo import ogr, osr

shpfile = 'Census_County_TIGER00_IN.shp'

def cust_field(field):
    '''cust_field(shpfile, field) creates a field definition, which, by calling cust_field(), can be used to create a field using the CreateField() function.
    cust_field() DOES NOT create a field -- it simply creates a "model" for a field, that can then be called later. It's weird, but that's GDAL/OGR, as far as I can tell.'''
    fieldDefn = ogr.FieldDefn(field, ogr.OFTInteger)
    fieldDefn.SetWidth(14)
    fieldDefn.SetPrecision(6)
    return fieldDefn

ds = ogr.Open(shpfile, 1)
lyr = ds.GetLayerByIndex(0)
field = cust_field("Test")
lyr.CreateField(field)

Everything runs smoothly until that last line, when iPython, normal shell Python and the IDLE command line all dump to a segmentation fault. Is this an error on my end or an issue with the underlying C that I’m not addressing properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:47:16+00:00Added an answer on May 18, 2026 at 5:47 am

    Is this an error on my end or an issue
    with the underlying C that I’m not
    addressing properly?

    It is probably both. GDAL/OGR’s bindings do tend to segfault occasionally, when objects go out of scope and are garbage collected. While this is a known bug, it is unlikely to be fixed any time soon.

    Chances are you can find a way to work around this. I can’t reproduce this segfault with another shapefile on Windows XP, and the following version of GDAL/OGR:

     >>> gdal.VersionInfo('') 
     'GDAL 1.6.0, released 2008/12/04'
    

    You could try temporarily to refactor the cust_field function into the body of the script like this:

    from osgeo import ogr, osr
    
    shpfile = 'Census_County_TIGER00_IN.shp'
    
    ds = ogr.Open(shpfile, 1)
    lyr = ds.GetLayerByIndex(0)
    fieldDefn = ogr.FieldDefn("Test", ogr.OFTInteger)
    fieldDefn.SetWidth(14)
    fieldDefn.SetPrecision(6)
    
    lyr.CreateField(fieldDefn)
    

    Let me know if this solves your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm receiving feedback from a developer that The only way visual basic (6) can
I am currently receiving this error: Validation of viewstate MAC failed. If this application
What options are available for receiving instant alerts from web applications? I have a
I have an Arduino sending and receiving instructions with a Python script via a
When receiving a bug report or an it-doesnt-work message one of my initials questions
I'm receiving Package Load Failure error when I open VS 2005 after I installed
I am receiving a 3rd party feed of which I cannot be certain of
My application is receiving email through SMTP server. There are one or more attachments
I am receiving dynamic xml where I won't know the attribute names, if you'll
I am receiving a large list of current account numbers daily, and storing them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.