We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3849 - New resampler: ASan reports memcpy-param-overlap error
Summary: New resampler: ASan reports memcpy-param-overlap error
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: HG 2.1
Hardware: x86 Other
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-26 04:46 UTC by Eric Wasylishen
Modified: 2017-10-11 02:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Wasylishen 2017-09-26 04:46:03 UTC
Tested on https://hg.libsdl.org/SDL/rev/8ce1c541181d

To reproduce:
- download the test.wav that is attachmed to https://bugzilla.libsdl.org/show_bug.cgi?id=3846 (this is an 11000Hz sample)
- Run testresample with the arguments "test.wav out.wav 44100 2" in Xcode with Address Sanitizer enabled

It stops for me on the line:
   SDL_memcpy(cvt->buf, dst, cvt->len_cvt);  /* !!! FIXME: remove this if we can get the resampler to work in-place again. */

and I confirmed the memcpy is overwriting its input:

(lldb) print (char *)dst - (char *)cvt->buf
(long) $3 = 60672
(lldb) print cvt->len_cvt
(int) $4 = 243232
Comment 1 Eric Wasylishen 2017-10-03 22:37:45 UTC
Changing the SDL_memcpy to a SDL_memmove fixes the ASan warning and seems to work..

If I understand right, the memcpy is copying "output" (which is directly after "input" in a single buffer), over top of "input", which is OK, it just needs to be a memmove instead of memcpy:

[ input ] [ output (possibly longer than input)      ]

-->

[ output (possibly longer than input)      ] [ unused ]
Comment 2 Ryan C. Gordon 2017-10-11 02:32:18 UTC
Yeah, you're right, this should be a memmove.

Fixed in https://hg.libsdl.org/SDL/rev/f882930f174f, thanks!

--ryan.