abnormal program termination with dynamic data, but not with fixed data

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default abnormal program termination with dynamic data, but not with fixed data

    hi everyone. I am stumped!

    I have code that is part of a simple persistent object manager.
    The system takes an object, builds an update statement, and
    builds the parameter list.

    I keep getting an abnormal program termination. Hoever as you
    can see in the modified code segment below, I can run the same query
    with the same data that is hand keyed and it works fine.

    Below, you can see that the dynamically created arrays and the
    hand keyed one are identical, but one always aborts and one works
    fine. I am running ruby 1.8 on windows 2000 using the pragmatic
    programmers installer.

    Does anyone have any ideas?


    Walt



    This one ends in a segmentation fault
    ## original code ##
    def update(obj)
    raise SpomDBClosedException.new if closed?
    executeCount = 0
    dbObject = @spom.getObjectMapping(obj.class)
    dbHandle.prepare(dbObject.updateSQL) do |sth|
    params = []
    dbObject.nonKeyFields.each{|field| params <<
    field.toDB(obj)}
    dbObject.keyFields.each{|field| params
    <<field.toDB(obj)}
    executeCount = sth.execute(*params)
    end
    executeCount
    end
    ## end original code ##



    this modified version works. The main difference is that I am
    executing the update with a fixed array, not the dynamically computed

    array. It also has some code to compare the dynamically computed
    array, and the fixed one. It appears that they are identical,
    however,
    the dynamically created one always ends with :

    C:/ruby/lib/ruby/site_ruby/1.8/DBD/ODBC/ODBC.rb:202: [BUG]
    Segmentation fault
    ruby 1.8.0 (2003-05-26) [i386-mswin32]


    abnormal program termination


    ## modified code ##
    def update(obj)
    raise SpomDBClosedException.new if closed?
    executeCount = 0
    dbObject = @spom.getObjectMapping(obj.class)
    dbHandle.prepare(dbObject.updateSQL) do |sth|
    params = []
    dbObject.nonKeyFields.each{|field| params <<
    field.toDB(obj)}
    dbObject.keyFields.each{|field| params
    <<field.toDB(obj)}

    puts "computed data"
    puts compData = params.join(",")
    compClasses = params.collect{|i| i.class}
    puts compClasses.join(",")

    keyed = [Date.today, 'aaa', 'POIL', 'line1', 'line2', 'city', 'st',
    'zip', 'country', 'p', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '10', Date.today, '-' , '', '', '', '', '', '', '', 20, 21, 'sic',
    'disp', 'oth3', "31", "32", "33", "34", "35", 'POIL', 999999]

    puts ""
    puts "hand keyed data"
    puts keyedData = keyed.join(",")
    keyedClasses = keyed.collect{|i| i.class}
    puts keyedClasses.join(",")

    puts ""
    puts "size (#{params.size}) same? #{params.size == keyed.size}"
    puts "raw data same? #{params == keyed}"
    puts "joined data same? #{compData == keyedData}"
    puts "raw classes same #{compClasses == keyedClasses}"

    #note nothing prints
    params.each_with_index do |p, index|
    puts "******* #{index} does NOT equal data" if p != keyed[index]
    puts "******* #{index} does NOT equal class" if p.class !=
    keyed[index].class
    end

    params = keyed #NOTE: replace dynamic data with keyed data

    executeCount = sth.execute(*params)
    end
    executeCount
    end

    ## end modified code ##

    ******************
    ***** OUTPUT *****
    ******************

    computed data
    2003-07-
    12,aaa,POIL,line1,line2,city,st,zip,country,p,1,2, 3,4,5,6,7,8,9,10,200
    3-07-12,-,,,,,,,,20,21,sic,disp,oth3,31,32,33,34,35,POIL,99 9999
    Date,String,String,String,String,String,String,Str ing,String,String,St
    ring,String,String,String,String,String,String,Str ing,String,String,Da
    te,String,String,String,String,String,String,Strin g,String,Fixnum,Fixn
    um,String,String,String,String,String,String,Strin g,String,String,Fixn
    um

    hand keyed data
    2003-07-
    12,aaa,POIL,line1,line2,city,st,zip,country,p,1,2, 3,4,5,6,7,8,9,10,200
    3-07-12,-,,,,,,,,20,21,sic,disp,oth3,31,32,33,34,35,POIL,99 9999
    Date,String,String,String,String,String,String,Str ing,String,String,St
    ring,String,String,String,String,String,String,Str ing,String,String,Da
    te,String,String,String,String,String,String,Strin g,String,Fixnum,Fixn
    um,String,String,String,String,String,String,Strin g,String,String,Fixn
    um

    size (41) same? true
    raw data same? true
    joined data same? true
    raw classes same true

    ************************************************** ***
    Walter Szewelanczyk
    IS Director
    M.W. Sewall & CO. email : [email]walter@mwsewall.com[/email]
    259 Front St. Phone : (207) 442-7994 x 128
    Bath, ME 04530 Fax : (207) 443-6284
    ************************************************** ***


    walter@mwsewall.com Guest

  2. Similar Questions and Discussions

    1. Problem with Data Grid reading dynamic data
      I have created a website that uses datagrids to read data from an asp page. It works great, and fills the datagrid perfectly but it does not work...
    2. Extracting test data to another program
      Hi, Is there any way to extract the test score data to a MS Excel or Access? If so, how? I don't have an LMS system and I want to extract this...
    3. How to get the data from a WSDL file from a c# Program?
      Hi, I am a beginner of .net. I would like to create an interface which accepts the WSDL url and should return the methods. It is a dynamic call....
    4. Exif data: Is APE only program left to get this rite?
      Please see below the note I posted in another newsgroup about a program that may end up being my FORMER favorite, Paint Shop Pro. I just looked in...
    5. best way to store data from a director program?
      Hi I am doing a program with nice animation and some data are entrered by the user. And I would like to store those info (about 20 from a form) in...
  3. #2

    Default Re: abnormal program termination with dynamic data, but not with fixed data

    "Sean O'Dell" <sean@REMOVEME.celsoft.com> wrote in message
    news:HiBRa.265$BG7.249@newssvr24.news.prodigy.com. ..
    > <walter@mwsewall.com> wrote in message
    > news:3F1094D4.21763.2AFC3C8@localhost...
    > > hi everyone. I am stumped!
    > >
    > > I have code that is part of a simple persistent object manager.
    > > The system takes an object, builds an update statement, and
    > > builds the parameter list.
    > >
    > > I keep getting an abnormal program termination. Hoever as you
    > > can see in the modified code segment below, I can run the same query
    > > with the same data that is hand keyed and it works fine.
    > >
    > > Below, you can see that the dynamically created arrays and the
    > > hand keyed one are identical, but one always aborts and one works
    > > fine. I am running ruby 1.8 on windows 2000 using the pragmatic
    > > programmers installer.
    > >
    > > Does anyone have any ideas?
    > >
    > >
    > > Walt
    > >
    > >
    > >
    > > This one ends in a segmentation fault
    > > ## original code ##
    > > def update(obj)
    > > raise SpomDBClosedException.new if closed?
    > > executeCount = 0
    > > dbObject = @spom.getObjectMapping(obj.class)
    > > dbHandle.prepare(dbObject.updateSQL) do |sth|
    > > params = []
    > > dbObject.nonKeyFields.each{|field| params <<
    > > field.toDB(obj)}
    > > dbObject.keyFields.each{|field| params
    > > <<field.toDB(obj)}
    > > executeCount = sth.execute(*params)
    > > end
    > > executeCount
    > > end
    > > ## end original code ##
    > >
    > >
    > >
    > > this modified version works. The main difference is that I am
    > > executing the update with a fixed array, not the dynamically computed
    > >
    > > array. It also has some code to compare the dynamically computed
    > > array, and the fixed one. It appears that they are identical,
    > > however,
    > > the dynamically created one always ends with :
    > >
    > > C:/ruby/lib/ruby/site_ruby/1.8/DBD/ODBC/ODBC.rb:202: [BUG]
    > > Segmentation fault
    > > ruby 1.8.0 (2003-05-26) [i386-mswin32]
    > >
    > >
    > > abnormal program termination
    > >
    > >
    > > ## modified code ##
    > > def update(obj)
    > > raise SpomDBClosedException.new if closed?
    > > executeCount = 0
    > > dbObject = @spom.getObjectMapping(obj.class)
    > > dbHandle.prepare(dbObject.updateSQL) do |sth|
    > > params = []
    > > dbObject.nonKeyFields.each{|field| params <<
    > > field.toDB(obj)}
    > > dbObject.keyFields.each{|field| params
    > > <<field.toDB(obj)}
    > >
    > > puts "computed data"
    > > puts compData = params.join(",")
    > > compClasses = params.collect{|i| i.class}
    > > puts compClasses.join(",")
    > >
    > > keyed = [Date.today, 'aaa', 'POIL', 'line1', 'line2', 'city', 'st',
    > > 'zip', 'country', 'p', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    > > '10', Date.today, '-' , '', '', '', '', '', '', '', 20, 21, 'sic',
    > > 'disp', 'oth3', "31", "32", "33", "34", "35", 'POIL', 999999]
    > >
    > > puts ""
    > > puts "hand keyed data"
    > > puts keyedData = keyed.join(",")
    > > keyedClasses = keyed.collect{|i| i.class}
    > > puts keyedClasses.join(",")
    > >
    > > puts ""
    > > puts "size (#{params.size}) same? #{params.size == keyed.size}"
    > > puts "raw data same? #{params == keyed}"
    > > puts "joined data same? #{compData == keyedData}"
    > > puts "raw classes same #{compClasses == keyedClasses}"
    > >
    > > #note nothing prints
    > > params.each_with_index do |p, index|
    > > puts "******* #{index} does NOT equal data" if p != keyed[index]
    > > puts "******* #{index} does NOT equal class" if p.class !=
    > > keyed[index].class
    > > end
    > >
    > > params = keyed #NOTE: replace dynamic data with keyed data
    > >
    > > executeCount = sth.execute(*params)
    > > end
    > > executeCount
    > > end
    > >
    > > ## end modified code ##
    > >
    > > ******************
    > > ***** OUTPUT *****
    > > ******************
    > >
    > > computed data
    > > 2003-07-
    > > 12,aaa,POIL,line1,line2,city,st,zip,country,p,1,2, 3,4,5,6,7,8,9,10,200
    > > 3-07-12,-,,,,,,,,20,21,sic,disp,oth3,31,32,33,34,35,POIL,99 9999
    > > Date,String,String,String,String,String,String,Str ing,String,String,St
    > > ring,String,String,String,String,String,String,Str ing,String,String,Da
    > > te,String,String,String,String,String,String,Strin g,String,Fixnum,Fixn
    > > um,String,String,String,String,String,String,Strin g,String,String,Fixn
    > > um
    > >
    > > hand keyed data
    > > 2003-07-
    > > 12,aaa,POIL,line1,line2,city,st,zip,country,p,1,2, 3,4,5,6,7,8,9,10,200
    > > 3-07-12,-,,,,,,,,20,21,sic,disp,oth3,31,32,33,34,35,POIL,99 9999
    > > Date,String,String,String,String,String,String,Str ing,String,String,St
    > > ring,String,String,String,String,String,String,Str ing,String,String,Da
    > > te,String,String,String,String,String,String,Strin g,String,Fixnum,Fixn
    > > um,String,String,String,String,String,String,Strin g,String,String,Fixn
    > > um
    > >
    > > size (41) same? true
    > > raw data same? true
    > > joined data same? true
    > > raw classes same true
    >
    > Which line is line 202?
    Actually, what is the entire backtrace? What line in your code is causing
    the failure?

    Sean O'Dell


    Sean O'Dell Guest

  4. #3

    Default Re: abnormal program termination with dynamic data, but not with fixed data

    The exception is during the call to sth.execute(*params)

    It looks like it is in the ODBC module.

    I have been able to duplicate the error using the ODBC module
    directly without using DBI.

    The error in both cases happened when I attempt to execute with a
    long dynamically generated parameter list. It works fine with a hand
    keyed parameter list. Both lists are the same size, all matching
    elements show that they are equal, but the dynamically generated one
    always crashes.


    Walt

    > "Sean O'Dell" <sean@REMOVEME.celsoft.com> wrote in message
    > news:HiBRa.265$BG7.249@newssvr24.news.prodigy.com. ..
    > > <walter@mwsewall.com> wrote in message
    > > news:3F1094D4.21763.2AFC3C8@localhost...
    > > > hi everyone. I am stumped!
    > > >
    > > > I have code that is part of a simple persistent object manager.
    > > > The system takes an object, builds an update statement, and builds
    > > > the parameter list.
    > > >
    > > > I keep getting an abnormal program termination. Hoever as you can
    > > > see in the modified code segment below, I can run the same query
    > > > with the same data that is hand keyed and it works fine.
    > > >
    > > > Below, you can see that the dynamically created arrays and the
    > > > hand keyed one are identical, but one always aborts and one works
    > > > fine. I am running ruby 1.8 on windows 2000 using the pragmatic
    > > > programmers installer.
    > > >
    > > > Does anyone have any ideas?
    > > >
    > > >
    > > > Walt
    > > >
    > > >
    > > >
    > > > This one ends in a segmentation fault
    > > > ## original code ##
    > > > def update(obj)
    > > > raise SpomDBClosedException.new if closed?
    > > > executeCount = 0
    > > > dbObject = @spom.getObjectMapping(obj.class)
    > > > dbHandle.prepare(dbObject.updateSQL) do |sth|
    > > > params = []
    > > > dbObject.nonKeyFields.each{|field| params <<
    > > > field.toDB(obj)}
    > > > dbObject.keyFields.each{|field| params
    > > > <<field.toDB(obj)}
    > > > executeCount = sth.execute(*params)
    > > > end
    > > > executeCount
    > > > end
    > > > ## end original code ##
    > > >
    > > >
    > > >
    > > > this modified version works. The main difference is that I am
    > > > executing the update with a fixed array, not the dynamically
    > > > computed
    > > >
    > > > array. It also has some code to compare the dynamically computed
    > > > array, and the fixed one. It appears that they are identical,
    > > > however, the dynamically created one always ends with :
    > > >
    > > > C:/ruby/lib/ruby/site_ruby/1.8/DBD/ODBC/ODBC.rb:202: [BUG]
    > > > Segmentation fault
    > > > ruby 1.8.0 (2003-05-26) [i386-mswin32]
    > > >
    > > >
    > > > abnormal program termination
    > > >
    > > >
    > > > ## modified code ##
    > > > def update(obj)
    > > > raise SpomDBClosedException.new if closed?
    > > > executeCount = 0
    > > > dbObject = @spom.getObjectMapping(obj.class)
    > > > dbHandle.prepare(dbObject.updateSQL) do |sth|
    > > > params = []
    > > > dbObject.nonKeyFields.each{|field| params <<
    > > > field.toDB(obj)}
    > > > dbObject.keyFields.each{|field| params
    > > > <<field.toDB(obj)}
    > > >
    > > > puts "computed data"
    > > > puts compData = params.join(",")
    > > > compClasses = params.collect{|i| i.class}
    > > > puts compClasses.join(",")
    > > >
    > > > keyed = [Date.today, 'aaa', 'POIL', 'line1', 'line2', 'city',
    > > > 'st', 'zip', 'country', 'p', '1', '2', '3', '4', '5', '6', '7',
    > > > '8', '9', '10', Date.today, '-' , '', '', '', '', '', '', '', 20,
    > > > 21, 'sic', 'disp', 'oth3', "31", "32", "33", "34", "35", 'POIL',
    > > > 999999]
    > > >
    > > > puts ""
    > > > puts "hand keyed data"
    > > > puts keyedData = keyed.join(",")
    > > > keyedClasses = keyed.collect{|i| i.class}
    > > > puts keyedClasses.join(",")
    > > >
    > > > puts ""
    > > > puts "size (#{params.size}) same? #{params.size == keyed.size}"
    > > > puts "raw data same? #{params == keyed}" puts "joined data same?
    > > > #{compData == keyedData}" puts "raw classes same #{compClasses ==
    > > > keyedClasses}"
    > > >
    > > > #note nothing prints
    > > > params.each_with_index do |p, index|
    > > > puts "******* #{index} does NOT equal data" if p !=
    > > > keyed[index] puts "******* #{index} does NOT equal class" if
    > > > p.class !=
    > > > keyed[index].class
    > > > end
    > > >
    > > > params = keyed #NOTE: replace dynamic data with keyed data
    > > >
    > > > executeCount = sth.execute(*params)
    > > > end
    > > > executeCount
    > > > end
    > > >
    > > > ## end modified code ##
    > > >
    > > > ******************
    > > > ***** OUTPUT *****
    > > > ******************
    > > >
    > > > computed data
    > > > 2003-07-
    > > > 12,aaa,POIL,line1,line2,city,st,zip,country,p,1,2, 3,4,5,6,7,8,9,10
    > > > ,200
    > > > 3-07-12,-,,,,,,,,20,21,sic,disp,oth3,31,32,33,34,35,POIL,99 9999
    > > > Date,String,String,String,String,String,String,Str ing,String,Strin
    > > > g,St
    > > > ring,String,String,String,String,String,String,Str ing,String,Strin
    > > > g,Da
    > > > te,String,String,String,String,String,String,Strin g,String,Fixnum,
    > > > Fixn
    > > > um,String,String,String,String,String,String,Strin g,String,String,
    > > > Fixn um
    > > >
    > > > hand keyed data
    > > > 2003-07-
    > > > 12,aaa,POIL,line1,line2,city,st,zip,country,p,1,2, 3,4,5,6,7,8,9,10
    > > > ,200
    > > > 3-07-12,-,,,,,,,,20,21,sic,disp,oth3,31,32,33,34,35,POIL,99 9999
    > > > Date,String,String,String,String,String,String,Str ing,String,Strin
    > > > g,St
    > > > ring,String,String,String,String,String,String,Str ing,String,Strin
    > > > g,Da
    > > > te,String,String,String,String,String,String,Strin g,String,Fixnum,
    > > > Fixn
    > > > um,String,String,String,String,String,String,Strin g,String,String,
    > > > Fixn um
    > > >
    > > > size (41) same? true
    > > > raw data same? true
    > > > joined data same? true
    > > > raw classes same true
    > >
    > > Which line is line 202?
    >
    > Actually, what is the entire backtrace? What line in your code is
    > causing the failure?
    >
    > Sean O'Dell
    >
    >
    >

    ************************************************** ***
    Walter Szewelanczyk
    IS Director
    M.W. Sewall & CO. email : [email]walter@mwsewall.com[/email]
    259 Front St. Phone : (207) 442-7994 x 128
    Bath, ME 04530 Fax : (207) 443-6284
    ************************************************** ***


    walter@mwsewall.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139