Hi all,
Here's a pretty simple patch for #1133. It segfaults with a regular
build, but a DEBUGBUILD says exactly what's wrong:
Error: unbound variable: make-input-port
Call history:
foo.scm:2: tcp-listen
foo.scm:2: tcp-accept <--
The problem got introduced when we fixed a similar bug in unit ports,
This time it turns out that the core itself gets its dependencies wrong:
tcp uses one procedure from ports but none from extras, even though it
only depends on extras!
I've replaced extras by ports to fix the dependency stuff. I think it's
time we started making a more concrete plan on how to make the core
system use proper modules instead of "units", while still maintaining
separate compilation of course! If we use modules, this kind of bug
will be easily detected because the module refuses to compile. It will
also make the system cleaner in general because names won't "leak out"
unless explicitly imported. Anyway, this is a long-term project that
will probably require fixing #1131 (kill ##sys#alias-global-hook) first.
This bugfix should probably go into the stability branch.
Cheers,
Peter
--
http://www.more-magic.net
>From b7b0248903d52be773455d528352bfba31fd9e8f Mon Sep 17 00:00:00 2001
From: Peter Bex <[email protected]>
Date: Thu, 19 Jun 2014 20:06:19 +0200
Subject: [PATCH] Fix #1133 by adding ports (and dropping extras) in unit
tcp's "uses" declaration
This problem got caused by 4eafceedddf34dff83c05eb6001214461949e7ce
(the fix for #999), because tcp uses make-input-port. This is
provided by ports, which got pulled in through extras which tcp
does depend upon.
Unit TCP doesn't really use anything from extras, so we now declare it
to depend on ports instead. Ports pulls in extras, so there's no way
to easily verify that TCP isn't using anything from extras except by
grepping the sources for procedures. We should really try to switch
to modules in core, that would've easily caught this!
Reported by Kristian Lein-Mathisen
---
NEWS | 3 +++
tcp.scm | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index df838ca..35df39f 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@
- Core libraries
- alist-ref from unit data-structures now gives an error when passed
a non-list, for consistency with assv/assq/assoc.
+ - Unit tcp now implicitly depends on ports instead of extras.
+ This may break programs which don't use modules and forgot to
+ require extras but use procedures from it.
- Unit lolevel:
- Restore long-lost but still documented "vector-like?" procedure (#983)
diff --git a/tcp.scm b/tcp.scm
index d0ac20e..cf81792 100644
--- a/tcp.scm
+++ b/tcp.scm
@@ -27,7 +27,7 @@
(declare
(unit tcp)
- (uses extras scheduler)
+ (uses ports scheduler)
(disable-interrupts) ; Avoid race conditions around errno/WSAGetLastError
(export tcp-close tcp-listen tcp-connect tcp-accept tcp-accept-ready?
##sys#tcp-port->fileno tcp-listener? tcp-addresses
tcp-abandon-port tcp-listener-port tcp-listener-fileno
tcp-port-numbers tcp-buffer-size
--
1.7.10.4
_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers