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

Locale / language should be unset when running `gcov` #166

Open
devurandom opened this issue Apr 1, 2017 · 5 comments

Comments

@devurandom
Copy link

@devurandom devurandom commented Apr 1, 2017

On my system LANG is set to de_DE.UTF-8 and LANGUAGE to en_GB:en_US:de. Apparently gcov does not come with a translation for en_GB nor en_US, so the German locale is being used, which results in this output:

# gcov .../src/lualdap.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory .../src
File: »src/lualdap.c«                                                                                                                                                                                                                                                                                                                                                      
76.35% von 427 Zeilen ausgeführt                            
81.60% von 163 Zweigen ausgeführt                           
56.44% von 163 Zweigen mindestens einmal genommen                                                                                                                                                                                                                                                                                                                          
70.38% von 314 Aufruf(en) ausgeführt                 
»src#lualdap.c.gcov« wird erzeugt                  
                                                                      
File: »/usr/include/bits/string3.h«                                                                                                                                                                                                     
66.67% von 3 Zeilen ausgeführt                                      
Keine Zweige                                       
Keine Aufrufe                            
»#usr#include#bits#string3.h.gcov« wird erzeugt                   
                                                                    
File: »/usr/include/bits/stdio2.h«                 
0.00% von 1 Zeilen ausgeführt                                                 
Keine Zweige                                                                     
Keine Aufrufe                                                                                                                                                                                                                                                                                                                                                               »#usr#include#bits#stdio2.h.gcov« wird erzeugt                                                                                                      

Please note the fancy quote symbols. When I unset LANGUAGE, the output is as follows:

# gcov .../src/lualdap.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory .../src
File 'src/lualdap.c'                                           
Lines executed:76.35% of 427                                                  
Branches executed:81.60% of 163                                                                                                                                                                                                                                                                                                                                            
Taken at least once:56.44% of 163                             
Calls executed:70.38% of 314                             
Creating 'src#lualdap.c.gcov'                                
                                                                  
File '/usr/include/bits/string3.h'                                             
Lines executed:66.67% of 3                                          
No branches                                                  
No calls                                                            
Creating '#usr#include#bits#string3.h.gcov'                        
                                                             
File '/usr/include/bits/stdio2.h'                              
Lines executed:0.00% of 1                                                                                                                                                                                                                                                                                                                                                  
No branches                                                
No calls                                                     
Creating '#usr#include#bits#stdio2.h.gcov'                   

gcovr parsing the former output results in following error:

# gcovr --html-details --root=. --verbose
Scanning directory . for gcda/gcno files...                    
Found 2 files (and will process 1)                               
Processing file: .../src/lualdap.gcda           
Running gcov: 'gcov .../src/lualdap.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory .../src' in '...'                                                                                                                                    
Traceback (most recent call last):                                                                                                                  
  File "/usr/lib/python-exec/python3.5/gcovr", line 2312, in <module>                                                                                                                                                                                                                                                                                                      
    process_datafile(file_, covdata, options)          
  File "/usr/lib/python-exec/python3.5/gcovr", line 853, in process_datafile                                                                                                                                                                                                                                                                                               
    out = out.decode('utf-8')                                                                                                                                                                                                                                                                                                                                              
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 6: invalid start byte

You probably want to unset LANGUAGE, LANG and LC_* when calling gcov, to prevent such issues.

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Jan 7, 2018

When gcovr runs gcov, it sets the environment variable LC_ALL=en_US. I am therefore unable to reproduce your problem when running only gcovr.

When you run gcov yourself and feed those files to gcovr, it is your responsibility to generate usable output. Gcovr is completely unable to influence how you run the gcov program.

The only way this could be fixed would be if gcovr were able to parse non-English gcov output, but that doesn't look like a very useful feature.

If this problem persists, please also provide:

  • your gcov version
  • your gcovr version
  • the shortest C or C++ program to reproduce the error, ideally just int main() { return 0; }.
@latk latk closed this Jan 7, 2018
@ThomasBrixLarsen

This comment has been minimized.

Copy link

@ThomasBrixLarsen ThomasBrixLarsen commented Jan 21, 2019

On my system gcovr only works if I change 'LC_ALL=en_US' in /usr/lib/python3.7/site-packages/gcovr/gcov.py to LC_ALL='C'.

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Jan 21, 2019

@ThomasBrixLarsen Out of curiosity, what system?

But yes that looks like a bug in gcovr. The canonical way to disable localization is not to set LC_ALL=en_US but LC_ALL=C. Can you check whether that would fix the problem as well?

@ThomasBrixLarsen

This comment has been minimized.

Copy link

@ThomasBrixLarsen ThomasBrixLarsen commented Jan 21, 2019

Arch Linux. Yes LC_ALL=C fixes the issue.

@robinmoussu

This comment has been minimized.

Copy link

@robinmoussu robinmoussu commented Jan 21, 2019

Hello, I think I have a similar issue. I opened a separate bug (#292).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.