Bug #9514

Huge query crash ruby core

Added by Marwan Rabbâa over 1 year ago. Updated over 1 year ago.

[ruby-core:60666]
Status:Third Party's Issue
Priority:Normal
Assignee:-
ruby -v:ruby 2.0.0p353 Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN

Description

Hi,

I have made a query on a [[[http://teradata.com|terradata]]] server using https://github.com/priviterag/teradata-cli

The result output is a CSV file containing at least a billing of lines (unicode).

After a few hours, I have the following stack

/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1055: [BUG] object allocation during garbage collection phase
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0022 p:---- s:0097 e:000096 CFUNC :[]=
c:0021 p:0027 s:0092 e:000091 BLOCK /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1055 [FINISH]
c:0020 p:---- s:0089 e:000088 CFUNC :each
c:0019 p:0011 s:0086 e:000085 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:766
c:0018 p:0019 s:0082 E:000340 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1053
c:0017 p:0023 s:0076 e:000075 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1047 [FINISH]
c:0016 p:---- s:0071 e:000070 CFUNC :new
c:0015 p:0054 s:0066 e:000065 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:784
c:0014 p:0090 s:0060 e:000059 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:696 [FINISH]
c:0013 p:---- s:0055 E:002200 CFUNC :map
c:0012 p:0026 s:0052 E:000bc8 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:714
c:0011 p:0061 s:0049 E:0017e8 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:178
c:0010 p:0009 s:0044 e:000043 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:195
c:0009 p:0010 s:0040 e:000039 BLOCK /usr/local/share/gems/gems/tdsql-0.2/lib/tdsql/querify.rb:17
c:0008 p:0223 s:0036 E:000e80 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:71 [FINISH]
c:0007 p:---- s:0028 e:000027 CFUNC :new
c:0006 p:0017 s:0023 e:000022 METHOD /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:38
c:0005 p:0083 s:0018 E:000d70 METHOD /usr/local/share/gems/gems/tdsql-0.2/lib/tdsql/querify.rb:16
c:0004 p:0030 s:0012 e:000011 TOP /usr/local/share/gems/gems/tdsql-0.2/bin/tdsql:4 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :load
c:0002 p:0134 s:0006 E:001dd8 EVAL /usr/local/bin/tdsql:23 [FINISH]
c:0001 p:0000 s:0002 E:0021f8 TOP [FINISH]
/usr/local/bin/tdsql:23:in <main>'
/usr/local/bin/tdsql:23:in
load'
/usr/local/share/gems/gems/tdsql-0.2/bin/tdsql:4:in <top (required)>'
/usr/local/share/gems/gems/tdsql-0.2/lib/tdsql/querify.rb:16:in
exec'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:38:in connect'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:38:in
new'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:71:in initialize'
/usr/local/share/gems/gems/tdsql-0.2/lib/tdsql/querify.rb:17:in
block in exec'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:195:in entries'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:178:in
execute_query'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:714:in fetch_all'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:714:in
map'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:696:in each_record'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:784:in
unmarshal'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:784:in new'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1047:in
initialize'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1053:in build_name_index'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:766:in
each_column'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:766:in each'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1055:in
block in build_name_index'
/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1055:in `[]='
-- C level backtrace information -------------------------------------------
-- Other runtime information -----------------------------------------------
* Loaded script: /usr/local/bin/tdsql
* Loaded features:
0 enumerator.so
1 /usr/lib64/ruby/enc/encdb.so
2 /usr/lib64/ruby/enc/trans/transdb.so
3 /usr/lib64/ruby/rbconfig.rb
4 /usr/local/share/ruby/site_ruby/rubygems/compatibility.rb
5 /usr/local/share/ruby/site_ruby/rubygems/defaults.rb
6 /usr/local/share/ruby/site_ruby/rubygems/deprecate.rb
7 /usr/local/share/ruby/site_ruby/rubygems/errors.rb
8 /usr/local/share/ruby/site_ruby/rubygems/version.rb
9 /usr/local/share/ruby/site_ruby/rubygems/requirement.rb
10 /usr/local/share/ruby/site_ruby/rubygems/platform.rb
11 /usr/local/share/ruby/site_ruby/rubygems/basic_specification.rb
12 /usr/local/share/ruby/site_ruby/rubygems/stub_specification.rb
13 /usr/local/share/ruby/site_ruby/rubygems/util/stringio.rb
14 /usr/local/share/ruby/site_ruby/rubygems/specification.rb
15 /usr/local/share/ruby/site_ruby/rubygems/exceptions.rb
16 /usr/share/rubygems/rubygems/defaults/operating_system.rb
17 /usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_gem.rb
18 /usr/share/ruby/thread.rb
19 /usr/share/ruby/monitor.rb
20 /usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb
21 /usr/local/share/ruby/site_ruby/rubygems.rb
22 /usr/local/share/ruby/site_ruby/rubygems/path_support.rb
23 /usr/local/share/ruby/site_ruby/rubygems/dependency.rb
24 /usr/local/share/gems/gems/tdsql-0.2/lib/tdsql/version.rb
25 /usr/share/ruby/forwardable.rb
26 /usr/share/ruby/English.rb
27 /usr/lib64/ruby/date_core.so
28 /usr/share/ruby/date/format.rb
29 /usr/share/ruby/date.rb
30 /usr/lib64/ruby/stringio.so
31 /usr/share/ruby/csv.rb
32 /usr/share/ruby/vendor_ruby/psych/syntax_error.rb
33 /usr/lib64/ruby/vendor_ruby/psych.so
34 /usr/share/ruby/vendor_ruby/psych/nodes/node.rb
35 /usr/share/ruby/vendor_ruby/psych/nodes/stream.rb
36 /usr/share/ruby/vendor_ruby/psych/nodes/document.rb
37 /usr/share/ruby/vendor_ruby/psych/nodes/sequence.rb
38 /usr/share/ruby/vendor_ruby/psych/nodes/scalar.rb
39 /usr/share/ruby/vendor_ruby/psych/nodes/mapping.rb
40 /usr/share/ruby/vendor_ruby/psych/nodes/alias.rb
41 /usr/share/ruby/vendor_ruby/psych/nodes.rb
42 /usr/share/ruby/vendor_ruby/psych/streaming.rb
43 /usr/share/ruby/vendor_ruby/psych/visitors/visitor.rb
44 /usr/lib64/ruby/strscan.so
45 /usr/share/ruby/vendor_ruby/psych/scalar_scanner.rb
46 /usr/share/ruby/vendor_ruby/psych/visitors/to_ruby.rb
47 /usr/share/ruby/vendor_ruby/psych/visitors/emitter.rb
48 /usr/share/ruby/vendor_ruby/psych/visitors/yaml_tree.rb
49 /usr/share/ruby/vendor_ruby/psych/json/ruby_events.rb
50 /usr/share/ruby/vendor_ruby/psych/visitors/json_tree.rb
51 /usr/share/ruby/vendor_ruby/psych/visitors/depth_first.rb
52 /usr/share/ruby/vendor_ruby/psych/visitors.rb
53 /usr/share/ruby/vendor_ruby/psych/handler.rb
54 /usr/share/ruby/vendor_ruby/psych/tree_builder.rb
55 /usr/share/ruby/vendor_ruby/psych/parser.rb
56 /usr/share/ruby/vendor_ruby/psych/omap.rb
57 /usr/share/ruby/vendor_ruby/psych/set.rb
58 /usr/share/ruby/vendor_ruby/psych/coder.rb
59 /usr/share/ruby/vendor_ruby/psych/core_ext.rb
60 /usr/share/ruby/vendor_ruby/psych/deprecated.rb
61 /usr/share/ruby/vendor_ruby/psych/stream.rb
62 /usr/share/ruby/vendor_ruby/psych/json/yaml_events.rb
63 /usr/share/ruby/vendor_ruby/psych/json/tree_builder.rb
64 /usr/share/ruby/vendor_ruby/psych/json/stream.rb
65 /usr/share/ruby/vendor_ruby/psych/handlers/document_stream.rb
66 /usr/share/ruby/vendor_ruby/psych.rb
67 /usr/share/ruby/yaml.rb
68 /usr/share/ruby/logger.rb
69 /usr/local/share/gems/gems/tdsql-0.2/lib/tdsql/querify.rb
70 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/version.rb
71 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/exception.rb
72 /usr/local/lib64/gems/ruby/teradata-cli-0.0.12/teradata-cli/cli.so
73 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/cli.rb
74 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/utils.rb
75 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb
76 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/dbobject.rb
77 /usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli.rb
78 /usr/local/share/gems/gems/tdsql-0.2/lib/tdsql.rb
79 /usr/lib64/ruby/enc/utf_16le.so
80 /usr/lib64/ruby/enc/utf_16be.so

I do not know what happen and I'll try to do this with an other way (I just want to report this)

History

#1 Updated by Eric Wong over 1 year ago

waghanza@gmail.com wrote:

I have made a query on a [[[http://teradata.com|terradata]]] server using https://github.com/priviterag/teradata-cli

/usr/local/share/gems/gems/teradata-cli-0.0.12/lib/teradata-cli/connection.rb:1055:
[BUG] object allocation during garbage collection phase

It is likely the following in ext/teradata-cli/cli/cli.c:

  static void
cli_free(struct rb_cli *p)
{
  if (p->logging_on) {
    logoff(p, Qtrue);
  }
}

Maybe if disabling logging will avoid calling the logoff function,
you won't hit the [BUG].

The logoff function is not safe to call inside the GC free phase
since it uses rb_raise:

  static void
logoff(struct rb_cli *p, VALUE force)
{
  Int32 status;
  char dummy[4] = {0, 0, 0, 0};

  p->dbcarea.func = DBFDSC;
  DBCHCL(&status, dummy, &p->dbcarea);
  if (!force && status != EM_OK) {
    rb_raise(CLIError, "CLI error: [%s] %s",
    status_name(status), p->dbcarea.msg_text);
  }
  p->logging_on = Qfalse;
}

I do not know the non-Ruby API at all, so DBCHCL/DBFDSC macros /may/
not be safe, either.

Can you contact the teradata-cli authors and forward this to them?
I don't know anything about teradata-cli and do not have time to test.

0 enumerator.so
1 /usr/lib64/ruby/enc/encdb.so
2 /usr/lib64/ruby/enc/trans/transdb.so
27 /usr/lib64/ruby/date_core.so
30 /usr/lib64/ruby/stringio.so
33 /usr/lib64/ruby/vendor_ruby/psych.so
44 /usr/lib64/ruby/strscan.so
72 /usr/local/lib64/gems/ruby/teradata-cli-0.0.12/teradata-cli/cli.so
79 /usr/lib64/ruby/enc/utf_16le.so
80 /usr/lib64/ruby/enc/utf_16be.so</pre>

The rest of the C extensions you have look to be in the standard distro,
so teradata-cli/cli.so was the most likely candidate to look for bugs
in.

#2 Updated by Eric Hodel over 1 year ago

  • Category deleted (core)
  • Status changed from Open to Third Party's Issue

Also available in: Atom PDF