Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Resolve issues while scanning for printer #22

Open
g00m opened this issue Jun 28, 2016 · 5 comments
Open

Resolve issues while scanning for printer #22

g00m opened this issue Jun 28, 2016 · 5 comments

Comments

@g00m
Copy link

g00m commented Jun 28, 2016

I scan with the following code example for printers. After about 40 rounds in the for loop the following error appears:

compat.c: write() failed: Bad file descriptor
ruby: compat.c:425: sdref_free: Assertion `__ret == 0' failed.
compat.c: write() failed: Broken pipe
compat.c: read() failed: EOF

Any ideas how to fix this? Looks like it is crashing in the avahi-lib in this line:

ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT));

require 'dnssd'

service =  '_http._tcp' #network printer
resolved = []

i = 1
while i <=100
 DNSSD.browse service do |b|
   DNSSD.resolve(b) do |r|
     resolved << r
   end
 end

 sleep 0.5
 puts "***** Round #{i} *****"
 resolved.each do |r|
   puts r.fullname
 end
 i+=1
 resolved = []
end
@tenderlove
Copy link
Owner

Looks like the file descriptor is getting closed, though I'm not sure which one. Is there any more stack trace? It seems like you're using Linux, is that correct? Can you start the process with gdb and see what the full stack trace is?

Thanks/

@g00m
Copy link
Author

g00m commented Jun 29, 2016

Thanks for your fast reply!
You are right. I'm using Ubuntu 16.04 with avahi 0.6.32, Ruby 2.2.1 and your current dnssd gem.
I had a bit trouble using gdb as followed:

gdp --args ruby dnssd_test.rb

I'm not experienced with C so the trace does not make any sense to me.
After that i typed 'r' and the file was executed with the following output:

Starting program: /home/user/.rvm/rubies/ruby-2.2.1/bin/ruby dnssd_test.rb
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7ff5700 (LWP 13188)]
[New Thread 0x7ffff5078700 (LWP 13189)]
[New Thread 0x7ffff4776700 (LWP 13190)]
[New Thread 0x7fffeffff700 (LWP 13191)]
[New Thread 0x7ffff4574700 (LWP 13192)]
[New Thread 0x7fffef7fe700 (LWP 13193)]
[New Thread 0x7ffff4372700 (LWP 13194)]
[New Thread 0x7fffeeffd700 (LWP 13195)]
[New Thread 0x7ffff4170700 (LWP 13196)]
[New Thread 0x7fffee7fc700 (LWP 13197)]
[New Thread 0x7fffedefa700 (LWP 13198)]
[New Thread 0x7fffeddf9700 (LWP 13199)]
[New Thread 0x7fffed4f7700 (LWP 13200)]
[New Thread 0x7fffed3f6700 (LWP 13201)]
[New Thread 0x7fffecaf4700 (LWP 13202)]
[New Thread 0x7fffec9f3700 (LWP 13203)]
[New Thread 0x7fffd7fff700 (LWP 13204)]
***** Round 1 *****
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
Samsung\032CLX-3170\032Series\032\040SEC001599618A14\041._http._tcp.local.
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
[New Thread 0x7fffd7efe700 (LWP 13205)]
[New Thread 0x7fffd75fc700 (LWP 13206)]
[New Thread 0x7fffd74fb700 (LWP 13207)]
[New Thread 0x7fffd6bf9700 (LWP 13208)]
[New Thread 0x7fffd6af8700 (LWP 13209)]
[New Thread 0x7fffd61f6700 (LWP 13210)]
[New Thread 0x7fffd60f5700 (LWP 13211)]
[New Thread 0x7fffd57f3700 (LWP 13212)]
[New Thread 0x7fffd56f2700 (LWP 13213)]
[New Thread 0x7fffd4df0700 (LWP 13214)]
[New Thread 0x7fffd4cef700 (LWP 13215)]
[New Thread 0x7fffd43ed700 (LWP 13216)]
[New Thread 0x7fffb3fff700 (LWP 13217)]
[New Thread 0x7fffd41eb700 (LWP 13218)]
[New Thread 0x7fffb37fe700 (LWP 13219)]
[New Thread 0x7fffb2efc700 (LWP 13220)]
***** Round 2 *****
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
.....
.....
.....
***** Round 30 *****
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C97201\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
Officejet\032Pro\0328600\032\091C67D30\093._http._tcp.local.
[Thread 0x7ffee6fa9700 (LWP 13746) exited]
[New Thread 0x7ffee3296700 (LWP 13760)]
[Thread 0x7ffee3296700 (LWP 13760) exited]
[Thread 0x7fff2f905700 (LWP 13476) exited]
[Thread 0x7fff0a051700 (LWP 13628) exited]
[Thread 0x7fff30308700 (LWP 13474) exited]
/home/user/.rvm/gems/ruby-2.2.1@z-wave/gems/dnssd-3.0.2/lib/dnssd/service.rb:66:in _browse': DNSSD operation failed with error code: -65553 (DNSSD::RefusedError) from /home/user/.rvm/gems/ruby-2.2.1@z-wave/gems/dnssd-3.0.2/lib/dnssd/service.rb:66:inbrowse'
from /home/user/.rvm/gems/ruby-2.2.1@z-wave/gems/dnssd-3.0.2/lib/dnssd.rb:95:in browse' from dnssd_test.rb:9:in

'
[Thread 0x7fff17c93700 (LWP 13580) exited]
[Thread 0x7fffd57f3700 (LWP 13212) exited]
[Thread 0x7ffef23df700 (LWP 13710) exited]
[Thread 0x7fff4c58f700 (LWP 13331) exited]
[Thread 0x7fff1a49f700 (LWP 13566) exited]
.....
....
....
[Thread 0x7fffb02ec700 (LWP 13232) exited]
[Thread 0x7fff0633e700 (LWP 13645) exited]
compat.c: read() failed: Connection reset by peer
[Thread 0x7fff36726700 (LWP 13425) exited]
[Thread 0x7fff05039700 (LWP 13648) exited]
.....
....
....
compat.c: write() failed: Bad file descriptor
ruby: compat.c:425: sdref_free: Assertion `__ret == 0' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff756dc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) backtrace full
#0 0x00007ffff756dc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007ffff7571028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#2 0x00007ffff7566bf6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#3 0x00007ffff7566ca2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#4 0x00007ffff58e63cc in ?? () from /usr/lib/x86_64-linux-gnu/libdns_sd.so.1
No symbol table info available.
#5 0x00007ffff5aede76 in dnssd_service_free_client (client=0x7fffd00025f0) at service.c:30
No locals.
#6 dnssd_service_free (ptr=0x7fffd00025f0) at service.c:40
client = 0x7fffd00025f0
#7 0x00007ffff7998d64 in run_final (objspace=0x6039f0, zombie=10581120) at gc.c:2463
key = 10583280
table = 0
#8 finalize_list (objspace=objspace@entry=0x6039f0, zombie=10581120) at gc.c:2479
next_zombie = 10579560
page = 0xa13d10
#9 0x00007ffff79a5639 in rb_objspace_call_finalizer (objspace=0x6039f0) at gc.c:2627
p =
pend =
i =
#10 rb_gc_call_finalizer_at_exit () at gc.c:2552
No locals.
#11 0x00007ffff7985266 in ruby_finalize_1 () at eval.c:128
No locals.
#12 ruby_cleanup (ex=1) at eval.c:229
_th = 0x6035f0
_tag = {tag = 0, retval = 140733193388034, buf = {{__jmpbuf = {140737488344336,
140737347343176, 140737488343552, 140737347332712, 140737488344368,
140737347341680, 140737488344112, 140737488344320},
__mask_was_saved = 4196496, __saved_mask = {__val = {140737351798936, 0,
140737488344688, 0, 0, 0, 140737351947559, 5, 0, 0, 140737346815400,
10663320, 0, 4196496, 140737351976149, 6}}}}, prev = 0x0}
state = 0
errs = {6531280, 6531280}
th = 0x6035f0
nerr =
#13 0x00007ffff7985493 in ruby_run_node (n=0xa2b598) at eval.c:309
status = -141600840
#14 0x000000000040088b in main (argc=2, argv=0x7fffffffd678) at main.c:36
variable_in_this_stack_frame = 0
(gdb)
#0 0x00007ffff756dc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007ffff7571028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#2 0x00007ffff7566bf6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#3 0x00007ffff7566ca2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#4 0x00007ffff58e63cc in ?? () from /usr/lib/x86_64-linux-gnu/libdns_sd.so.1
No symbol table info available.
#5 0x00007ffff5aede76 in dnssd_service_free_client (client=0x7fffd00025f0) at service.c:30
No locals.
#6 dnssd_service_free (ptr=0x7fffd00025f0) at service.c:40
client = 0x7fffd00025f0
#7 0x00007ffff7998d64 in run_final (objspace=0x6039f0, zombie=10581120) at gc.c:2463
key = 10583280
table = 0
#8 finalize_list (objspace=objspace@entry=0x6039f0, zombie=10581120) at gc.c:2479
next_zombie = 10579560
page = 0xa13d10
#9 0x00007ffff79a5639 in rb_objspace_call_finalizer (objspace=0x6039f0) at gc.c:2627
p =
pend =
i =
#10 rb_gc_call_finalizer_at_exit () at gc.c:2552
No locals.
#11 0x00007ffff7985266 in ruby_finalize_1 () at eval.c:128
No locals.
#12 ruby_cleanup (ex=1) at eval.c:229
_th = 0x6035f0
_tag = {tag = 0, retval = 140733193388034, buf = {{__jmpbuf = {140737488344336,
140737347343176, 140737488343552, 140737347332712, 140737488344368,
140737347341680, 140737488344112, 140737488344320},
__mask_was_saved = 4196496, __saved_mask = {__val = {140737351798936, 0,
140737488344688, 0, 0, 0, 140737351947559, 5, 0, 0, 140737346815400,
10663320, 0, 4196496, 140737351976149, 6}}}}, prev = 0x0}
state = 0
errs = {6531280, 6531280}
th = 0x6035f0
nerr =
#13 0x00007ffff7985493 in ruby_run_node (n=0xa2b598) at eval.c:309
status = -141600840
#14 0x000000000040088b in main (argc=2, argv=0x7fffffffd678) at main.c:36
variable_in_this_stack_frame = 0
(gdb)
#0 0x00007ffff756dc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007ffff7571028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#2 0x00007ffff7566bf6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#3 0x00007ffff7566ca2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#4 0x00007ffff58e63cc in ?? () from /usr/lib/x86_64-linux-gnu/libdns_sd.so.1
No symbol table info available.
#5 0x00007ffff5aede76 in dnssd_service_free_client (client=0x7fffd00025f0) at service.c:30
No locals.
#6 dnssd_service_free (ptr=0x7fffd00025f0) at service.c:40
client = 0x7fffd00025f0
#7 0x00007ffff7998d64 in run_final (objspace=0x6039f0, zombie=10581120) at gc.c:2463
key = 10583280
table = 0
#8 finalize_list (objspace=objspace@entry=0x6039f0, zombie=10581120) at gc.c:2479
next_zombie = 10579560
page = 0xa13d10
#9 0x00007ffff79a5639 in rb_objspace_call_finalizer (objspace=0x6039f0) at gc.c:2627
p =
pend =
i =
#10 rb_gc_call_finalizer_at_exit () at gc.c:2552
No locals.
#11 0x00007ffff7985266 in ruby_finalize_1 () at eval.c:128
No locals.
#12 ruby_cleanup (ex=1) at eval.c:229
_th = 0x6035f0
_tag = {tag = 0, retval = 140733193388034, buf = {{__jmpbuf = {140737488344336,
140737347343176, 140737488343552, 140737347332712, 140737488344368,
140737347341680, 140737488344112, 140737488344320},
__mask_was_saved = 4196496, __saved_mask = {__val = {140737351798936, 0,
140737488344688, 0, 0, 0, 140737351947559, 5, 0, 0, 140737346815400,
10663320, 0, 4196496, 140737351976149, 6}}}}, prev = 0x0}
state = 0
errs = {6531280, 6531280}
th = 0x6035f0
nerr =
#13 0x00007ffff7985493 in ruby_run_node (n=0xa2b598) at eval.c:309
status = -141600840
#14 0x000000000040088b in main (argc=2, argv=0x7fffffffd678) at main.c:36
variable_in_this_stack_frame = 0
(gdb)
#0 0x00007ffff756dc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007ffff7571028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#2 0x00007ffff7566bf6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#3 0x00007ffff7566ca2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#4 0x00007ffff58e63cc in ?? () from /usr/lib/x86_64-linux-gnu/libdns_sd.so.1
No symbol table info available.
#5 0x00007ffff5aede76 in dnssd_service_free_client (client=0x7fffd00025f0) at service.c:30
No locals.
#6 dnssd_service_free (ptr=0x7fffd00025f0) at service.c:40
client = 0x7fffd00025f0
#7 0x00007ffff7998d64 in run_final (objspace=0x6039f0, zombie=10581120) at gc.c:2463
key = 10583280
table = 0
#8 finalize_list (objspace=objspace@entry=0x6039f0, zombie=10581120) at gc.c:2479
next_zombie = 10579560
page = 0xa13d10
#9 0x00007ffff79a5639 in rb_objspace_call_finalizer (objspace=0x6039f0) at gc.c:2627
p =
pend =
i =
#10 rb_gc_call_finalizer_at_exit () at gc.c:2552
No locals.
#11 0x00007ffff7985266 in ruby_finalize_1 () at eval.c:128
No locals.
#12 ruby_cleanup (ex=1) at eval.c:229
_th = 0x6035f0
_tag = {tag = 0, retval = 140733193388034, buf = {{__jmpbuf = {140737488344336,
140737347343176, 140737488343552, 140737347332712, 140737488344368,
140737347341680, 140737488344112, 140737488344320},
__mask_was_saved = 4196496, __saved_mask = {__val = {140737351798936, 0,
140737488344688, 0, 0, 0, 140737351947559, 5, 0, 0, 140737346815400,
10663320, 0, 4196496, 140737351976149, 6}}}}, prev = 0x0}
state = 0
errs = {6531280, 6531280}
th = 0x6035f0
nerr =
#13 0x00007ffff7985493 in ruby_run_node (n=0xa2b598) at eval.c:309
status = -141600840
#14 0x000000000040088b in main (argc=2, argv=0x7fffffffd678) at main.c:36
variable_in_this_stack_frame = 0
(gdb)
#0 0x00007ffff756dc37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007ffff7571028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#2 0x00007ffff7566bf6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#3 0x00007ffff7566ca2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#4 0x00007ffff58e63cc in ?? () from /usr/lib/x86_64-linux-gnu/libdns_sd.so.1
No symbol table info available.
#5 0x00007ffff5aede76 in dnssd_service_free_client (client=0x7fffd00025f0) at service.c:30
No locals.
#6 dnssd_service_free (ptr=0x7fffd00025f0) at service.c:40
client = 0x7fffd00025f0
#7 0x00007ffff7998d64 in run_final (objspace=0x6039f0, zombie=10581120) at gc.c:2463
key = 10583280
table = 0
#8 finalize_list (objspace=objspace@entry=0x6039f0, zombie=10581120) at gc.c:2479
next_zombie = 10579560
page = 0xa13d10
#9 0x00007ffff79a5639 in rb_objspace_call_finalizer (objspace=0x6039f0) at gc.c:2627
p =
pend =
i =
#10 rb_gc_call_finalizer_at_exit () at gc.c:2552
No locals.
#11 0x00007ffff7985266 in ruby_finalize_1 () at eval.c:128
No locals.
#12 ruby_cleanup (ex=1) at eval.c:229
_th = 0x6035f0
_tag = {tag = 0, retval = 140733193388034, buf = {{__jmpbuf = {140737488344336,
140737347343176, 140737488343552, 140737347332712, 140737488344368,
140737347341680, 140737488344112, 140737488344320},
__mask_was_saved = 4196496, __saved_mask = {__val = {140737351798936, 0,
140737488344688, 0, 0, 0, 140737351947559, 5, 0, 0, 140737346815400,
10663320, 0, 4196496, 140737351976149, 6}}}}, prev = 0x0}
state = 0
errs = {6531280, 6531280}
th = 0x6035f0
nerr =
#13 0x00007ffff7985493 in ruby_run_node (n=0xa2b598) at eval.c:309
status = -141600840
#14 0x000000000040088b in main (argc=2, argv=0x7fffffffd678) at main.c:36
variable_in_this_stack_frame = 0

@towingie
Copy link

any progress? same error here..

@g00m
Copy link
Author

g00m commented Mar 19, 2018

Nope, no progress on our side. We are lacking knowledge to debug further. If anyone can/will help us we could work together

@ukd1
Copy link

ukd1 commented Aug 30, 2020

Also having similar issues - @tenderlove is this maintained anymore? need any help?

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

No branches or pull requests

4 participants