mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	handle_interrupt to defend monitor state [Bug #15992]
If an exception is raised from another thread for example Timeout and this thread is just after `mon_exit`'s `@mon_owner = nil`, the exception breaks the state of MonitorMixin. To prevent that situation, it need to block interruption in mon_enter and mon_exit.
This commit is contained in:
		
							parent
							
								
									1d2ec4b216
								
							
						
					
					
						commit
						f91879a7b5
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		|  | @ -225,11 +225,13 @@ module MonitorMixin | ||||||
|   # +MonitorMixin+. |   # +MonitorMixin+. | ||||||
|   # |   # | ||||||
|   def mon_synchronize |   def mon_synchronize | ||||||
|     mon_enter |     # Prevent interrupt on handling interrupts; for example timeout errors | ||||||
|  |     # it may break locking state. | ||||||
|  |     Thread.handle_interrupt(Exception => :never){ mon_enter } | ||||||
|     begin |     begin | ||||||
|       yield |       yield | ||||||
|     ensure |     ensure | ||||||
|       mon_exit |       Thread.handle_interrupt(Exception => :never){ mon_exit } | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   alias synchronize mon_synchronize |   alias synchronize mon_synchronize | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 NARUSE, Yui
						NARUSE, Yui