indigo-dc / oidc-agent

oidc-agent for managing OpenID Connect tokens on the command line
MIT License
110 stars 30 forks source link

oidc-agent crash due to STATUS_ACCESS_VIOLATION #550

Closed XMol closed 10 months ago

XMol commented 10 months ago

Hello @marcvs,

you outed yourself as "responsible for Windows" in #521, so maybe you can help me with oidc-agent crashing on Windows with STATUS_ACCESS_VIOLATION exception?

I'm using oidc-agent v5.0.1, installed from repo.data.kit.edu on Windows 10 Enterprise N 22H2 with current updates.

PS U:\> oidc-agent.exe --version
oidc-agent 5.0.1

When trying to start oidc-agent without any customization, it fails with "Could not make temp socket directory" error, I assume because it constructed an illegal TEMP file path.

PS U:\> oidc-agent.exe
Error: Could not make temp socket directory

PS U:\> type .\oidc-agent.log
2023-11-02 16:20:07 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory
2023-11-02 16:21:08 oidc-agent.p DEBUG: (src/ipc/serveripc.c:200) initializing server ipc
2023-11-02 16:21:08 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\xavier/Users/xavier/AppData/Local/Temp
2023-11-02 16:21:08 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory
2023-11-02 16:32:44 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory

With an explicit socket-path though the above stackdump is generated.

PS U:\> oidc-agent.exe --debug --socket-path=oidc-agent.socket
      0 [main] oidc-agent 899 cygwin_exception::open_stackdumpfile: Dumping stack trace to oidc-agent.exe.stackdump

Since there is barely any documentation regarding Windows, can you tell me whether I did something wrong?

Best regards, Xavier.

zachmann commented 10 months ago

Hi Xavier,

Hello @marcvs,

you outed yourself as "responsible for Windows" in #521

that's only partly the case

When trying to start oidc-agent without any customization, it fails with "Could not make temp socket directory" error, I assume because it constructed an illegal TEMP file path.

2023-11-02 16:21:08 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\xavier/Users/xavier/AppData/Local/Temp

Indeed, it looks like it constructs a wrong path. I'll look into it.

zachmann commented 10 months ago

I did something that hopefully fixes the issue. (The path things with windows and msys is all a bit weird, so "hopefully" is the best we currently have).

Could you please try to use the binaries at https://git.scc.kit.edu/m-team/oidc-agent/-/jobs/1129259/artifacts/browse/bin/ and report back the result.

XMol commented 10 months ago

Could you please try to use the binaries at https://git.scc.kit.edu/m-team/oidc-agent/-/jobs/1129259/artifacts/browse/bin/ and report back the result.

Shall I just dump them into the install dir of oidc-agent, replacing the existing binaries?

zachmann commented 10 months ago

Yes

XMol commented 10 months ago

Something is still going wrong...

PS U:\> oidc-agent.exe --debug
Error: Could not make temp socket directory

Yet, oidc-agent.log was written to a different directory now:

PS U:\> type C:\Users\xavier\AppData\Local\oidc-agent\oidc-agent\oidc-agent.log
2023-11-06 10:26:19 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory
2023-11-06 10:26:42 oidc-agent.p DEBUG: (src/ipc/serveripc.c:200) initializing server ipc
2023-11-06 10:26:42 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\xavier/Users/xavier/AppData/Local/Temp
2023-11-06 10:26:42 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory
2023-11-06 10:28:57 oidc-agent.p DEBUG: (src/ipc/serveripc.c:200) initializing server ipc
zachmann commented 10 months ago

New link: https://git.scc.kit.edu/m-team/oidc-agent/-/jobs/1129346/artifacts/browse/bin/

I actually forgot to use my newly implemented function, so it could not work before; I also added some debug logging.

XMol commented 10 months ago

Again same outcome

2023-11-06 12:51:25 oidc-agent.p DEBUG: (src/ipc/serveripc.c:200) initializing server ipc
2023-11-06 12:51:25 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\xavier/Users/xavier/AppData/Local/Temp
2023-11-06 12:51:25 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory
zachmann commented 10 months ago

mmh, are you sure the correct binary is used?

There should be at least some additional debug message, similar to:

2023-11-06 13:10:11 oidc-agent.p DEBUG: (src/ipc/serveripc.c:200) initializing server ipc
2023-11-06 13:10:11 oidc-agent.p DEBUG: (src/utils/tempenv.c:83) We are in a windows non-msys terminal and determine the tmp dir
2023-11-06 13:10:11 oidc-agent.p DEBUG: (src/utils/tempenv.c:91) $TEMP is '/AppData/Local/Temp/393'
2023-11-06 13:10:11 oidc-agent.p DEBUG: (src/utils/tempenv.c:110) $USERPROFILE is 'C:\Users\ib9131'
2023-11-06 13:10:11 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\ib9131/AppData/Local/Temp/393
XMol commented 10 months ago

No, I'm not, but I don't know how to make sure of that either. I again...

  1. Downloaded the entire artifacts archive from the last link you posted (pipeline #323354, job #1129346)
  2. Extracted the entire content into the installation directory of oidc-agent ⇒ I was asked for permission to replace 34 files
  3. Ran oidc-agent in a new PowerShell session with fully qualified path to oidc-agent.exe

I have not rebooted and the outcome stays the same once more.

2023-11-06 14:08:26 oidc-agent.p DEBUG: (src/ipc/serveripc.c:200) initializing server ipc
2023-11-06 14:08:26 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\uv7044/Users/uv7044/AppData/Local/Temp
2023-11-06 14:08:26 oidc-agent.p ALERT: (src/ipc/serveripc.c:64) No such file or directory
XMol commented 10 months ago

This is the MD5SUM of my binary

PS U:\> Get-FileHash 'C:\Program Files\oidc-agent\oidc-agent.exe' -Algorithm MD5

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
MD5             FBA28FF27A536AA17BC92B3BC4DF3A03                                       C:\Program Files\oidc-agent\oidc-agent.exe
zachmann commented 10 months ago

Yes that's still the old version - the md5 from the above link is 26361ADEF09927840096BA898FB17A56.

Seems like the binary was not replaced.

XMol commented 10 months ago

Ah, the artifacts archive has the binaries in a bin subfolder, whereas the binaries installer by the Windows installer are in the top level installation directory. So I moved all of them and now the behavior is different.

PS U:\> 'C:\Program Files\oidc-agent\oidc-agent.exe'
C:\Program Files\oidc-agent\oidc-agent.exe

Cannot use any of the command line options --debug, -debug, -d, --status or --help since those trigger an "unexpected token" error. So I continued with wlcg-gen.exe, but didn't get far... Turns out, running the command with fully qualified path now breaks them, so I have to rely on the environment.

PS U:\> oidc-agent.exe --debug
OIDC_SOCK=C:\Users\uv7044/AppData/Local/Temp/oidc-1BY37y/oidc-agent.1
OIDCD_PID=862

PS U:\> oidc-agent.exe --status
####################################
##       oidc-agent status        ##
####################################

This agent is running version 5.0.2.

This agent was started with the following options:
Lifetime:               Forever
Confirm:                false
Autoload:               true
Auto Re-authenticate:   true
Use custom URI scheme:  true
Webserver:              true
Allow ID-Token:         false
Group:                  false
Daemon:                 true
Log Debug:              true
Log to stderr:          false

Currently there are 0 accounts loaded:
2023-11-06 15:54:48 oidc-agent.p DEBUG: (src/utils/tempenv.c:83) We are in a windows non-msys terminal and determine the tmp dir
2023-11-06 15:54:48 oidc-agent.p DEBUG: (src/utils/tempenv.c:91) $TEMP is '/Users/xavier/AppData/Local/Temp'
2023-11-06 15:54:48 oidc-agent.p DEBUG: (src/utils/tempenv.c:110) $USERPROFILE is 'C:\Users\xavier'
2023-11-06 15:54:48 oidc-agent.p DEBUG: (src/ipc/serveripc.c:46) Using tmp dir: C:\Users\xavier/AppData/Local/Temp
2023-11-06 15:54:48 oidc-agent.p DEBUG: (src/ipc/serveripc.c:248) binding ipc

2023-11-06 15:54:48 oidc-agent.p DEBUG: (src/ipc/serveripc.c:269) listen ipc

Thanks @zachmann, it seems my issue has been resolved. 👍

zachmann commented 10 months ago

I fixed our ci pipeline, so there is now also an installer for the fixed version available at:

https://repo.data.kit.edu/devel/windows/oidc-agent/

XMol commented 10 months ago

FYI, I was able to obtain an access-token now just fine. Hence, this issue may be closed, unless you'd like to resolve it in tandem with a commit/pull-request/release.