Skip to content

Conversation

@amorynan
Copy link
Contributor

What problem does this PR solve?

if we set session variable for fold_constant_for_be = 1 and enable_decimal256 = true
here will meet error in sql

SELECT ARRAY_AVG(CAST([] AS ARRAY < DECIMALV3(1,0) > ));

with core

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:200:15 in
 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /mnt/disk1/wangqiannan/amory/doris/be/src/common/signal_handler.h:421
 1# PosixSignals::chained_handler(int, siginfo*, void*) [clone .part.0] in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 2# JVM_handle_linux_signal in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 3# 0x00007FD98C1A2B50 in /lib64/libc.so.6
 4# doris::vectorized::ColumnDecimal<doris::vectorized::Decimal<wide::integer<256ul, int> > >::get_data_at(unsigned long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:201
 5# doris::vectorized::DataTypeDecimalSerDe<doris::vectorized::Decimal<wide::integer<256ul, int> > >::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_decimal_serde.h:158
 6# doris::vectorized::DataTypeNullableSerDe::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_nullable_serde.cpp:237
 7# doris::FoldConstantExecutor::fold_constant_vexpr(doris::TFoldConstantParams const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/runtime/fold_constant_executor.cpp:118
 8# doris::PInternalService::_fold_constant_expr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1537
 9# doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0::operator()() const at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1515
10# void std::__invoke_impl<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(std::__invoke_other, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61
11# std::enable_if<is_invocable_r_v<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>, void>::type std::__invoke_r<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:117
12# std::_Function_handler<void (), doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0>::_M_invoke(std::_Any_data const&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
13# std::function<void ()>::operator()() const at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560
14# doris::WorkThreadPool<false>::work_thread(int) at /mnt/disk1/wangqiannan/amory/doris/be/src/util/work_thread_pool.hpp:158
15# void std::__invoke_impl<void, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(std::__invoke_memfun_deref, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:74
16# std::__invoke_result<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>::type std::__invoke<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:96

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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

@hello-stephen
Copy link
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?

@amorynan
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17572	6110	6015	6015
q2	2046	306	173	173
q3	10414	1193	732	732
q4	10225	860	425	425
q5	7917	2172	2034	2034
q6	206	181	143	143
q7	882	780	594	594
q8	9296	1402	1226	1226
q9	5259	4937	5014	4937
q10	6742	2300	1854	1854
q11	519	270	260	260
q12	337	361	216	216
q13	17775	4178	3130	3130
q14	237	222	203	203
q15	586	534	528	528
q16	628	602	570	570
q17	559	855	333	333
q18	6908	6607	6466	6466
q19	1447	956	535	535
q20	308	331	197	197
q21	2790	2220	1941	1941
q22	355	335	301	301
Total cold run time: 103008 ms
Total hot run time: 32813 ms

----- Round 2, with runtime_filter_mode=off -----
q1	6228	6218	6201	6201
q2	239	335	240	240
q3	2216	2648	2343	2343
q4	1388	1807	1338	1338
q5	4349	4723	4768	4723
q6	190	175	139	139
q7	2056	1960	1826	1826
q8	2570	2829	2717	2717
q9	7256	7282	7330	7282
q10	3107	3319	2735	2735
q11	600	548	523	523
q12	713	825	679	679
q13	3497	3906	3248	3248
q14	284	302	279	279
q15	578	521	538	521
q16	644	694	634	634
q17	1205	1743	1264	1264
q18	7698	7508	7322	7322
q19	785	1175	1045	1045
q20	1992	2031	1903	1903
q21	5613	5098	4976	4976
q22	594	622	590	590
Total cold run time: 53802 ms
Total hot run time: 52528 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 194508 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 8788da9728f334704ed4e4a17263a998c4602c40, data reload: false

query1	1298	946	922	922
query2	6368	2010	1983	1983
query3	11020	4461	4577	4461
query4	61578	29395	23240	23240
query5	5505	612	457	457
query6	434	194	173	173
query7	5504	500	293	293
query8	324	235	230	230
query9	8044	2761	2727	2727
query10	431	309	252	252
query11	17861	14944	15627	14944
query12	168	108	112	108
query13	1427	565	436	436
query14	11426	7077	7442	7077
query15	210	201	196	196
query16	6972	641	503	503
query17	1130	766	589	589
query18	1369	413	316	316
query19	207	259	153	153
query20	120	110	108	108
query21	211	126	110	110
query22	4438	4796	4257	4257
query23	34117	33662	33764	33662
query24	5589	2302	2383	2302
query25	456	498	405	405
query26	640	288	166	166
query27	1634	477	337	337
query28	4259	2504	2455	2455
query29	523	581	425	425
query30	217	182	157	157
query31	936	906	840	840
query32	71	61	61	61
query33	456	378	288	288
query34	755	870	534	534
query35	801	812	738	738
query36	999	1032	940	940
query37	129	109	72	72
query38	4319	4368	4158	4158
query39	1531	1463	1499	1463
query40	205	125	107	107
query41	52	49	48	48
query42	118	101	103	101
query43	512	522	494	494
query44	1362	846	859	846
query45	184	174	171	171
query46	894	1076	646	646
query47	1898	1867	1824	1824
query48	401	404	332	332
query49	701	500	410	410
query50	662	685	403	403
query51	6881	7110	6994	6994
query52	100	99	91	91
query53	230	255	186	186
query54	478	498	429	429
query55	86	80	84	80
query56	252	254	253	253
query57	1145	1131	1084	1084
query58	237	227	229	227
query59	3037	3198	3037	3037
query60	283	268	253	253
query61	130	123	126	123
query62	937	769	700	700
query63	219	188	183	183
query64	1255	1040	673	673
query65	3234	3162	3136	3136
query66	770	419	312	312
query67	16110	15748	15370	15370
query68	5039	830	543	543
query69	489	295	270	270
query70	1152	1169	1133	1133
query71	426	285	254	254
query72	6237	3910	3810	3810
query73	800	758	363	363
query74	10038	8935	8937	8935
query75	3234	3160	2648	2648
query76	3778	1200	754	754
query77	478	351	284	284
query78	10004	9952	9345	9345
query79	3438	802	592	592
query80	1644	532	440	440
query81	555	283	331	283
query82	350	149	122	122
query83	274	171	147	147
query84	281	98	71	71
query85	797	392	310	310
query86	461	310	301	301
query87	4579	4593	4341	4341
query88	4572	2189	2182	2182
query89	400	327	288	288
query90	1601	192	190	190
query91	146	144	108	108
query92	70	56	52	52
query93	2847	855	537	537
query94	765	401	299	299
query95	329	261	262	261
query96	484	636	282	282
query97	2805	2871	2727	2727
query98	221	191	199	191
query99	1400	1460	1394	1394
Total cold run time: 315544 ms
Total hot run time: 194508 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 30.7 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 8788da9728f334704ed4e4a17263a998c4602c40, data reload: false

query1	0.03	0.03	0.04
query2	0.06	0.04	0.04
query3	0.24	0.07	0.06
query4	1.62	0.10	0.11
query5	0.42	0.41	0.42
query6	1.14	0.65	0.65
query7	0.03	0.02	0.02
query8	0.04	0.03	0.03
query9	0.61	0.49	0.53
query10	0.53	0.57	0.54
query11	0.14	0.11	0.11
query12	0.14	0.11	0.11
query13	0.60	0.60	0.59
query14	2.72	2.72	2.70
query15	0.90	0.83	0.83
query16	0.40	0.39	0.38
query17	1.04	1.07	1.06
query18	0.23	0.22	0.20
query19	1.91	1.87	1.99
query20	0.01	0.02	0.01
query21	15.36	0.90	0.58
query22	0.75	0.77	0.75
query23	15.20	1.38	0.55
query24	2.74	1.70	0.30
query25	0.16	0.08	0.06
query26	0.44	0.16	0.14
query27	0.04	0.06	0.04
query28	12.98	1.58	1.05
query29	12.56	3.91	3.28
query30	0.25	0.09	0.06
query31	2.82	0.60	0.37
query32	3.23	0.55	0.45
query33	3.03	2.99	3.13
query34	16.74	5.12	4.53
query35	4.51	4.53	4.53
query36	0.65	0.49	0.47
query37	0.09	0.06	0.06
query38	0.04	0.04	0.04
query39	0.04	0.02	0.03
query40	0.15	0.14	0.13
query41	0.08	0.02	0.02
query42	0.04	0.03	0.02
query43	0.03	0.04	0.03
Total cold run time: 104.74 s
Total hot run time: 30.7 s

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 14, 2025
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@amorynan
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17579	6107	5985	5985
q2	2049	314	168	168
q3	10439	1236	727	727
q4	10224	871	437	437
q5	7878	2196	1934	1934
q6	208	182	145	145
q7	887	799	583	583
q8	9235	1358	1133	1133
q9	5191	4870	4998	4870
q10	6805	2289	1825	1825
q11	484	289	255	255
q12	337	365	209	209
q13	17788	3667	3147	3147
q14	231	235	208	208
q15	580	534	524	524
q16	631	639	593	593
q17	574	845	319	319
q18	6845	6468	6342	6342
q19	2124	969	559	559
q20	320	344	194	194
q21	2901	2202	2020	2020
q22	366	344	317	317
Total cold run time: 103676 ms
Total hot run time: 32494 ms

----- Round 2, with runtime_filter_mode=off -----
q1	6209	6216	7017	6216
q2	261	337	231	231
q3	2289	2679	2268	2268
q4	1381	1797	1399	1399
q5	4335	4704	4839	4704
q6	188	180	146	146
q7	2065	1935	1843	1843
q8	2622	2822	2676	2676
q9	7295	7232	7310	7232
q10	3038	3278	2763	2763
q11	592	519	526	519
q12	709	799	680	680
q13	3436	3900	3343	3343
q14	268	304	284	284
q15	580	516	547	516
q16	662	682	680	680
q17	1220	1754	1259	1259
q18	7760	7741	7385	7385
q19	796	975	1141	975
q20	2005	2074	1914	1914
q21	5574	5247	5056	5056
q22	605	633	594	594
Total cold run time: 53890 ms
Total hot run time: 52683 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 194560 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 1706d86679a968ef53f987a9ac2a969ea028048b, data reload: false

query1	1328	956	933	933
query2	6290	2032	2024	2024
query3	11043	4543	4463	4463
query4	61159	28783	23367	23367
query5	5570	605	459	459
query6	446	188	175	175
query7	5497	501	298	298
query8	320	232	232	232
query9	7899	2730	2709	2709
query10	438	295	245	245
query11	17611	15158	15754	15158
query12	159	108	107	107
query13	1424	540	392	392
query14	10765	6580	6389	6389
query15	207	204	187	187
query16	7086	648	478	478
query17	1141	705	544	544
query18	1703	407	319	319
query19	199	181	187	181
query20	117	116	112	112
query21	210	135	105	105
query22	4603	4768	4502	4502
query23	33799	33594	33645	33594
query24	5765	2331	2267	2267
query25	464	461	415	415
query26	637	278	160	160
query27	1702	465	342	342
query28	4014	2528	2497	2497
query29	549	596	427	427
query30	218	181	152	152
query31	940	880	806	806
query32	78	58	56	56
query33	462	368	305	305
query34	723	873	500	500
query35	781	842	736	736
query36	1012	1020	957	957
query37	121	103	78	78
query38	4281	4295	4195	4195
query39	1499	1432	1466	1432
query40	237	111	104	104
query41	51	50	52	50
query42	118	99	98	98
query43	512	528	500	500
query44	1328	841	839	839
query45	180	172	165	165
query46	874	1048	647	647
query47	1898	1967	1925	1925
query48	379	421	321	321
query49	700	507	389	389
query50	665	688	420	420
query51	7081	6983	6925	6925
query52	100	99	90	90
query53	231	252	185	185
query54	478	514	407	407
query55	83	80	78	78
query56	287	261	254	254
query57	1253	1243	1183	1183
query58	248	239	255	239
query59	3228	3103	2949	2949
query60	264	273	252	252
query61	123	124	136	124
query62	839	759	707	707
query63	222	186	184	184
query64	1237	1009	634	634
query65	3216	3149	3126	3126
query66	710	399	299	299
query67	15975	15875	15691	15691
query68	2302	835	561	561
query69	461	320	255	255
query70	1202	1132	1132	1132
query71	388	278	257	257
query72	6467	3984	3891	3891
query73	701	747	356	356
query74	9943	9185	8796	8796
query75	3267	3160	2647	2647
query76	2858	1163	764	764
query77	526	368	285	285
query78	10040	9971	9339	9339
query79	2807	807	615	615
query80	1711	532	442	442
query81	558	266	231	231
query82	357	150	121	121
query83	263	168	162	162
query84	284	101	83	83
query85	821	338	293	293
query86	462	302	299	299
query87	4434	4411	4399	4399
query88	4112	2196	2169	2169
query89	391	322	285	285
query90	1585	187	186	186
query91	127	133	107	107
query92	62	57	55	55
query93	2888	882	534	534
query94	771	408	297	297
query95	335	303	254	254
query96	493	623	277	277
query97	2819	2970	2799	2799
query98	221	196	201	196
query99	1424	1509	1390	1390
Total cold run time: 309857 ms
Total hot run time: 194560 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 31.42 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 1706d86679a968ef53f987a9ac2a969ea028048b, data reload: false

query1	0.04	0.03	0.03
query2	0.07	0.04	0.03
query3	0.23	0.07	0.07
query4	1.61	0.11	0.10
query5	0.42	0.43	0.41
query6	1.14	0.66	0.65
query7	0.03	0.02	0.01
query8	0.04	0.03	0.04
query9	0.59	0.51	0.51
query10	0.55	0.56	0.57
query11	0.14	0.10	0.11
query12	0.14	0.10	0.11
query13	0.61	0.60	0.61
query14	2.71	2.73	2.83
query15	0.91	0.82	0.82
query16	0.38	0.40	0.38
query17	1.07	1.07	1.07
query18	0.24	0.20	0.21
query19	1.93	1.84	2.00
query20	0.02	0.01	0.02
query21	15.38	0.93	0.58
query22	0.75	0.78	0.66
query23	15.28	1.43	0.54
query24	2.97	0.91	1.75
query25	0.14	0.16	0.18
query26	0.39	0.16	0.13
query27	0.04	0.05	0.05
query28	13.51	1.49	1.04
query29	12.58	3.92	3.25
query30	0.25	0.09	0.08
query31	2.83	0.59	0.38
query32	3.22	0.55	0.46
query33	2.98	3.05	3.04
query34	16.88	5.13	4.55
query35	4.53	4.56	4.54
query36	0.64	0.50	0.50
query37	0.08	0.06	0.06
query38	0.04	0.03	0.03
query39	0.04	0.03	0.02
query40	0.17	0.14	0.12
query41	0.07	0.03	0.03
query42	0.03	0.03	0.02
query43	0.04	0.03	0.02
Total cold run time: 105.71 s
Total hot run time: 31.42 s

Copy link
Member

@eldenmoon eldenmoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amorynan
Copy link
Contributor Author

run cloud_p0

@eldenmoon eldenmoon merged commit c91d919 into apache:master Jan 20, 2025
26 checks passed
lzyy2024 pushed a commit to lzyy2024/doris that referenced this pull request Feb 21, 2025
if we set session variable for fold_constant_for_be = 1 and
enable_decimal256 = true
here will meet error in sql 
```
SELECT ARRAY_AVG(CAST([] AS ARRAY < DECIMALV3(1,0) > ));
```
with core 
```
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:200:15 in
 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /mnt/disk1/wangqiannan/amory/doris/be/src/common/signal_handler.h:421
 1# PosixSignals::chained_handler(int, siginfo*, void*) [clone .part.0] in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 2# JVM_handle_linux_signal in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 3# 0x00007FD98C1A2B50 in /lib64/libc.so.6
 4# doris::vectorized::ColumnDecimal<doris::vectorized::Decimal<wide::integer<256ul, int> > >::get_data_at(unsigned long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:201
 5# doris::vectorized::DataTypeDecimalSerDe<doris::vectorized::Decimal<wide::integer<256ul, int> > >::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_decimal_serde.h:158
 6# doris::vectorized::DataTypeNullableSerDe::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_nullable_serde.cpp:237
 7# doris::FoldConstantExecutor::fold_constant_vexpr(doris::TFoldConstantParams const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/runtime/fold_constant_executor.cpp:118
 8# doris::PInternalService::_fold_constant_expr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1537
 9# doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0::operator()() const at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1515
10# void std::__invoke_impl<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(std::__invoke_other, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61
11# std::enable_if<is_invocable_r_v<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>, void>::type std::__invoke_r<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:117
12# std::_Function_handler<void (), doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0>::_M_invoke(std::_Any_data const&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
13# std::function<void ()>::operator()() const at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560
14# doris::WorkThreadPool<false>::work_thread(int) at /mnt/disk1/wangqiannan/amory/doris/be/src/util/work_thread_pool.hpp:158
15# void std::__invoke_impl<void, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(std::__invoke_memfun_deref, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:74
16# std::__invoke_result<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>::type std::__invoke<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:96
```
amorynan pushed a commit to amorynan/doris that referenced this pull request Mar 4, 2025
if we set session variable for fold_constant_for_be = 1 and
enable_decimal256 = true
here will meet error in sql
```
SELECT ARRAY_AVG(CAST([] AS ARRAY < DECIMALV3(1,0) > ));
```
with core
```
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:200:15 in
 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /mnt/disk1/wangqiannan/amory/doris/be/src/common/signal_handler.h:421
 1# PosixSignals::chained_handler(int, siginfo*, void*) [clone .part.0] in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 2# JVM_handle_linux_signal in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 3# 0x00007FD98C1A2B50 in /lib64/libc.so.6
 4# doris::vectorized::ColumnDecimal<doris::vectorized::Decimal<wide::integer<256ul, int> > >::get_data_at(unsigned long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:201
 5# doris::vectorized::DataTypeDecimalSerDe<doris::vectorized::Decimal<wide::integer<256ul, int> > >::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_decimal_serde.h:158
 6# doris::vectorized::DataTypeNullableSerDe::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_nullable_serde.cpp:237
 7# doris::FoldConstantExecutor::fold_constant_vexpr(doris::TFoldConstantParams const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/runtime/fold_constant_executor.cpp:118
 8# doris::PInternalService::_fold_constant_expr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1537
 9# doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0::operator()() const at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1515
10# void std::__invoke_impl<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(std::__invoke_other, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61
11# std::enable_if<is_invocable_r_v<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>, void>::type std::__invoke_r<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:117
12# std::_Function_handler<void (), doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0>::_M_invoke(std::_Any_data const&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
13# std::function<void ()>::operator()() const at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560
14# doris::WorkThreadPool<false>::work_thread(int) at /mnt/disk1/wangqiannan/amory/doris/be/src/util/work_thread_pool.hpp:158
15# void std::__invoke_impl<void, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(std::__invoke_memfun_deref, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:74
16# std::__invoke_result<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>::type std::__invoke<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:96
```
yiguolei pushed a commit that referenced this pull request Mar 4, 2025
if we set session variable for fold_constant_for_be = 1 and
enable_decimal256 = true
here will meet error in sql
```
SELECT ARRAY_AVG(CAST([] AS ARRAY < DECIMALV3(1,0) > ));
```
with core
```
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:200:15 in
 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /mnt/disk1/wangqiannan/amory/doris/be/src/common/signal_handler.h:421
 1# PosixSignals::chained_handler(int, siginfo*, void*) [clone .part.0] in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 2# JVM_handle_linux_signal in /mnt/disk1/wangqiannan/tool/jdk-17.0.10/lib/server/libjvm.so
 3# 0x00007FD98C1A2B50 in /lib64/libc.so.6
 4# doris::vectorized::ColumnDecimal<doris::vectorized::Decimal<wide::integer<256ul, int> > >::get_data_at(unsigned long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/columns/column_decimal.h:201
 5# doris::vectorized::DataTypeDecimalSerDe<doris::vectorized::Decimal<wide::integer<256ul, int> > >::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_decimal_serde.h:158
 6# doris::vectorized::DataTypeNullableSerDe::write_column_to_pb(doris::vectorized::IColumn const&, doris::PValues&, long, long) const at /mnt/disk1/wangqiannan/amory/doris/be/src/vec/data_types/serde/data_type_nullable_serde.cpp:237
 7# doris::FoldConstantExecutor::fold_constant_vexpr(doris::TFoldConstantParams const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/runtime/fold_constant_executor.cpp:118
 8# doris::PInternalService::_fold_constant_expr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, doris::PConstantExprResult*) at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1537
 9# doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0::operator()() const at /mnt/disk1/wangqiannan/amory/doris/be/src/service/internal_service.cpp:1515
10# void std::__invoke_impl<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(std::__invoke_other, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61
11# std::enable_if<is_invocable_r_v<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>, void>::type std::__invoke_r<void, doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&>(doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:117
12# std::_Function_handler<void (), doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0>::_M_invoke(std::_Any_data const&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291
13# std::function<void ()>::operator()() const at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560
14# doris::WorkThreadPool<false>::work_thread(int) at /mnt/disk1/wangqiannan/amory/doris/be/src/util/work_thread_pool.hpp:158
15# void std::__invoke_impl<void, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(std::__invoke_memfun_deref, void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:74
16# std::__invoke_result<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>::type std::__invoke<void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&>(void (doris::WorkThreadPool<false>::* const&)(int), doris::WorkThreadPool<false>*&, int&) at /mnt/disk1/wangqiannan/tool/ldb_toolchain_16/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:96
```

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] 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 <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/2.1.9-merged dev/3.0.5-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants