mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	gh-117657: Log TSAN warnings to separate files and archive them (#118747)
This ensures we don't lose races that occur in subprocesses or interleave races from workers running in parallel. Log files are collected and packaged into a zipfile that can be downloaded from the "Artifacts" section of the workflow run.
This commit is contained in:
		
							parent
							
								
									a019347947
								
							
						
					
					
						commit
						b88889e9ff
					
				
					 3 changed files with 20 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -486,6 +486,7 @@ jobs:
 | 
				
			||||||
      config_hash: ${{ needs.check_source.outputs.config_hash }}
 | 
					      config_hash: ${{ needs.check_source.outputs.config_hash }}
 | 
				
			||||||
      options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
 | 
					      options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
 | 
				
			||||||
      suppressions_path: Tools/tsan/supressions.txt
 | 
					      suppressions_path: Tools/tsan/supressions.txt
 | 
				
			||||||
 | 
					      tsan_logs_artifact_name: tsan-logs-default
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  build_tsan_free_threading:
 | 
					  build_tsan_free_threading:
 | 
				
			||||||
    name: 'Thread sanitizer (free-threading)'
 | 
					    name: 'Thread sanitizer (free-threading)'
 | 
				
			||||||
| 
						 | 
					@ -496,6 +497,7 @@ jobs:
 | 
				
			||||||
      config_hash: ${{ needs.check_source.outputs.config_hash }}
 | 
					      config_hash: ${{ needs.check_source.outputs.config_hash }}
 | 
				
			||||||
      options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
 | 
					      options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
 | 
				
			||||||
      suppressions_path: Tools/tsan/suppressions_free_threading.txt
 | 
					      suppressions_path: Tools/tsan/suppressions_free_threading.txt
 | 
				
			||||||
 | 
					      tsan_logs_artifact_name: tsan-logs-free-threading
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
 | 
					  # CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
 | 
				
			||||||
  cifuzz:
 | 
					  cifuzz:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										16
									
								
								.github/workflows/reusable-tsan.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								.github/workflows/reusable-tsan.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -11,6 +11,10 @@ on:
 | 
				
			||||||
        description: 'A repo relative path to the suppressions file'
 | 
					        description: 'A repo relative path to the suppressions file'
 | 
				
			||||||
        required: true
 | 
					        required: true
 | 
				
			||||||
        type: string
 | 
					        type: string
 | 
				
			||||||
 | 
					      tsan_logs_artifact_name:
 | 
				
			||||||
 | 
					        description: 'Name of the TSAN logs artifact. Must be unique for each job.'
 | 
				
			||||||
 | 
					        required: true
 | 
				
			||||||
 | 
					        type: string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  build_tsan_reusable:
 | 
					  build_tsan_reusable:
 | 
				
			||||||
| 
						 | 
					@ -41,7 +45,7 @@ jobs:
 | 
				
			||||||
        sudo sysctl -w vm.mmap_rnd_bits=28
 | 
					        sudo sysctl -w vm.mmap_rnd_bits=28
 | 
				
			||||||
    - name: TSAN Option Setup
 | 
					    - name: TSAN Option Setup
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
        echo "TSAN_OPTIONS=suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }}" >> $GITHUB_ENV
 | 
					        echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }} handle_segv=0" >> $GITHUB_ENV
 | 
				
			||||||
        echo "CC=clang" >> $GITHUB_ENV
 | 
					        echo "CC=clang" >> $GITHUB_ENV
 | 
				
			||||||
        echo "CXX=clang++" >> $GITHUB_ENV
 | 
					        echo "CXX=clang++" >> $GITHUB_ENV
 | 
				
			||||||
    - name: Add ccache to PATH
 | 
					    - name: Add ccache to PATH
 | 
				
			||||||
| 
						 | 
					@ -60,3 +64,13 @@ jobs:
 | 
				
			||||||
      run: make pythoninfo
 | 
					      run: make pythoninfo
 | 
				
			||||||
    - name: Tests
 | 
					    - name: Tests
 | 
				
			||||||
      run: ./python -m test --tsan -j4
 | 
					      run: ./python -m test --tsan -j4
 | 
				
			||||||
 | 
					    - name: Display TSAN logs
 | 
				
			||||||
 | 
					      if: always()
 | 
				
			||||||
 | 
					      run: find ${GITHUB_WORKSPACE} -name 'tsan_log.*' | xargs head -n 1000
 | 
				
			||||||
 | 
					    - name: Archive TSAN logs
 | 
				
			||||||
 | 
					      if: always()
 | 
				
			||||||
 | 
					      uses: actions/upload-artifact@v4
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        name: ${{ inputs.tsan_logs_artifact_name }}
 | 
				
			||||||
 | 
					        path: tsan_log.*
 | 
				
			||||||
 | 
					        if-no-files-found: ignore
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,3 +2,6 @@
 | 
				
			||||||
# reference: https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions
 | 
					# reference: https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions
 | 
				
			||||||
race:get_allocator_unlocked
 | 
					race:get_allocator_unlocked
 | 
				
			||||||
race:set_allocator_unlocked
 | 
					race:set_allocator_unlocked
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# https://gist.github.com/mpage/daaf32b39180c1989572957b943eb665
 | 
				
			||||||
 | 
					thread:pthread_create
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue