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

runtime error: applying zero offset to null pointer #1740

Open
gazer-star opened this issue Apr 5, 2024 · 3 comments
Open

runtime error: applying zero offset to null pointer #1740

gazer-star opened this issue Apr 5, 2024 · 3 comments
Labels
feedback Waiting for futher feedbacks invalid Investigation quiestion remains ambiguous

Comments

@gazer-star
Copy link

gazer-star commented Apr 5, 2024

Describe the bug
runtime error: applying zero offset to null pointer.

// ./nanomq/nng/src/core/list.c:
void *
nni_list_first(const nni_list *list)
{
	nni_list_node *node = list->ll_head.ln_next;

	if (node == &list->ll_head) {
		return (NULL);
	}
	return (ITEM(list, node)); // null pointer.
}

To Reproduce
Build with UBSan: -DCMAKE_CXX_FLAGS="-g -O1 -fsanitize=address,undefined"
Start two nanomq server with different tcp address but the same ws address. (remove the pid file in /tmp/nanomq/nanomq.pid)

server 1

./nanomq

server2

./nanomq tart --url nmq-tcp://0.0.0.0:4453

Server Logs as follow

Additional context

2024-04-05 21:58:36 [2627426] ERROR /home/user/nanomq/nng/src/supplemental/nanolib/conf_ver2.c:1202 conf_parse_ver2: Configure file [(null)] or [/etc/nanomq.conf] not found or unreadable
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1141 print_conf: This NanoMQ instance configured as:
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1144 print_conf: tcp url:                  nmq-tcp://0.0.0.0:4453 
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1148 print_conf: websocket url:            nmq-ws://0.0.0.0:8083/mqtt
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1166 print_conf: daemon:                   false
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1168 print_conf: num_taskq_thread:         32
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1170 print_conf: max_taskq_thread:         32
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1171 print_conf: parallel:                 32
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1172 print_conf: property_size:            32
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1173 print_conf: max_packet_size:          1048576
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1175 print_conf: client_max_packet_size:   1048576
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1176 print_conf: msq_len:                  2048
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1177 print_conf: qos_duration:             10
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1178 print_conf: keepalive_backoff:        1.500000
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1215 print_conf: allow_anonymous:          true
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1219 print_conf: acl_nomatch:              allow
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1221 print_conf: enable_acl_cache:         on
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1223 print_conf: acl_cache_max_size:       32
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1224 print_conf: acl_cache_ttl:            60
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nng/src/supplemental/nanolib/conf.c:1227 print_conf: acl_deny_action:          ignore
2024-04-05 21:58:36 [2627426] INFO  /home/user/nanomq/nanomq/apps/broker.c:1272 store_pid: 2627426
nng_listen ws: Address in use
/home/user/nanomq/nng/src/core/list.c:39:10: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/user/nanomq/nng/src/core/list.c:39:10 in 
@wanghaEMQ
Copy link
Member

Hi. Could you show the version number of commitid of nanomq you are using?

@wanghaEMQ
Copy link
Member

I can't reproduce this issue on my pc.

./nanomq/nanomq start
Config file is not specified, use default config file: /etc/nanomq.conf
2024-04-13 03:34:35 [222557] ERROR /home/wangha/Documents/nanomq/nng/src/supplemental/nanolib/conf_ver2.c:1532  conf_parse_ver2: Configure file [/etc/nanomq.conf] or [/etc/nanomq.conf] not found or unreadable
NanoMQ Broker is started successfully!
./nanomq/nanomq start --url nmq-tcp://0.0.0.0:4453
Config file is not specified, use default config file: /etc/nanomq.conf
2024-04-13 03:34:48 [222678] ERROR /home/wangha/Documents/nanomq/nng/src/supplemental/nanolib/conf_ver2.c:1532  conf_parse_ver2: Configure file [/etc/nanomq.conf] or [/etc/nanomq.conf] not found or unreadable
NanoMQ Broker is started successfully!
^C
Broker exit(0).

@JaylinYu JaylinYu added the feedback Waiting for futher feedbacks label Apr 16, 2024
@JaylinYu JaylinYu added the Investigation quiestion remains ambiguous label May 9, 2024
@JaylinYu
Copy link
Member

JaylinYu commented May 9, 2024

A pretty interesting way to test nanomq.
Anyway I doubt anyone would use it in such a strange way. even so, we don't recommend user to creat conflict listening address on websocket as well.
so I label it as invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback Waiting for futher feedbacks invalid Investigation quiestion remains ambiguous
Projects
None yet
Development

No branches or pull requests

3 participants