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

4.1.9.3 autostart issue #2841

Closed
vanyaindigo opened this issue Apr 1, 2020 · 37 comments
Closed

4.1.9.3 autostart issue #2841

vanyaindigo opened this issue Apr 1, 2020 · 37 comments
Labels

Comments

@vanyaindigo
Copy link

The app doesn't start with the system while autostart is switch on.

@chenshaoju
Copy link
Collaborator

Please check registry \HKCU\Software\Microsoft\Windows\CurrentVersion\Run,There is a Shadowsocks_xxxxxxxx entry?

@vanyaindigo
Copy link
Author

Yes, there is such entry

@chenshaoju
Copy link
Collaborator

chenshaoju commented Apr 2, 2020

I tested on my Windows 10 1909 (18363.720), But it can't be repeated. It can repeated.

It's your computer install some computer manager software, Like 360 Security Center or Tencent PC Manager?

@vanyaindigo
Copy link
Author

Nothing installed and with ver. 4.1.9.2 all was fine.

@chenshaoju
Copy link
Collaborator

chenshaoju commented Apr 2, 2020

Odd, Please quit Shadowsocks, Open registry and delete Shadowsocks_xxxxxx from \HKCU\Software\Microsoft\Windows\CurrentVersion\Run, And start Shadowsocks again to set auto-start ?

@vanyaindigo
Copy link
Author

vanyaindigo commented Apr 2, 2020

Still not starting, works only manual start

@chenshaoju
Copy link
Collaborator

chenshaoju commented Apr 2, 2020

This should not happen.

If you manually create an entry name something else like test with your Shadowsocks path, It's can work?

example:
image

@vanyaindigo
Copy link
Author

I think this is somehow refer with new localization

@chenshaoju
Copy link
Collaborator

What is your operating system language or location settings?

@vanyaindigo
Copy link
Author

vanyaindigo commented Apr 2, 2020

Russian, is it possible to switch back to english?

@ghost
Copy link

ghost commented Apr 2, 2020

Russian, is it possible to switch back to english?

Help-> Write translate template, then delete Russian column in generated file.

@ghost
Copy link

ghost commented Apr 2, 2020

Is there anything in logfile?

@vanyaindigo
Copy link
Author

Is there anything in logfile?

Nothing

@celeron533 celeron533 added the bug label Apr 2, 2020
@celeron533
Copy link
Contributor

tag as bug for tracking.
It is possible that this new binary release is not trusted by the anti-virus and does not allowed to be added in startup?

@vanyaindigo
Copy link
Author

There is an error in system log:

Контейнер ошибки , тип 0
Имя события: CLR20r3
Отклик: Нет данных
Идентификатор CAB: 0

Сигнатура проблемы:
P1: Shadowsocks.exe
P2: 4.1.9.3
P3: 5e835a75
P4: mscorlib
P5: 4.8.4150.0
P6: 5e176d21
P7: 1693
P8: 12e
P9: System.UnauthorizedAccess
P10: 

@vanyaindigo
Copy link
Author

vanyaindigo commented Apr 2, 2020

And another:

Приложение: Shadowsocks.exe
Версия платформы: v4.0.30319
Описание. Процесс был завершен из-за необработанного исключения. (The process was completed due to an unhandled exception.)
Сведения об исключении: System.UnauthorizedAccessException
   в System.IO.__Error.WinIOError(Int32, System.String)
   в System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
   в System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean)
   в System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean)
   в System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean)
   в System.IO.File.InternalWriteAllText(System.String, System.String, System.Text.Encoding, Boolean)
   в System.IO.File.WriteAllText(System.String, System.String)
   в Shadowsocks.Model.NLogConfig.TouchAndApplyNLogConfig()
   в Shadowsocks.Program.Main(System.String[])

Имя сбойного приложения: Shadowsocks.exe, версия: 4.1.9.3, метка времени: 0x5e835a75
Имя сбойного модуля: KERNELBASE.dll, версия: 10.0.18362.719, метка времени: 0x4061c730
Код исключения: 0xe0434352
Смещение ошибки: 0x00114192
Идентификатор сбойного процесса: 0x1280
Время запуска сбойного приложения: 0x01d608cae86c08b2
Путь сбойного приложения: E:\Downloads\Shadowsocks\Shadowsocks.exe
Путь сбойного модуля: C:\WINDOWS\System32\KERNELBASE.dll
Идентификатор отчета: 19675f09-69a5-4833-b542-d9cafa01c016
Полное имя сбойного пакета: 
Код приложения, связанного со сбойным пакетом: 

@ghost
Copy link

ghost commented Apr 2, 2020

I think problem is in NLog

@snakefoot
Copy link
Contributor

snakefoot commented Apr 2, 2020

The exception comes from your own code:

public static void TouchAndApplyNLogConfig()
{
if (!File.Exists(NLOG_CONFIG_FILE_NAME))
{
File.WriteAllText(NLOG_CONFIG_FILE_NAME, Properties.Resources.NLog_config);
LogManager.LoadConfiguration(NLOG_CONFIG_FILE_NAME);
}
}

Maybe add some exception handling like this:

 public static void TouchAndApplyNLogConfig() 
 { 
     try
     {
         if (File.Exists(NLOG_CONFIG_FILE_NAME))
             return;   // NLog.config exists, and has already been loaded

         File.WriteAllText(NLOG_CONFIG_FILE_NAME, Properties.Resources.NLog_config);
     }
     catch (Exception ex)
     {
         NLog.Common.InternalLogger.Error(ex, "[shadowsocks] Failed to setup default NLog.config: {0}", NLOG_CONFIG_FILE_NAME)
         return;
     }

     LogManager.LoadConfiguration(NLOG_CONFIG_FILE_NAME); // Load the new config-file
 } 

@ningsibuqu
Copy link

我也有一样的问题,Windows 10 1809 x64

@funny-fury
Copy link

Hello,

OS 名称: Microsoft Windows 10 专业版 Insider Preview
OS 版本: 10.0.19592 暂缺 Build 19592
系统区域设置: zh-cn;中文(中国)

Have the same problem.

@billysingo
Copy link

same problem on windows10x64 1903

@chenshaoju
Copy link
Collaborator

Sorry for my fault, I'm using the wrong version.

The 4.1.9.3 have some issue, It's unable auto-start.

错误应用程序名称: Shadowsocks.exe,版本: 4.1.9.3,时间戳: 0x5e835a75
错误模块名称: KERNELBASE.dll,版本: 10.0.18362.719,时间戳: 0x4061c730
异常代码: 0xe0434352
错误偏移量: 0x00114192
错误进程 ID: 0x2a10
错误应用程序启动时间: 0x01d6097a24e57d83
错误应用程序路径: C:\Software\Shadowsocks\Shadowsocks.exe
错误模块路径: C:\Windows\System32\KERNELBASE.dll
报告 ID: b8fa373a-eca2-4f99-9bfc-fc6d25fc2ec2
错误程序包全名: 
错误程序包相对应用程序 ID: 
应用程序: Shadowsocks.exe
Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: System.UnauthorizedAccessException
   在 System.IO.__Error.WinIOError(Int32, System.String)
   在 System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
   在 System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean)
   在 System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean)
   在 System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean)
   在 System.IO.File.InternalWriteAllText(System.String, System.String, System.Text.Encoding, Boolean)
   在 System.IO.File.WriteAllText(System.String, System.String)
   在 Shadowsocks.Model.NLogConfig.TouchAndApplyNLogConfig()
   在 Shadowsocks.Program.Main(System.String[])
故障存储段 1613589829736366270,类型 5
事件名称: CLR20r3
响应: 不可用
Cab ID: 0

问题签名:
P1: Shadowsocks.exe
P2: 4.1.9.3
P3: 5e835a75
P4: mscorlib
P5: 4.8.4150.0
P6: 5e176d21
P7: 1693
P8: 12e
P9: System.UnauthorizedAccess
P10: 

@basten1899
Copy link

the same problem

@celeron533
Copy link
Contributor

Hi All,
Just need to confirm, manual start still works when auto start has problem?

@chenshaoju
Copy link
Collaborator

yes

@ghost
Copy link

ghost commented Apr 3, 2020

https://www.codeproject.com/Questions/262575/Start-on-windows-logon-results-in-System-Unauthori

Does your app open or create a file using relative path?
If so, the cause of the problem is a difference of current directory.

If you run the app yourself, the current directory is the directory where the app is located.

If you use either HKLM...\Run or HKCU...\Run the current directory is the root of your login account.

The solution: set a proper current directory before accessing any file or always use absolute path.

@ghost
Copy link

ghost commented Apr 3, 2020

move this line to the top of Main() may solve our problem

Directory.SetCurrentDirectory(Application.StartupPath);

celeron533 added a commit to celeron533/shadowsocks-windows that referenced this issue Apr 4, 2020
@ningsibuqu
Copy link

既然修复了,可以发个版本吗

@ningsibuqu
Copy link

@vanyaindigo
Copy link
Author

vanyaindigo commented Apr 6, 2020

After all is done check also verbose logging, there may too be issues.

@ghost
Copy link

ghost commented Apr 6, 2020

yes, verbose logging is too verbose in release config.

@celeron533
Copy link
Contributor

I'll adjust the "verbose" from Trace to Debug

config.nLogConfig.SetLogLevel(config.isVerboseLogging? NLogConfig.LogLevel.Trace: NLogConfig.LogLevel.Info);

Then prepare a new release with autostart code fix

@ghost
Copy link

ghost commented Apr 7, 2020

I'll adjust the "verbose" from Trace to Debug

config.nLogConfig.SetLogLevel(config.isVerboseLogging? NLogConfig.LogLevel.Trace: NLogConfig.LogLevel.Info);

Then prepare a new release with autostart code fix

Some log is at wrong level, like AEADEncryptor's internal state logging, they're at Debug level.

I suggest use this, in Debug config, log level is Trace, in Release it is Debug. Also adjusted some log's level.

0001-adjust-log-level.zip (My computer is broken, I'm working on public device, so I can't push at this moment...)

@celeron533
Copy link
Contributor

Hi @studentmain , your patch has been applied on 23ce58a .
LogForm.cs is not changed. I think it is useful for normal end-user

@ghost
Copy link

ghost commented Apr 8, 2020

@celeron533 got it

@vanyaindigo
Copy link
Author

All is working with 4.1.10.0. Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants