Daniel Sahlberg <daniel.l.sahlb...@gmail.com> writes:

> Den ons 26 feb. 2025 kl 12:33 skrev Sam James <s...@gentoo.org>:
>
>  Hi!
>
> Hi,

Hi Daniel,

>
> Thanks for the detailed report!

And thank you for the quick response (and Stefan too).

>
>  When subversion-1.14.5 is built with upcoming GCC 15 with -O3 -mavx (or
>  -O2 -mavx -fno-vect-cost-model), it crashes in some cases in
>  svn_eol__find_eol_start.
>
>  We found `svn checkout https://svn.code.sf.net/p/sdcc/code/trunk/sdcc`
>  was a reliable reproducer, as was `svn cleanup sdcc` once the first
>  command crashed. (The svn testsuite passes, though.)
>
>  Full backtrace:
>  ```
>  Thread 1 (Thread 0x7fb5f533d7c0 (LWP 418455)):
>  #0  0x00007fb5f5be084d in svn_eol__find_eol_start (buf=<optimized out>, 
> buf@entry=0x564804d4a48b "  
>  bug3379723.c\n*/\n\n#include <testfwk.h>\n\n#if !defined(PORT_HOST) && 
> !defined(__SDCC_hc08) && !defined(__SDCC_s08)
>  && !defined(__SDCC_mos6502) && !defined(__SDCC_mos65c02) && 
> !defined(__SDCC_sm83) && "..., len=<optimized out>,
>  len@entry=838) at subversion/libsvn_subr/eol.c:43
>  #1  0x00007fb5f5c0d2ca in translate_chunk (dst=dst@entry=0x564804d56840, 
> b=0x56480490dec0, buf=<optimized out>,
>  buflen=<optimized out>, pool=<optimized out>) at 
> subversion/libsvn_subr/subst.c:1152
>  #2  0x00007fb5f5c0e91d in translated_stream_read (baton=0x56480490de20, 
> buffer=0x564804d4f498 "/*\n   bug2686159.c\n
>  */\n\n#include <testfwk.h>\n\n#ifdef __SDCC_pic16\n# define ADDRESS(x) (0x02 
> ## x)\n#elif defined(__SDCC_pic14)\n#
>  define ADDRESS(x) (0x01A0 + 0x ## x)\n#elif defined(__SDCC_stm8)\n# 
> define"..., len=0x7ffe9abfae10) at
>  subversion/libsvn_subr/subst.c:1297
>  #3  0x00007fb5f5c08647 in svn_stream_copy3 (from=0x56480490de60, 
> to=0x564804d49548,
>  cancel_func=cancel_func@entry=0x7fb5f5bcffb0 <check_cancel>, 
> cancel_baton=cancel_baton@entry=0x0,
>  scratch_pool=scratch_pool@entry=0x56480490c6f8) at 
> subversion/libsvn_subr/stream.c:423
>  #4  0x00007fb5f5d01d45 in run_file_install (wqb=0x7ffe9abfaf90, 
> db=0x56480464e268, work_item=<optimized out>,
>  wri_abspath=0x5648049de410 "/home/kostadin/sdcc/support/regression/tests", 
> cancel_func=0x7fb5f5bcffb0 <check_cancel>,
>  cancel_baton=0x0, scratch_pool=0x56480490c6f8) at 
> subversion/libsvn_wc/workqueue.c:580
>  #5  0x00007fb5f5d02fdd in dispatch_work_item (wqb=<optimized out>, 
> db=<optimized out>, wri_abspath=<optimized out>,
>  work_item=<optimized out>, cancel_func=<optimized out>, 
> cancel_baton=<optimized out>, scratch_pool=<optimized out>)
>  at subversion/libsvn_wc/workqueue.c:1441
>  #6  svn_wc__wq_run (db=0x56480464e268, wri_abspath=0x5648049de410 
> "/home/kostadin/sdcc/support/regression/tests",
>  cancel_func=0x7fb5f5bcffb0 <check_cancel>, cancel_baton=0x0, 
> scratch_pool=scratch_pool@entry=0x5648049de2a8) at
>  subversion/libsvn_wc/workqueue.c:1546
>  #7  0x00007fb5f5cc4f0c in close_directory (dir_baton=0x5648049de320, 
> pool=<optimized out>) at
>  subversion/libsvn_wc/update_editor.c:2819
>  #8  0x00007fb5f55c89b3 in maybe_close_dir (dir=<optimized out>) at 
> subversion/libsvn_ra_serf/update.c:738
>  #9  0x00007fb5f55ce0fc in handle_response_cb (request=0x5648048aee18, 
> response=<optimized out>, baton=0x5648048a0ff0,
>  response_pool=0x564804d46468) at subversion/libsvn_ra_serf/util.c:1540
>  #10 0x00007fb5f5393f8e in serf.process_connection () from 
> /usr/lib64/libserf-1.so.1
>  #11 0x00007fb5f5394815 in serf_event_trigger () from 
> /usr/lib64/libserf-1.so.1
>  #12 0x00007fb5f5394989 in serf_context_run () from /usr/lib64/libserf-1.so.1
>  #13 0x00007fb5f55cd7b1 in svn_ra_serf__context_run (sess=0x564804679c60, 
> waittime_left=0x7ffe9abfb3a0,
>  scratch_pool=0x5648047128b8) at subversion/libsvn_ra_serf/util.c:913
>  #14 svn_ra_serf__context_run (sess=0x564804679c60, 
> waittime_left=0x7ffe9abfb3a0, scratch_pool=0x5648047128b8) at
>  subversion/libsvn_ra_serf/util.c:902
>  #15 0x00007fb5f55c998d in process_editor_report (ctx=0x564804661b28, 
> handler=0x564804690a08,
>  scratch_pool=0x564804690878) at subversion/libsvn_ra_serf/update.c:2429
>  #16 finish_report (report_baton=0x564804661b28, pool=<optimized out>) at 
> subversion/libsvn_ra_serf/update.c:2504
>  #17 0x00007fb5f5c868d0 in svn_wc_crawl_revisions5 (wc_ctx=<optimized out>,
>  local_abspath=local_abspath@entry=0x56480465f8a0 "/home/kostadin/sdcc", 
> reporter=0x7fb5f55df960 <ra_serf_reporter>,
>  report_baton=0x564804661b28, restore_files=restore_files@entry=1, 
> depth=depth@entry=svn_depth_unknown,
>  honor_depth_exclude=1, depth_compatibility_trick=0, use_commit_times=0, 
> cancel_func=0x7fb5f5bcffb0 <check_cancel>,
>  cancel_baton=0x0, notify_func=0x5647fc07f070 
> <svn_cl__check_externals_failed_notify_wrapper>,
>  notify_baton=0x7ffe9abfb9e0, scratch_pool=0x56480465f788) at 
> subversion/libsvn_wc/adm_crawler.c:859
>  #18 0x00007fb5f5dbb741 in update_internal (result_rev=result_rev@entry=0x0,
>  timestamp_sleep=timestamp_sleep@entry=0x7ffe9abfb91c, 
> conflicted_paths=conflicted_paths@entry=0x0,
>  ra_session_p=<optimized out>, 
> local_abspath=local_abspath@entry=0x56480465f8a0 "/home/kostadin/sdcc",
>  anchor_abspath=anchor_abspath@entry=0x564804661350 "/home/kostadin/sdcc", 
> revision=0x7ffe9abfb790,
>  depth=svn_depth_unknown, depth_is_sticky=0, ignore_externals=0, 
> allow_unver_obstructions=0, adds_as_modification=1,
>  notify_summary=1, ctx=0x56480464e180, result_pool=0x56480465f788, 
> scratch_pool=0x56480465f788) at
>  subversion/libsvn_client/update.c:560
>  #19 0x00007fb5f5dbbc8c in svn_client__update_internal 
> (result_rev=result_rev@entry=0x0,
>  timestamp_sleep=timestamp_sleep@entry=0x7ffe9abfb91c, 
> local_abspath=local_abspath@entry=0x56480465f8a0
>  "/home/kostadin/sdcc", revision=revision@entry=0x7ffe9abfb870, 
> depth=depth@entry=svn_depth_unknown,
>  depth_is_sticky=depth_is_sticky@entry=1, ignore_externals=0, 
> allow_unver_obstructions=0, adds_as_modification=1,
>  make_parents=0, innerupdate=0, ra_session=<optimized out>, 
> ctx=0x56480464e180, pool=0x56480465f788) at
>  subversion/libsvn_client/update.c:696
>  #20 0x00007fb5f5d5336d in svn_client__checkout_internal 
> (result_rev=result_rev@entry=0x0,
>  timestamp_sleep=timestamp_sleep@entry=0x7ffe9abfb91c, 
> url=url@entry=0x56480465e1f8
>  "https://svn.code.sf.net/p/sdcc/code/trunk/sdcc";, 
> local_abspath=0x56480465f8a0 "/home/kostadin/sdcc",
>  peg_revision=peg_revision@entry=0x7ffe9abfb9d0, 
> revision=revision@entry=0x7ffe9abfb9c0, depth=svn_depth_unknown,
>  ignore_externals=0, allow_unver_obstructions=0, ra_session=<optimized out>, 
> ctx=0x56480464e180,
>  scratch_pool=0x56480465f788) at subversion/libsvn_client/checkout.c:189
>  #21 0x00007fb5f5d53594 in svn_client_checkout3 
> (result_rev=result_rev@entry=0x0, URL=0x56480465e1f8
>  "https://svn.code.sf.net/p/sdcc/code/trunk/sdcc";, path=<optimized out>,
>  peg_revision=peg_revision@entry=0x7ffe9abfb9d0, 
> revision=revision@entry=0x7ffe9abfb9c0, depth=svn_depth_unknown,
>  ignore_externals=0, allow_unver_obstructions=0, ctx=0x56480464e180, 
> pool=0x56480465f788) at
>  subversion/libsvn_client/checkout.c:218
>  #22 0x00005647fc06bef2 in svn_cl__checkout (os=<optimized out>, 
> baton=<optimized out>, pool=<optimized out>) at
>  subversion/svn/checkout-cmd.c:168
>  #23 0x00005647fc08b7eb in sub_main 
> (exit_code=exit_code@entry=0x7ffe9abfbe34, argc=argc@entry=3,
>  cmdline_argv=cmdline_argv@entry=0x7ffe9abfbf68, 
> pool=pool@entry=0x56480464c638) at subversion/svn/svn.c:3263
>  #24 0x00005647fc06983f in main (argc=3, argv=0x7ffe9abfbf68) at
>  subversion/svn/svn.c:3348
>  ```
>
>  The unaligned access itself controlled by SVN_UNALIGNED_ACCESS_IS_OK in
>  svn_eol__find_eol_start AFAIK isn't wrong, just the forming and use of
>  an unaligned pointer for (apr_)uintptr_t.
>
> Looking at the code, I'm assuming that if SVN_UNALIGNED_ACCESS_IS_OK was  set 
> to 0 (so the char by char loop after #endif
> is used instead), the code would run just fine. Can you confirm that?
>

Confirmed. And I've also checked it vectorises (though not benchmarked
it).

> SVN_UNALIGNED_ACCESS_IS_OK is defined as follows - we'd probably have to 
> change that for GCC15.
>
> #ifndef SVN_UNALIGNED_ACCESS_IS_OK
> # if defined(_M_IX86) || defined(i386) \
>      || defined(_M_X64) || defined(__x86_64) \
>      || defined(__powerpc__) || defined(__ppc__)
> #  define SVN_UNALIGNED_ACCESS_IS_OK 1
> # else
> #  define SVN_UNALIGNED_ACCESS_IS_OK 0
> # endif
> #endif

>
>  -fsanitize=undefined (or -fsanitize=alignment, take your pick; it's a
>   subset) reports:
>  ```
>  subversion/libsvn_subr/eol.c:43:21: runtime error: load of misaligned 
> address 0x56302447f98b for type 'const
>  apr_uintptr_t', which requires 8 byte alignment
>  0x56302447f98b: note: pointer points here
>   00  2f 2a 0a 20 20 20 62 75  67 33 33 37 39 37 32 33  2e 63 0a 2a 2f 0a 0a 
> 23  69 6e 63 6c 75 64 65
>                ^ 
>  ```
>

thanks,
sam

Reply via email to