[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Posix Test Failure
From: |
J Altfas |
Subject: |
[Chicken-users] Posix Test Failure |
Date: |
Thu, 11 Apr 2013 21:14:26 -0700 |
Yesterday I'd compiled the most recent git-master version of Chicken. Everything went fine until I encountered a seg-fault failure during "make test", the culprit being "posix-tests.scm".
In the portion of the test:
(let ((tnpfilpn (create-temporary-file)))
(let ((tmpfilno (file-open tnpfilpn ( open/rdwr open/creat)))
(data "abcde")
(size 5))
(file-write tmpfilno data)
(let ((mmap (map-file-to-memory #f size prot/read map/file tmpfilno))
(str (make-string size)))
(assert (memory-mapped-file? mmap))
(move-memory! (memory-mapped-file-pointer mmap) str size)
(assert (blob=? (string->blob data) (string->blob str)))
(unmap-file-from-memory mmap))))
the problem arose during (move-memory! ...) because mmap was actually pointing at address #x00, obviously not a valid location, resulting in the seg-fault.
On investigation, it turns out that, at least on Linux, the map/file flag doesn't do anything. It's necessary to also use map/private, map/shared, etc., in order for mmap function (that is, map-file-to-memory) to work. (In fact, map/file isn't needed at all and may be omitted.)
Modifying the procedure call in the (let ((mmap ...) line as follows returns a valid pointer and the test succeeds:
(let ((mmap (map-file-to-memory #f size prot/read ( map/file map/private) tmpfilno))
...
Likely enough, the mmap call varies among operating systems so I'm not sure what the general solution would be, but I thought the problem with the test was worth pointing out.
Jules Altfas.
- [Chicken-users] Posix Test Failure,
J Altfas <=