Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault generating datamatrix barcode #83

Open
AndrewRayCode opened this issue Aug 22, 2017 · 3 comments
Open

segfault generating datamatrix barcode #83

AndrewRayCode opened this issue Aug 22, 2017 · 3 comments

Comments

@AndrewRayCode
Copy link

    barcode = Barby::DataMatrix.new(json)
    blob = Barby::PngOutputter.new(barcode)
    blob.xdim = 3
    blob.ydim = 3
    barcode_image = Tempfile.new(['barcode', '.png'])
    barcode_image.binmode
    barcode_image.write(blob.to_png) # segfault on this line
    barcode_image.close

Segfault start:

.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/barcode/data_matrix.rb:24: [BUG] Segmentation fault at 0x0000000000001d
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin16.0]

-- Control frame information -----------------------------------------------
c:0126 p:0039 s:0640 e:000638 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/barcode/data_matrix.rb:24
c:0125 p:0007 s:0636 e:000635 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/barcode/data_matrix.rb:29
c:0124 p:0041 s:0633 e:000632 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter.rb:84
c:0123 p:0014 s:0629 e:000628 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:105
c:0122 p:0007 s:0626 e:000625 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:77
c:0121 p:0007 s:0623 e:000622 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:85
c:0120 p:0016 s:0620 e:000618 BLOCK  .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:23
c:0119 p:0020 s:0614 e:000613 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter.rb:122
c:0118 p:0013 s:0608 e:000607 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:22
c:0117 p:0043 s:0604 e:000603 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:66
c:0116 p:0009 s:0599 e:000598 METHOD .rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:72
c:0114 p:---- s:0593 e:000592 CFUNC  :eval
c:0110 p:---- s:0570 e:000569 CFUNC  :catch
c:0108 p:---- s:0564 e:000563 CFUNC  :catch
c:0105 p:---- s:0550 e:000549 CFUNC  :loop
c:0102 p:---- s:0542 e:000541 CFUNC  :call
c:0094 p:---- s:0513 e:000512 CFUNC  :catch
c:0089 p:0083 s:0493 E:001eb0 METHOD dev/project/lib/barcode.rb:41
c:0088 p:0015 s:0485 E:0019d0 METHOD dev/project/lib/barcode.rb:19
c:0086 p:---- s:0472 e:000471 CFUNC  :new
c:0085 p:0016 s:0468 E:001ab0 METHOD dev/project/app/models/outbound_fax_pdf.rb:19
c:0084 p:0007 s:0464 E:001b28 METHOD dev/project/app/models/outbound_fax_pdf.rb:11
c:0082 p:---- s:0458 e:000457 CFUNC  :call
c:0080 p:---- s:0452 e:000451 CFUNC  :call
c:0077 p:---- s:0439 e:000438 CFUNC  :call
c:0071 p:---- s:0417 e:000416 CFUNC  :catch
c:0051 p:---- s:0303 e:000302 CFUNC  :each
c:0003 p:---- s:0008 e:000007 CFUNC  :call
c:0002 p:0042 s:0005 E:002090 BLOCK  .rvm/gems/ruby-2.1.5@project/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474 [FINISH]
c:0001 p:---- s:0002 e:000001 TOP    [FINISH]

.rvm/gems/ruby-2.1.5@project/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
.rvm/gems/ruby-2.1.5@project/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `call'
dev/project/app/models/outbound_fax_pdf.rb:19:in `new'
dev/project/lib/barcode.rb:41:in `generate_barcode_image'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:72:in `to_png'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:66:in `to_datastream'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:22:in `to_image'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter.rb:122:in `with_options'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:23:in `block in to_image'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:85:in `full_width'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:77:in `width'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter/png_outputter.rb:105:in `length'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/outputter.rb:84:in `encoding'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/barcode/data_matrix.rb:29:in `encoding'
.rvm/gems/ruby-2.1.5@project/gems/barby-0.6.5/lib/barby/barcode/data_matrix.rb:24:in `encoder'

-- C level backtrace information -------------------------------------------
0   libruby.2.1.0.dylib                 0x000000010e264096 rb_vm_bugreport + 134
1   libruby.2.1.0.dylib                 0x000000010e1194a4 report_bug + 292
2   libruby.2.1.0.dylib                 0x000000010e119373 rb_bug + 179
3   libruby.2.1.0.dylib                 0x000000010e1e6723 sigsegv + 131
4   libsystem_platform.dylib            0x00007fffb8defb3a _sigtramp + 26
5   ???                                 0x000000000000001d 0x0 + 29
6   libruby.2.1.0.dylib                 0x000000010e1eea29 st_lookup + 41
7   libruby.2.1.0.dylib                 0x000000010e25ea52 vm_setivar + 322
8   libruby.2.1.0.dylib                 0x000000010e247e22 vm_exec_core + 930
9   libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
10  libruby.2.1.0.dylib                 0x000000010e262968 eval_string_with_cref + 1512
11  libruby.2.1.0.dylib                 0x000000010e255b51 rb_f_eval + 161
12  libruby.2.1.0.dylib                 0x000000010e12a782 bind_eval + 82
13  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
14  libruby.2.1.0.dylib                 0x000000010e24acab vm_exec_core + 12843
15  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
16  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
17  libruby.2.1.0.dylib                 0x000000010e262cec catch_i + 76
18  libruby.2.1.0.dylib                 0x000000010e256888 rb_catch_protect + 152
19  libruby.2.1.0.dylib                 0x000000010e256e4d rb_f_catch + 77
20  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
21  libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
22  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
23  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
24  libruby.2.1.0.dylib                 0x000000010e262cec catch_i + 76
25  libruby.2.1.0.dylib                 0x000000010e256888 rb_catch_protect + 152
26  libruby.2.1.0.dylib                 0x000000010e256e4d rb_f_catch + 77
27  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
28  libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
29  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
30  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
31  libruby.2.1.0.dylib                 0x000000010e262d58 loop_i + 40
32  libruby.2.1.0.dylib                 0x000000010e122092 rb_rescue2 + 274
33  libruby.2.1.0.dylib                 0x000000010e256ed3 rb_f_loop + 51
34  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
35  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
36  libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
37  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
38  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
39  libruby.2.1.0.dylib                 0x000000010e257b51 vm_invoke_proc + 177
40  libruby.2.1.0.dylib                 0x000000010e257a90 rb_vm_invoke_proc + 32
41  libruby.2.1.0.dylib                 0x000000010e128c70 proc_call + 112
42  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
43  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
44  libruby.2.1.0.dylib                 0x000000010e24acab vm_exec_core + 12843
45  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
46  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
47  libruby.2.1.0.dylib                 0x000000010e262cec catch_i + 76
48  libruby.2.1.0.dylib                 0x000000010e256888 rb_catch_protect + 152
49  libruby.2.1.0.dylib                 0x000000010e256e4d rb_f_catch + 77
50  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
51  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
52  libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
53  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
54  libruby.2.1.0.dylib                 0x000000010e2616ba rb_call0 + 250
55  libruby.2.1.0.dylib                 0x000000010e265957 rb_debug_inspector_open + 855
56  libruby.2.1.0.dylib                 0x000000010e1223f6 rb_ensure + 166
58  libruby.2.1.0.dylib                 0x000000010e269078 exec_hooks_protected + 216
59  libruby.2.1.0.dylib                 0x000000010e266c72 rb_threadptr_exec_event_hooks_orig + 450
60  libruby.2.1.0.dylib                 0x000000010e24a381 vm_exec_core + 10497
61  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
62  libruby.2.1.0.dylib                 0x000000010e2616ba rb_call0 + 250
63  libruby.2.1.0.dylib                 0x000000010e1776a9 rb_class_new_instance + 41
64  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
65  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
66  libruby.2.1.0.dylib                 0x000000010e24acab vm_exec_core + 12843
67  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
68  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
69  libruby.2.1.0.dylib                 0x000000010e257b51 vm_invoke_proc + 177
70  libruby.2.1.0.dylib                 0x000000010e260891 vm_call0_body + 961
71  libruby.2.1.0.dylib                 0x000000010e254153 rb_vm_call + 51
72  libruby.2.1.0.dylib                 0x000000010e127c40 rb_method_call_with_block + 304
73  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
74  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
75  libruby.2.1.0.dylib                 0x000000010e24acab vm_exec_core + 12843
76  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
77  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
78  libruby.2.1.0.dylib                 0x000000010e257b51 vm_invoke_proc + 177
79  libruby.2.1.0.dylib                 0x000000010e257a90 rb_vm_invoke_proc + 32
80  libruby.2.1.0.dylib                 0x000000010e128c70 proc_call + 112
81  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
82  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
83  libruby.2.1.0.dylib                 0x000000010e24acab vm_exec_core + 12843
84  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
85  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
86  libruby.2.1.0.dylib                 0x000000010e257b51 vm_invoke_proc + 177
87  libruby.2.1.0.dylib                 0x000000010e257a90 rb_vm_invoke_proc + 32
88  libruby.2.1.0.dylib                 0x000000010e128c70 proc_call + 112
89  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
90  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
91  libruby.2.1.0.dylib                 0x000000010e24acab vm_exec_core + 12843
92  libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
93  libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
94  libruby.2.1.0.dylib                 0x000000010e262cec catch_i + 76
95  libruby.2.1.0.dylib                 0x000000010e256888 rb_catch_protect + 152
96  libruby.2.1.0.dylib                 0x000000010e256e4d rb_f_catch + 77
97  libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
98  libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
99  libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
100 libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
101 libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
102 libruby.2.1.0.dylib                 0x000000010e25535c rb_yield + 156
103 libruby.2.1.0.dylib                 0x000000010e0da619 rb_ary_each + 41
104 libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
105 libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
106 libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
107 libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
108 libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
109 libruby.2.1.0.dylib                 0x000000010e257b51 vm_invoke_proc + 177
110 libruby.2.1.0.dylib                 0x000000010e257a90 rb_vm_invoke_proc + 32
111 libruby.2.1.0.dylib                 0x000000010e128c70 proc_call + 112
112 libruby.2.1.0.dylib                 0x000000010e25d40a vm_call_cfunc + 986
113 libruby.2.1.0.dylib                 0x000000010e25cd1d vm_call_method + 1037
114 libruby.2.1.0.dylib                 0x000000010e24aaea vm_exec_core + 12394
115 libruby.2.1.0.dylib                 0x000000010e258909 vm_exec + 137
116 libruby.2.1.0.dylib                 0x000000010e26200b invoke_block_from_c + 2171
117 libruby.2.1.0.dylib                 0x000000010e257b51 vm_invoke_proc + 177
118 libruby.2.1.0.dylib                 0x000000010e257a90 rb_vm_invoke_proc + 32
119 libruby.2.1.0.dylib                 0x000000010e2716d2 thread_start_func_2 + 498
120 libruby.2.1.0.dylib                 0x000000010e2714c5 thread_start_func_1 + 149
121 libsystem_pthread.dylib             0x00007fffb8df993b _pthread_body + 180
122 libsystem_pthread.dylib             0x00007fffb8df9887 _pthread_body + 0
@AndrewRayCode
Copy link
Author

I've narrowed this down to a fairly small test case. This segfaults for me indeterminately, about 50% of the time:

require 'barby/barcode/data_matrix'
require 'barby/outputter/png_outputter'
require 'json'

data = { hello: "TEST TEST TEST TEST" }
barcode = Barby::DataMatrix.new(JSON.generate(data))
code = barcode.to_png
/Users/andy/.rvm/gems/ruby-2.1.5@projecct/gems/barby-0.6.5/lib/barby/barcode/data_matrix.rb:26: [BUG] Segmentation fault at 0x0000000000001d

@AndrewRayCode
Copy link
Author

This is kind of baffling. If you change certain things about the above input data, it causes the segfault, and other times it works.

Other four letter words fail:

data = { hello: "BAND BAND BAND BAND" }

But 5 words instead of 4 does not fail:

data = { hello: "BAND BAND BAND BAND BAND" }

@AndrewRayCode
Copy link
Author

Happens on Ruby 2.4.1 too, not just the version I'm using (ruby-2.1.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant