Summary

srfi-13 string-pad segfaults when arguments are not of the right type

Metadata

Description

This little piece of code causes a segfault (easy mistake to make, arguments order is reversed).

 (import srfi-13)
 (string-pad "coucou" #\space 10)

Changes and comments

[2019-08-04 13:57:58 UTC] sjamaan changed milestone from someday to 5.2

[2019-08-04 13:59:35 UTC] sjamaan wrote:

This is a bug in `##sys#check-exact`. It will fail anywhere it's used. In core there's currently two places remaining that use it: pointer-vector-ref and pointer-vector-set!

 (import (chicken memory))
 (pointer-vector-ref (make-pointer-vector 2) #\space) ; segfault

Actually, I think all these uses are bogus: an exact complex number is not a valid index into a vector or string. So probably it's better to get rid of `##sys#check-exact` altogether.

[2019-08-04 14:21:04 UTC] sjamaan wrote:

I've fixed srfi-13 to use `##sys#check-fixnum` but there are other eggs still using it:

- sequences - object-evict - srfi-1 - srfi-14 - srfi-18 - srfi-69 - vector-lib

[2019-08-04 14:44:22 UTC] sjamaan wrote:

I've updated the eggs now too. This ticket can be closed when core is patched to mark it as obsolete and remove uses in pointer-vector-ref/set!

[2019-08-25 10:22:20 UTC] sjamaan changed status from new to closed

[2019-08-25 10:22:20 UTC] sjamaan set resolution to fixed

[2019-08-25 10:22:20 UTC] sjamaan wrote:

Fixed with 29b3d6113985e2f110698d8ab7f398f51a88a819