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

space after numbers on windows #204

Closed
rulerofthehuns opened this issue Mar 31, 2021 · 0 comments
Closed

space after numbers on windows #204

rulerofthehuns opened this issue Mar 31, 2021 · 0 comments

Comments

@rulerofthehuns
Copy link
Contributor

Hi,

There are 3 spaces after every number in the stacktrace output on windows:

D:\dev\projects\backtracetest\build-win\bin>main 0
------------------------
Stack trace (most recent call last):
#9          Object "", at 0   0   0   0   7   F   F   8   6   D   A   2   7   0   3   4   , in BaseThreadInitThunk
#8          Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp", line 1   7   , in mainCRTStartup
#7          Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 3   3   1   , in __scrt_common_main
#6          Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 2   8   8   , in __scrt_common_main_seh
#5          Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 7   9   , in invoke_main
#4          Source "D:\dev\projects\backtracetest\main.cpp", line 1   7   2   , in main
           1   6   9   :     // testfunc();
           1   7   0   :
           1   7   1   :     helper(argc, argv);
      >    1   7   2   :     return 0;
           1   7   3   : }
#3          Source "D:\dev\projects\backtracetest\main.cpp", line 6   5   , in helper
               6   2   :         {
               6   3   :             case str2int("0"):
               6   4   :                 print_backtrace();
      >        6   5   :                 break;
               6   6   :             case str2int("1"):
               6   7   :                 lib1_pst();
               6   8   :                 break;
#2          Source "D:\dev\projects\backtracetest\pst.h", line 1   1   0   , in print_backtrace
           1   0   8   :     // throw new int();
           1   0   9   :     // *(int *)0 = 42;
      >    1   1   0   : }
           1   1   1   :
           1   1   2   :
           1   1   3   : static void crash()
#1          Source "D:\dev\projects\backtracetest\pst.h", line 6   5   , in do_print_backtrace
               6   3   :     StackTrace st;
               6   4   :     st.load_here(32);
      >        6   5   :     Printer p;
               6   6   :     //p.color_mode = ColorMode::never;
               6   7   :
               6   8   :     p.print(st);
#0          Source "D:\dev\projects\backtracetest\backward.hpp", line 1   1   3   0   , in backward::StackTraceImpl<backward::system_tag::windows_tag>::load_here
       1   1   2   7   :       RtlCaptureContext(ctx_);
       1   1   2   8   :     }
       1   1   2   9   :
      >1   1   3   0   :     if (!thd_) {
       1   1   3   1   :       thd_ = GetCurrentThread();
       1   1   3   2   :     }

But the same executable works as expected while debugging from vscode or if I pipe the stdout to a file ( note: the stacktrace goes to stderr, not stdout ):

D:\dev\projects\backtracetest\build-win\bin>main 0 > out.txt
Stack trace (most recent call last):
#9    Object "", at 00007FF86DA27034, in BaseThreadInitThunk
#8    Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp", line 17, in mainCRTStartup
#7    Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 331, in __scrt_common_main
#6    Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 288, in __scrt_common_main_seh
#5    Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 79, in invoke_main
#4    Source "D:\dev\projects\backtracetest\main.cpp", line 172, in main
        169:     // testfunc();
        170:
        171:     helper(argc, argv);
      > 172:     return 0;
        173: }
#3    Source "D:\dev\projects\backtracetest\main.cpp", line 65, in helper
         62:         {
         63:             case str2int("0"):
         64:                 print_backtrace();
      >  65:                 break;
         66:             case str2int("1"):
         67:                 lib1_pst();
         68:                 break;
#2    Source "D:\dev\projects\backtracetest\pst.h", line 110, in print_backtrace
        108:     // throw new int();
        109:     // *(int *)0 = 42;
      > 110: }
        111:
        112:
        113: static void crash()
#1    Source "D:\dev\projects\backtracetest\pst.h", line 65, in do_print_backtrace
         63:     StackTrace st;
         64:     st.load_here(32);
      >  65:     Printer p;
         66:     //p.color_mode = ColorMode::never;
         67:
         68:     p.print(st);
#0    Source "D:\dev\projects\backtracetest\backward.hpp", line 1130, in backward::StackTraceImpl<backward::system_tag::windows_tag>::load_here
       1127:       RtlCaptureContext(ctx_);
       1128:     }
       1129:
      >1130:     if (!thd_) {
       1131:       thd_ = GetCurrentThread();
       1132:     }

The same code on works fine on WSL Ubuntu.
I'm using Visual Studio 2019 community edition, 19.25.28614.0

rulerofthehuns added a commit to rulerofthehuns/backward-cpp that referenced this issue Mar 31, 2021
rulerofthehuns added a commit to rulerofthehuns/backward-cpp that referenced this issue Mar 31, 2021
bombela added a commit that referenced this issue Mar 31, 2021
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

1 participant