Summary
string-copy! bug
Metadata
- Id: 0480e82d53a24cadb0956a9bf379a7bc551e094d
- Trac id: 1135
- Type: defect
- Reporter: mario
- Owner:
- Cc:
- Status: closed
- Component: core libraries
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: 4.10.0
- Version: 4.9.x
- Changetime: 2014-06-30 21:32:33 UTC
- Created: 2014-06-27 16:51:02 UTC
- Keywords: string-copy!, srfi-13
Attachments
- 0480e82d53a24cadb0956a9bf379a7bc551e094d/attachments/0001-C_substring_copy-use-C_memmove-instead-of-C_memcpy.patch
- 0480e82d53a24cadb0956a9bf379a7bc551e094d/attachments/0001-C_substring_copy-use-C_memmove-instead-of-C_memcpy-w.patch
Description
While using the gap-buffer egg (implementation ported from Guile), I noticed a weird behavior in certain cases (see http://lists.gnu.org/archive/html/guile-devel/2014-06/msg00060.html)
Looks like the culprit is string-copy! (probably C_substring_copy), as it was in Guile's case (as pointed by Mark H Weaver).
A test case from Guile's test suite illustrates the problem:
(let ((str (string-copy "abcde"))) (string-copy! str 1 str 0 3) str) => "aaaae" Expected: "aabce"
Changes and comments
[2014-06-27 20:54:33 UTC] mario attached 0001-C_substring_copy-use-C_memmove-instead-of-C_memcpy-w.patch (description=#f)
[2014-06-27 20:55:39 UTC] mario wrote:
The attached patch Works For Me, although I don't know if it is the optimal/correct solution.
[2014-06-27 23:03:56 UTC] mario attached 0001-C_substring_copy-use-C_memmove-instead-of-C_memcpy.patch (description=#f)
[2014-06-27 23:04:12 UTC] mario wrote:
Seth Alves pointed out on #chicken that checking for string equality is pointless, since memmove will do that anyway. So, attached is a new patch which just replaces C_memcpy by C_memmove in C_substring_copy.
[2014-06-30 21:32:33 UTC] sjamaan changed status from new to closed
[2014-06-30 21:32:33 UTC] sjamaan set resolution to fixed
[2014-06-30 21:32:33 UTC] sjamaan wrote:
Fixed by 6b36695d94e0bd977e0d85d48438f621128e1101