Skip to content

[fix](function) Reject overflowing IPv6 uint128 strings - #68334

Open
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:fix-ipv6-uint128-overflow
Open

Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:fix-ipv6-uint128-overflow

Conversation

@Mryange

@Mryange Mryange commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Problem Summary: ipv6_from_uint128_string_or_null accepted empty strings and decimal values larger than uint128, causing digit-by-digit parsing to wrap around and produce an incorrect IPv6 value. Root cause: the parser performed unchecked multiplication and addition. This change rejects empty input and checks the value before each decimal accumulation so invalid input is converted to NULL by the existing nullable function path.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: N/A

Problem Summary: IPv6 decimal strings beyond the uint128 range previously wrapped during digit-by-digit parsing, and empty strings were accepted as zero. Add explicit empty-input and overflow checks so invalid values are rejected and the nullable function can return NULL.

### Release note

None

### Check List (For Author)

- Test: Focused BE ASAN unit test FunctionIpTest.IPv6FromUInt128StringRejectsEmptyAndOverflow

- Behavior changed: Yes (invalid empty and out-of-range values are rejected)

- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@Mryange

Mryange commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28130 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit f3744bdf9a7d60ad06a059ed881ac08d1a44669b, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17673	4022	4001	4001
q2	2172	370	309	309
q3	10094	1461	804	804
q4	4685	499	348	348
q5	7477	944	555	555
q6	193	187	137	137
q7	796	801	612	612
q8	9316	1500	1611	1500
q9	5566	4243	4211	4211
q10	6857	1343	1017	1017
q11	456	284	245	245
q12	636	452	297	297
q13	18076	2744	2005	2005
q14	267	257	237	237
q15	q16	745	725	668	668
q17	1881	1225	1047	1047
q18	6575	5612	5550	5550
q19	1332	1358	998	998
q20	495	407	270	270
q21	5903	3417	3001	3001
q22	453	363	318	318
Total cold run time: 101648 ms
Total hot run time: 28130 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5238	4785	4790	4785
q2	753	598	528	528
q3	4971	5234	4646	4646
q4	2355	2456	1442	1442
q5	4659	4759	4498	4498
q6	258	193	129	129
q7	1885	1781	1620	1620
q8	2558	2205	2186	2186
q9	7474	7378	7230	7230
q10	3687	3571	3111	3111
q11	544	368	336	336
q12	729	730	507	507
q13	2383	2729	2006	2006
q14	267	274	241	241
q15	q16	668	690	603	603
q17	7407	6761	6631	6631
q18	12006	11017	11863	11017
q19	1117	988	999	988
q20	2233	2213	1959	1959
q21	5154	4221	4358	4221
q22	507	453	388	388
Total cold run time: 66853 ms
Total hot run time: 59072 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 152658 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit f3744bdf9a7d60ad06a059ed881ac08d1a44669b, data reload: false

query5	4308	611	482	482
query6	436	218	201	201
query7	4877	528	287	287
query8	328	188	164	164
query9	8840	4038	4044	4038
query10	467	307	272	272
query11	5805	3534	3241	3241
query12	158	93	87	87
query13	1265	590	422	422
query14	6519	4516	4233	4233
query14_1	3915	3934	3918	3918
query15	203	198	180	180
query16	998	445	434	434
query17	924	661	546	546
query18	2443	447	338	338
query19	205	181	142	142
query20	85	84	81	81
query21	220	138	114	114
query22	13008	13171	12766	12766
query23	13878	12998	12370	12370
query23_1	12469	12453	12452	12452
query24	7518	1158	669	669
query24_1	693	679	668	668
query25	576	438	382	382
query26	1315	330	175	175
query27	2598	566	337	337
query28	4549	1963	2006	1963
query29	1710	759	534	534
query30	316	216	177	177
query31	894	755	631	631
query32	167	119	102	102
query33	544	319	248	248
query34	1180	1185	648	648
query35	751	754	671	671
query36	788	816	702	702
query37	149	106	88	88
query38	1844	1762	1686	1686
query39	683	702	662	662
query39_1	642	647	639	639
query40	224	121	101	101
query41	67	66	61	61
query42	94	93	98	93
query43	341	347	302	302
query44	1431	721	720	720
query45	187	176	168	168
query46	1110	1187	730	730
query47	1488	1498	1381	1381
query48	407	419	297	297
query49	581	419	292	292
query50	959	365	259	259
query51	10515	10404	10568	10404
query52	89	95	75	75
query53	247	263	180	180
query54	270	212	194	194
query55	76	79	70	70
query56	230	222	215	215
query57	1495	1452	1363	1363
query58	288	259	250	250
query59	1989	2050	1863	1863
query60	284	245	231	231
query61	154	151	149	149
query62	411	322	263	263
query63	224	178	185	178
query64	2798	1002	817	817
query65	3466	3414	3403	3403
query66	1795	415	316	316
query67	20109	20253	19815	19815
query68	3127	1491	939	939
query69	425	316	273	273
query70	908	826	784	784
query71	294	232	266	232
query72	2736	2602	2233	2233
query73	872	807	471	471
query74	4621	4485	4302	4302
query75	2328	2269	1951	1951
query76	2353	1133	769	769
query77	364	394	306	306
query78	9087	8976	8476	8476
query79	1413	1269	729	729
query80	581	469	389	389
query81	540	328	292	292
query82	873	172	129	129
query83	311	234	216	216
query84	316	153	117	117
query85	893	469	385	385
query86	334	242	233	233
query87	2004	1977	1852	1852
query88	3732	2765	2726	2726
query89	350	292	246	246
query90	1961	191	186	186
query91	173	159	130	130
query92	105	97	88	88
query93	1448	1435	879	879
query94	538	328	288	288
query95	688	376	441	376
query96	1090	777	352	352
query97	2462	2448	2332	2332
query98	163	149	142	142
query99	717	723	606	606
Total cold run time: 236945 ms
Total hot run time: 152658 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.89 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit f3744bdf9a7d60ad06a059ed881ac08d1a44669b, data reload: false

query1	0.01	0.01	0.01
query2	0.10	0.05	0.05
query3	0.26	0.13	0.13
query4	1.61	0.14	0.14
query5	0.25	0.22	0.22
query6	1.16	0.95	0.90
query7	0.04	0.01	0.00
query8	0.06	0.04	0.04
query9	0.39	0.33	0.33
query10	0.55	0.55	0.55
query11	0.19	0.14	0.14
query12	0.18	0.15	0.14
query13	0.47	0.46	0.48
query14	0.96	0.95	0.93
query15	0.60	0.60	0.59
query16	0.32	0.33	0.32
query17	1.04	1.13	1.13
query18	0.22	0.19	0.20
query19	2.01	1.86	1.94
query20	0.02	0.01	0.02
query21	15.48	0.22	0.14
query22	4.79	0.06	0.05
query23	16.13	0.31	0.12
query24	2.99	0.43	0.34
query25	0.13	0.05	0.04
query26	0.72	0.21	0.14
query27	0.04	0.03	0.03
query28	3.54	0.76	0.33
query29	12.51	3.99	3.23
query30	0.27	0.14	0.14
query31	2.77	0.55	0.31
query32	3.22	0.58	0.49
query33	3.23	3.14	3.17
query34	15.59	3.92	3.26
query35	3.20	3.21	3.21
query36	0.56	0.42	0.42
query37	0.10	0.07	0.06
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.14
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.03
Total cold run time: 96.15 s
Total hot run time: 23.89 s

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

Successfully merging this pull request may close these issues.

2 participants