mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Avoid GCing dead stack after switching away from a fiber
Fixes <https://bugs.ruby-lang.org/issues/14561> and discussed <https://bugs.ruby-lang.org/issues/15362>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									57005046a1
								
							
						
					
					
						commit
						4b99725de9
					
				
					 2 changed files with 11 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								cont.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								cont.c
									
										
									
									
									
								
							|  | @ -1747,6 +1747,7 @@ fiber_store(rb_fiber_t *next_fib, rb_thread_t *th) | |||
|     return fib->cont.value; | ||||
| 
 | ||||
| #else /* FIBER_USE_NATIVE */ | ||||
|     fib->cont.saved_ec.machine.stack_end = NULL; | ||||
|     if (ruby_setjmp(fib->cont.jmpbuf)) { | ||||
|         /* restored */ | ||||
|         fib = th->ec->fiber_ptr; | ||||
|  |  | |||
|  | @ -398,4 +398,14 @@ class TestFiber < Test::Unit::TestCase | |||
|     }.value | ||||
|     assert_equal :ok, ret, '[Bug #14642]' | ||||
|   end | ||||
| 
 | ||||
|   def test_machine_stack_gc | ||||
|     assert_normal_exit <<-RUBY, '[Bug #14561]', timeout: 10 | ||||
|       enum = Enumerator.new { |y| y << 1 } | ||||
|       thread = Thread.new { enum.peek } | ||||
|       thread.join | ||||
|       sleep 5     # pause until thread cache wait time runs out. Native thread exits. | ||||
|       GC.start | ||||
|     RUBY | ||||
|   end | ||||
| end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 samuel
						samuel