ZNC 1.6.5 crashes when unloading modules via the web interface [CygWin] [SOLVED] #758

Closed
opened 2026-10-05 04:43:00 +02:00 by adam · 6 comments
Owner

OS: Windows Server 2012 R2
ZNC version: ZNC 1.6.5+cygwin1 - http://znc.in
IPv6: yes, SSL: yes, DNS: threads, charset: yes
CygWin version: CYGWIN_NT-6.3 Server 2.7.0(0.306/5/3) 2017-02-12 13:18 x86_64 Cygwin

Issue:
When running ZNC normally it instantly crashes whenever you try to unload a module via the WebAdmin interface and save the changes, in this case buffextras on a network (the module is also activated under the user). However, when running ZNC with the foreground or debug flag (which implies foreground) it seems to run without any issues. So I can't get a log with ZNC debug enabled. This also happened on version 1.6.4. No knowledge about previous versions.

Another strange thing is that sometimes after a crash when starting the bouncer up again, it will add the line Key = . under only one network for only one user on all the channels without keys in that network (the sole admin account) and change one channel with a password to Key = * (the same channel every time) leaving the other channels in that network with keys alone. That's also the only network under that user that has any channels with keys. It does this with a clean config file. Meaning that the config file doesn't contain this extra and changed information prior to starting the bouncer after a crash. All other users are unaffected, so perhaps this is something the IRC client is messing up. Thought I'd mention it non the less.

The Issue is probably related to:
https://github.com/znc/znc/issues/1258
https://github.com/znc/znc/issues/1265

ZNC GDB Log: (added .txt since GitHub won't allow log files to be uploaded)
znc.gdb.log.txt
(A znc.exe.stackdump also exists. If that's needed I'll upload that too).

Edit:
I thought maybe CryptoPrevent could have had something to do with it (Default level). But after disabling it and restarting the server ZNC still crashes. Disabling CryptoPrevent should revert all changes it does (unless something went wrong). Other than CP there's no other application that should interfere with ZNC or CygWin on the server as far as I know.

**OS:** Windows Server 2012 R2 **ZNC version:** ZNC 1.6.5+cygwin1 - http://znc.in IPv6: yes, SSL: yes, DNS: threads, charset: yes **CygWin version:** CYGWIN_NT-6.3 Server 2.7.0(0.306/5/3) 2017-02-12 13:18 x86_64 Cygwin **Issue:** When running ZNC normally it instantly crashes whenever you try to unload a module via the WebAdmin interface and save the changes, in this case buffextras on a network (the module is also activated under the user). However, when running ZNC with the foreground or debug flag (which implies foreground) it seems to run without any issues. So I can't get a log with ZNC debug enabled. This also happened on version 1.6.4. No knowledge about previous versions. Another strange thing is that sometimes after a crash when starting the bouncer up again, it will add the line _**Key = .**_ under only one network for only one user on all the channels **without** keys in that network (the sole admin account) and change one channel with a password to **_Key = *_** (the same channel every time) leaving the other channels in that network with keys alone. That's also the only network under that user that has any channels with keys. It does this with a clean config file. Meaning that the config file doesn't contain this extra and changed information prior to starting the bouncer after a crash. All other users are unaffected, so perhaps this is something the IRC client is messing up. Thought I'd mention it non the less. **The Issue is probably related to:** https://github.com/znc/znc/issues/1258 https://github.com/znc/znc/issues/1265 **ZNC GDB Log:** (added .txt since GitHub won't allow log files to be uploaded) [znc.gdb.log.txt](https://github.com/znc/znc/files/846341/znc.gdb.log.txt) (A znc.exe.stackdump also exists. If that's needed I'll upload that too). **Edit:** I thought maybe [CryptoPrevent](https://www.foolishit.com/cryptoprevent-malware-prevention/) could have had something to do with it (Default level). But after disabling it and restarting the server ZNC still crashes. Disabling CryptoPrevent _should_ revert all changes it does (unless something went wrong). Other than CP there's no other application that should interfere with ZNC or CygWin on the server as far as I know. <!-- github-sync-id:214566673 -->
adam closed this issue 2026-10-05 04:43:00 +02:00
Author
Owner

The following modules are loaded:

Global:
adminlog
blockuser
fail2ban
identfile
lastseen
webadmin

User:
autoattach
buffextras
chansaver
clientnotify
controlpanel
ctcpflood 4 2
disconnectkick

Network:
autoattach
buffextras
chansaver
keepnick
kickrejoin
route_replies
savebuff
simple_away

I have moved the following module files to cygwin64\lib\znc\disabled:
autoop.so
autovoice.so
awaynick.so
bouncerdcc.so
dcc.so
listsockets.so
log.so
missingmotd.so
modules_online.se
notes.so
raw.so
sample.so
send_raw.so
shell.so

**The following modules are loaded:** **Global:** adminlog blockuser fail2ban identfile lastseen webadmin **User:** autoattach buffextras chansaver clientnotify controlpanel ctcpflood _4 2_ disconnectkick **Network:** autoattach buffextras chansaver keepnick kickrejoin route_replies savebuff simple_away **I have moved the following module files to cygwin64\lib\znc\disabled:** autoop.so autovoice.so awaynick.so bouncerdcc.so dcc.so listsockets.so log.so missingmotd.so modules_online.se notes.so raw.so sample.so send_raw.so shell.so <!-- github-comment-id:287208425 -->
Author
Owner

Config File with crash:

AnonIPLimit = 10
ConnectDelay = 5
HideVersion = true
LoadModule = webadmin
LoadModule = blockuser
LoadModule = fail2ban
LoadModule = identfile
LoadModule = lastseen
LoadModule = adminlog
MaxBufferSize = 1000
ProtectWebSessions = true
SSLCertFile = Secret Path
ServerThrottle = 30
Skin = dark-clouds
StatusPrefix = *
Version = 1.6.5

<Listener listener0>
	AllowIRC = true
	AllowWeb = true
	IPv4 = true
	IPv6 = false
	Port = Secret
	SSL = true
	URIPrefix = /
</Listener>

<User Secret>
	Admin = true
	Allow = *
	AltNick = Secret_
	AppendTimestamp = false
	AutoClearChanBuffer = true
	AutoClearQueryBuffer = true
	Buffer = 500
	ChanModes = +stn
	ClientEncoding = ^ISO-8859-15
	DenyLoadMod = false
	DenySetBindHost = true
	Ident = Secret
	JoinTries = 10
	LoadModule = autoattach
	LoadModule = buffextras
	LoadModule = chansaver
	LoadModule = controlpanel
	LoadModule = ctcpflood 4 2
	LoadModule = disconkick
	LoadModule = clientnotify
	MaxJoins = 5
	MaxNetworks = 5
	MaxQueryBuffers = 50
	MultiClients = true
	Nick = Secret
	PrependTimestamp = true
	QuitMsg = Quit Message
	RealName = Secret
	TimestampFormat = [%a-%H:%M:%S]
	Timezone = Europe/Stockholm

	<Network Quakenet>
		Encoding = ^ISO-8859-15
		FloodBurst = 4
		FloodRate = 1.00
		IRCConnectEnabled = false
		JoinDelay = 0
		LoadModule = autoattach
		LoadModule = buffextras
		LoadModule = chansaver
		LoadModule = keepnick
		LoadModule = kickrejoin
		LoadModule = route_replies
		LoadModule = savebuff
		LoadModule = simple_away
		Server = se.quakenet.org 6667
		Server = dreamhack.se.quakenet.org 6667
	</Network>

	<Pass password>
		Hash = Very Secret
		Method = SHA256
		Salt = Pepper
	</Pass>
</User>

If I remove LoadModule = buffextras from the Quakenet network in the config file above the bouncer seems to be working. I can enable and disable buffextras from the web-interface without any issues. But if I leave it on and restart the bouncer it will start crashing again whenever I try to unload the module from the Web-interface and saving.

Further testing reveals the following; you can't have the buffextras module activated under both the user and a network. Doing so makes ZNC crash whenever you try to unload the module either from the user or the network, unless you are running ZNC with the --foreground or --debug flag. (However, that will annoyingly result in you getting messages from buffextras twice, which isn't desired anyway. See https://github.com/znc/znc/issues/1078).

**Config File with crash:** ``` AnonIPLimit = 10 ConnectDelay = 5 HideVersion = true LoadModule = webadmin LoadModule = blockuser LoadModule = fail2ban LoadModule = identfile LoadModule = lastseen LoadModule = adminlog MaxBufferSize = 1000 ProtectWebSessions = true SSLCertFile = Secret Path ServerThrottle = 30 Skin = dark-clouds StatusPrefix = * Version = 1.6.5 <Listener listener0> AllowIRC = true AllowWeb = true IPv4 = true IPv6 = false Port = Secret SSL = true URIPrefix = / </Listener> <User Secret> Admin = true Allow = * AltNick = Secret_ AppendTimestamp = false AutoClearChanBuffer = true AutoClearQueryBuffer = true Buffer = 500 ChanModes = +stn ClientEncoding = ^ISO-8859-15 DenyLoadMod = false DenySetBindHost = true Ident = Secret JoinTries = 10 LoadModule = autoattach LoadModule = buffextras LoadModule = chansaver LoadModule = controlpanel LoadModule = ctcpflood 4 2 LoadModule = disconkick LoadModule = clientnotify MaxJoins = 5 MaxNetworks = 5 MaxQueryBuffers = 50 MultiClients = true Nick = Secret PrependTimestamp = true QuitMsg = Quit Message RealName = Secret TimestampFormat = [%a-%H:%M:%S] Timezone = Europe/Stockholm <Network Quakenet> Encoding = ^ISO-8859-15 FloodBurst = 4 FloodRate = 1.00 IRCConnectEnabled = false JoinDelay = 0 LoadModule = autoattach LoadModule = buffextras LoadModule = chansaver LoadModule = keepnick LoadModule = kickrejoin LoadModule = route_replies LoadModule = savebuff LoadModule = simple_away Server = se.quakenet.org 6667 Server = dreamhack.se.quakenet.org 6667 </Network> <Pass password> Hash = Very Secret Method = SHA256 Salt = Pepper </Pass> </User> ``` If I remove _LoadModule = buffextras_ from the Quakenet network in the config file above the bouncer seems to be working. I can enable and disable buffextras from the web-interface without any issues. But if I leave it on and restart the bouncer it will start crashing again whenever I try to unload the module from the Web-interface and saving. Further testing reveals the following; you can't have the buffextras module activated under both the user and a network. Doing so makes ZNC crash whenever you try to unload the module either from the user or the network, unless you are running ZNC with the --foreground or --debug flag. (However, that will annoyingly result in you getting messages from buffextras twice, which isn't desired anyway. See https://github.com/znc/znc/issues/1078). <!-- github-comment-id:287937419 -->
Author
Owner

I reproduced it with your config on both win2012 and win10.
This is because of how cygwin implements fork().
Here is the minimal example:

// shared.cpp
extern "C" {
int f();
int f() {
        return 30;
}
}
// main.cpp
#include <dlfcn.h>
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
int main() {
        void* x = dlopen("shared.so", 0);
        assert(x);
        void* y = dlopen("shared.so", 0);
        assert(y);
        int (*f)() = NULL;
        *reinterpret_cast<void**>(&f) = dlsym(y, "f");
        assert(f);
        if (int pid = fork()) {
                printf("%d\n", pid);
                return 0;
        }
        // now quickly run: gdb -p <number from above>
        sleep(10);
        dlclose(x);
        int z = f();  // boom!
        dlclose(y);
        return z;
}
gcc -shared shared.cpp -o shared.so
gcc main.cpp
./a.exe
gdb -p ...
I reproduced it with your config on both win2012 and win10. This is because of how cygwin implements `fork()`. Here is the minimal example: ```c++ // shared.cpp extern "C" { int f(); int f() { return 30; } } ``` ```c++ // main.cpp #include <dlfcn.h> #include <assert.h> #include <unistd.h> #include <stdio.h> int main() { void* x = dlopen("shared.so", 0); assert(x); void* y = dlopen("shared.so", 0); assert(y); int (*f)() = NULL; *reinterpret_cast<void**>(&f) = dlsym(y, "f"); assert(f); if (int pid = fork()) { printf("%d\n", pid); return 0; } // now quickly run: gdb -p <number from above> sleep(10); dlclose(x); int z = f(); // boom! dlclose(y); return z; } ``` ``` gcc -shared shared.cpp -o shared.so gcc main.cpp ./a.exe gdb -p ... ``` <!-- github-comment-id:288014319 -->
Author
Owner
https://cygwin.com/ml/cygwin/2017-03/msg00220.html <!-- github-comment-id:288018569 -->
Author
Owner
https://cygwin.com/ml/cygwin/2017-03/msg00221.html https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=33297d810d9033ffca661b8f9158116602615dd7;hp=33c7b2b544a96ee443728f9558ce07a13e05f1e8 <!-- github-comment-id:288097948 -->
Author
Owner

Thanks for all the help and the quick response =)

I have tested the latest CygWin snapshot (2017-03-21 13:38:00 UTC) and it seems to be working as it should. No crashes thus far when I replicate the circumstances from before.

CYGWIN_NT-6.3 Server 2.8.0(0.308/5/3) x86_64 Cygwin

Thanks for all the help and the quick response =) I have tested the latest CygWin snapshot (2017-03-21 13:38:00 UTC) and it seems to be working as it should. No crashes thus far when I replicate the circumstances from before. > CYGWIN_NT-6.3 Server 2.8.0(0.308/5/3) x86_64 Cygwin <!-- github-comment-id:288149360 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#758