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 sometimes occurred by error handling #66

Open
matsumotory opened this issue Feb 23, 2017 · 6 comments
Open

Segfault sometimes occurred by error handling #66

matsumotory opened this issue Feb 23, 2017 · 6 comments

Comments

@matsumotory
Copy link
Contributor

matsumotory commented Feb 23, 2017

Hi, @mattn !

mruby-uv error handling sometimes occurred segfault.

  • uname
$ uname -a
Linux matsumotory 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • disable ivp6
sudo sysctl net.ipv6.conf.all.disable_ipv6=0
  • build_config.rb
MRuby::Build.new do |conf|
  toolchain :gcc
  conf.gembox 'default'
  conf.gem mgem: 'mruby-uv'
  conf.enable_test
end
  • run test, sometimes catch raise error
$ ./bin/mrbtest
mrbtest - Embeddable Ruby Test

.........................................................................................?..........................................................................................................................
............................................................................................................................................XXXXX...................................................................
..................................................................................................................?.................................................................................................
.....................................................................................................................................................................................................................................................................................................................................................................
Skip: Struct.new removes existing constant  redefining Struct with same name cause warnings
UVError: UV::UDP server/client => address not available (mrbgems: mruby-uv)
UVError: UV::Prepare, UV::Check => resource busy or locked (mrbgems: mruby-uv)
UVError: UV::Idle => resource busy or locked (mrbgems: mruby-uv)
UVError: UV::TCP IPv6 server/client => address not available (mrbgems: mruby-uv)
UVError: Process => address not available (mrbgems: mruby-uv)
Skip: Module#prepend super in alias  super does not currently work in aliased methods
Total: 991
   OK: 986
   KO: 0
Crash: 5
 Time: 0.29 seconds
  • run test sometimes occurred segfault
$ gdb ./bin/mrbtest
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/mrbtest...done.
(gdb) r
Starting program: /home/ubuntu/DEV/mruby/bin/mrbtest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
mrbtest - Embeddable Ruby Test

[New Thread 0x7ffff70db700 (LWP 652)]
[New Thread 0x7ffff68da700 (LWP 653)]
[New Thread 0x7ffff60d9700 (LWP 654)]
[New Thread 0x7ffff58d8700 (LWP 655)]

Thread 1 "mrbtest" received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x100000008) at malloc.c:2949
2949    malloc.c: No such file or directory.
(gdb) bt
#0  __GI___libc_free (mem=0x100000008) at malloc.c:2949
#1  0x000000000046bd3d in uv_fs_req_cleanup (req=req@entry=0x8001b8) at src/unix/fs.c:1178
#2  0x0000000000458bbe in mrb_uv_req_release (mrb=mrb@entry=0x7c0590, v=...) at /home/ubuntu/DEV/mruby/build/mrbgems/mruby-uv/src/mrb_uv.c:144
#3  0x000000000046192f in mrb_uv_tcp_connect (version=6, self=..., mrb=0x7c0590) at /home/ubuntu/DEV/mruby/build/mrbgems/mruby-uv/src/handle.c:393
#4  mrb_uv_tcp_connect6 (mrb=0x7c0590, self=...) at /home/ubuntu/DEV/mruby/build/mrbgems/mruby-uv/src/handle.c:408
#5  0x00000000004359d8 in mrb_vm_exec (mrb=mrb@entry=0x7c0590, proc=<optimized out>, proc@entry=0x7b9960, pc=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:1229
#6  0x0000000000437fa1 in mrb_vm_run (mrb=0x7c0590, proc=0x7b9960, self=..., stack_keep=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:815
#7  0x0000000000438cfc in mrb_run (self=..., proc=0x7b9960, mrb=0x7c0590) at /home/ubuntu/DEV/mruby/src/vm.c:2558
#8  mrb_yield_with_class (mrb=0x7c0590, b=..., argc=<optimized out>, argv=<optimized out>, self=..., c=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:696
#9  0x000000000043903a in mrb_yield_argv (mrb=mrb@entry=0x7c0590, b=..., argc=argc@entry=0, argv=argv@entry=0x0) at /home/ubuntu/DEV/mruby/src/vm.c:708
#10 0x000000000045dd21 in _uv_timer_cb (timer=<optimized out>) at /home/ubuntu/DEV/mruby/build/mrbgems/mruby-uv/src/handle.c:1358
#11 0x00000000004725d5 in uv__run_timers (loop=loop@entry=0x718b60 <default_loop_struct>) at src/unix/timer.c:165
#12 0x000000000046860a in uv_run (loop=0x718b60 <default_loop_struct>, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:314
#13 0x000000000045529f in mrb_uv_run (mrb=<optimized out>, self=...) at /home/ubuntu/DEV/mruby/build/mrbgems/mruby-uv/src/mrb_uv.c:52
#14 0x00000000004359d8 in mrb_vm_exec (mrb=mrb@entry=0x7c0590, proc=<optimized out>, proc@entry=0x7bc240, pc=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:1229
#15 0x0000000000437fa1 in mrb_vm_run (mrb=0x7c0590, proc=0x7bc240, self=..., stack_keep=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:815
#16 0x000000000043a561 in mrb_top_run (mrb=mrb@entry=0x7c0590, proc=proc@entry=0x7bc240, self=..., stack_keep=stack_keep@entry=0) at /home/ubuntu/DEV/mruby/src/vm.c:2569
#17 0x0000000000429f01 in mrb_load_irep_cxt (c=0x0, bin=<optimized out>, mrb=0x7c0590) at /home/ubuntu/DEV/mruby/src/load.c:638
#18 mrb_load_irep (mrb=0x7c0590, bin=<optimized out>) at /home/ubuntu/DEV/mruby/src/load.c:644
#19 0x00000000004084c9 in GENERATED_TMP_mrb_mruby_uv_gem_test (mrb=0x719420) at /home/ubuntu/DEV/mruby/build/host/mrbgems/mruby-uv/gem_test.c:1470
#20 0x00000000004052d9 in mrbgemtest_init (mrb=mrb@entry=0x719420) at /home/ubuntu/DEV/mruby/build/host/mrbgems/mruby-test/mrbtest.c:104
#21 0x0000000000405363 in mrb_init_mrbtest (mrb=0x719420) at /home/ubuntu/DEV/mruby/build/host/mrbgems/mruby-test/mrbtest.c:38
#22 0x0000000000404c2b in main (argc=1, argv=0x7fffffffead8) at /home/ubuntu/DEV/mruby/mrbgems/mruby-test/driver.c:167
(gdb) 

or

(gdb) r
Starting program: /home/ubuntu/DEV/mruby/bin/mrbtest 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
mrbtest - Embeddable Ruby Test

[New Thread 0x7ffff70db700 (LWP 714)]
[New Thread 0x7ffff68da700 (LWP 715)]
[New Thread 0x7ffff60d9700 (LWP 716)]
[New Thread 0x7ffff58d8700 (LWP 717)]

Thread 1 "mrbtest" received signal SIGSEGV, Segmentation fault.
0x0000000000000015 in ?? ()
(gdb) bt
#0  0x0000000000000015 in ?? ()
#1  0x0000000000468720 in uv__finish_close (handle=0x8077b8) at src/unix/core.c:245
#2  uv__run_closing_handles (loop=0x718b60 <default_loop_struct>) at src/unix/core.c:259
#3  uv_run (loop=0x718b60 <default_loop_struct>, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:325
#4  0x000000000045529f in mrb_uv_run (mrb=<optimized out>, self=...) at /home/ubuntu/DEV/mruby/build/mrbgems/mruby-uv/src/mrb_uv.c:52
#5  0x00000000004359d8 in mrb_vm_exec (mrb=mrb@entry=0x7afeb0, proc=<optimized out>, proc@entry=0x7f0800, pc=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:1229
#6  0x0000000000437fa1 in mrb_vm_run (mrb=0x7afeb0, proc=0x7f0800, self=..., stack_keep=<optimized out>) at /home/ubuntu/DEV/mruby/src/vm.c:815
#7  0x000000000043a561 in mrb_top_run (mrb=mrb@entry=0x7afeb0, proc=proc@entry=0x7f0800, self=..., stack_keep=stack_keep@entry=0) at /home/ubuntu/DEV/mruby/src/vm.c:2569
#8  0x0000000000429f01 in mrb_load_irep_cxt (c=0x0, bin=<optimized out>, mrb=0x7afeb0) at /home/ubuntu/DEV/mruby/src/load.c:638
#9  mrb_load_irep (mrb=0x7afeb0, bin=<optimized out>) at /home/ubuntu/DEV/mruby/src/load.c:644
#10 0x0000000000408693 in GENERATED_TMP_mrb_mruby_uv_gem_test (mrb=0x719420) at /home/ubuntu/DEV/mruby/build/host/mrbgems/mruby-uv/gem_test.c:1495
#11 0x00000000004052d9 in mrbgemtest_init (mrb=mrb@entry=0x719420) at /home/ubuntu/DEV/mruby/build/host/mrbgems/mruby-test/mrbtest.c:104
#12 0x0000000000405363 in mrb_init_mrbtest (mrb=0x719420) at /home/ubuntu/DEV/mruby/build/host/mrbgems/mruby-test/mrbtest.c:38
#13 0x0000000000404c2b in main (argc=1, argv=0x7fffffffead8) at /home/ubuntu/DEV/mruby/mrbgems/mruby-test/driver.c:167

I think this behavior is thread race condition. I just now investigate it. Please check it.

@matsumotory matsumotory changed the title mruby-uv error handling sometimes occurred segfault Segfault sometimes occurred by error handling Feb 23, 2017
@mattn
Copy link
Owner

mattn commented Feb 23, 2017

Thanks for your detailed report! I'll look into it later.

@mattn
Copy link
Owner

mattn commented Feb 24, 2017

I tested this on Windows. But not repro. I'll test this on Linux in later.

@mattn
Copy link
Owner

mattn commented Feb 24, 2017

I tried this 10 times on Linux. But not repro.

don't repro

@matsumotory
Copy link
Contributor Author

Thank you for your investigation. Did you disable ipv6?

@mattn
Copy link
Owner

mattn commented Feb 24, 2017

Yes, I disabled ipv6 with command you wrote.

@matsumotory
Copy link
Contributor Author

fmm, if disabled ipv6, some tests failed such as UV::TCP ipv6. But your log seems all tests passed.

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

2 participants