
@sorawee is this right? I think sta1
below is working as a static method of the class counter%
? #lang racket/gui
(define counter%
(let* ([total 0]
(sta1 (λ () (+ 20 total))))
(class object%
(field (current-count 0))
(define/public (tada)
(sta1))
(super-new)
(define/public (get-count)
current-count)
(define/public (next)
(set! current-count (+ current-count 1))
(set! total (+ total 1))
(list current-count total)))))
(define c1 (new counter%))
(define c2 (new counter%))
(send c1 next)
(send c1 next)
(send c1 tada)
(send c1 next)
(send c2 next)
(send c1 tada)
(send c2 tada)

This :point_up_2: was derived from a so answer by @soegaard2

I really should generalise this as a macro

@mflatt I’m seeing some huge spikes in memory usage with Racket CS, up to 13GB even when using with-limits
at 2GB (ending up freezing my computer since I run several such processes in parallel). My guess: • GC is postponed during the intensive CPU usage and ends up eating a lot of memory before with-limits
can realize it’s way over 2GB. • Racket CS uses pre-allocated cons cells and when it runs out it doubles the previous amount. [edit: wrong] If that happens to be correct, then I think the doubling strategy is way too aggressive when memory is bounded. Also, before increasing the memory, it may be a good time to first check if the limit imposed by with-limits
is not reached. Do I have some better control over all this?

Which version of Racket CS are you using?

Racket v7.5.0.11 [cs]

My guess is that there’s some leak in Racket CS that causes it not to bound the memory use of your application as it should. Is it something that I can run?

I can’t share it for now unfortunately. However, once the function using with-limit terminates, I force a GC and memory comes back to normal (according to htop
). Does that still count as a memory leak?

Yes, I’m imagining it’s a kind of “leak” where the sandboxed data is reachable from outside the sandbox.

Static methods, as @spdegabrielle points out, are just functions

Instead of fromX I’d call it X->Y

@mila has joined the channel

Based on your comment, I could make this program eat up to 9GB despite the 1GB limit.

Replacing (set! a-tree tree)
with (set! a-tree (length tree))
doesn’t have the same bad behaviour (it still uses twice what it should do, which is not so great though)

Well, that’s a leak, but a deliberate one! It’s the same with traditional Racket and Racket CS, right?

Your real program works correctly with traditional Racket and not with Racket CS, right?

I think so. I say ‘I think’ because I’ve made a number of changes after the switch. Getting to the bad behaviour takes a long time so no so easy to check.
Also, I return only statistics through with-limits, like lengths and numbers, but not trees and such.
Regarding the intentional leak above, my expectation would still be that the program should break.

The tree program above just cannot work like you want. Accounting is based on reachability (not on, say, allocation time), and only those values reachable specifically from the sandbox will be charged to the sandbox.

@samth is my example idiomatic? Or would you do it differently?

I see. Then it may be because I just added some children relations in my program, and some root objects that live outside with-limits may hold some children. Since these may be reached from outside with-limits, they are not counted by it, is that correct?

That’s correct.

Ok. Thanks for the explanation. I’ll make copies of the root object inside with-limits instead, and see if that solves it.

Isn’t it only visible inside of the class though? Like you can’t provide that “static method”

@samdphillips maybe ? #lang racket/gui
(define staticmethod void)
(define counter%
(let* ([total 0]
(sta1 (λ () (+ 20 total))))
(class object%
(field (current-count 0))
(set! staticmethod sta1)
(super-new)
(define/public (get-count)
current-count)
(define/public (next)
(set! current-count (+ current-count 1))
(set! total (+ total 1))
(list current-count total)))))
(define c1 (new counter%))
(define c2 (new counter%))
(send c1 next)
(send c1 next)
(staticmethod)
(send c1 next)
(send c2 next)
(staticmethod)
not very elegant. I should work out a way to make a macro on top of class

Why is it that when a package build fails all of the online documentation for a collection vanishes? I made a mistake by leaving out a dependency in polyglot
and now all of my docs are gone.

I thought there would be some kind of protection against that kind of thing.

Is there something I need to configure?

A bunch of the docs are still there: https://docs.racket-lang.org/polyglot-reference@polyglot/index.html

I get a 404 when I visit that link

that’s quite odd, it works correctly for me

Looks like it gets rewritten too

Reproduces when I clear/disable cache

If you clear your cache/hard reload @samth, does it start to 404?

no, I’ve hard-reloaded several times

Yep, I’m confused.

I just opened another browser and it still works

I think I see what’s going on. Let me record a quick video.

It is actually cache-related, just not in the way I expected. When I produce the 404 the @polyglot
is stripped from the link.
https://docs.racket-lang.org/polyglot-reference@polyglot/index.html
When I visit https://docs.racket-lang.org/polyglot-reference/index.html, that DOES 404.

I expected the latter link to still work.

Shouldn’t it?

I think it doesn’t work because of the build failure

That’s kind of what I was afraid of. I’ll reconfigure my package source on the index to divide stable/unstable.

I assumed that failed builds would not be allowed to proceed to have that impact.

That seems to have solved it (for the most part). Thanks again!

Thanks! I’ll study that!

I might have made slight progress. The Could not resolve hostname
error is gone now, and now I’m getting the same error @ben was earlier, the timing out on ssh: Starting VirtualBox machine "racket-pkg-build"
Waiting for VM "racket-pkg-build" to power on...
VM "racket-pkg-build" has been successfully started.
/usr/bin/ssh -R 18333:localhost:18333 racket@10.0.2.15 '/usr/bin/env' 'PLTUSERHOME=/home/racket/build-pkgs/user' 'PLT_PKG_BUILD_SERVICE=1' 'CI=true' 'PLTSTDERR=debug@pkg error' 'PLT_INFO_ALLOW_VARS=;PLT_PKG_BUILD_SERVICE' '/bin/sh' '-c' 'echo hello'
ssh: connect to host 10.0.2.15 port 22: Operation timed out
/usr/bin/ssh -R 18333:localhost:18333 racket@10.0.2.15 '/usr/bin/env' 'PLTUSERHOME=/home/racket/build-pkgs/user' 'PLT_PKG_BUILD_SERVICE=1' 'CI=true' 'PLTSTDERR=debug@pkg error' 'PLT_INFO_ALLOW_VARS=;PLT_PKG_BUILD_SERVICE' '/bin/sh' '-c' 'echo hello'
ssh: connect to host 10.0.2.15 port 22: Operation timed out
/usr/bin/ssh -R 18333:localhost:18333 racket@10.0.2.15 '/usr/bin/env' 'PLTUSERHOME=/home/racket/build-pkgs/user' 'PLT_PKG_BUILD_SERVICE=1' 'CI=true' 'PLTSTDERR=debug@pkg error' 'PLT_INFO_ALLOW_VARS=;PLT_PKG_BUILD_SERVICE' '/bin/sh' '-c' 'echo hello'
ssh: connect to host 10.0.2.15 port 22: Operation timed out
/usr/bin/ssh -R 18333:localhost:18333 racket@10.0.2.15 '/usr/bin/env' 'PLTUSERHOME=/home/racket/build-pkgs/user' 'PLT_PKG_BUILD_SERVICE=1' 'CI=true' 'PLTSTDERR=debug@pkg error' 'PLT_INFO_ALLOW_VARS=;PLT_PKG_BUILD_SERVICE' '/bin/sh' '-c' 'echo hello'
ssh: connect to host 10.0.2.15 port 22: Operation timed out
ssh: failed
context...:
/Users/Alex/Library/Racket/snapshot-7.5.0.13--2019-12-16/pkgs/remote-shell-lib/ssh.rkt:180:2: loop
/Applications/Racket/2019-12-16/Racket v7.5.0.13/collects/racket/contract/private/arrow-val-first.rkt:555:3
/Users/Alex/Library/Racket/snapshot-7.5.0.13--2019-12-16/pkgs/pkg-build/main.rkt:452:5
/Users/Alex/Library/Racket/snapshot-7.5.0.13--2019-12-16/pkgs/pkg-build/main.rkt:445:2: install
/Users/Alex/Library/Racket/snapshot-7.5.0.13--2019-12-16/pkgs/pkg-build/main.rkt:515:2: check-and-install
/Users/Alex/Library/Racket/snapshot-7.5.0.13--2019-12-16/pkgs/pkg-build/main.rkt:123:0: build-pkgs
"/Users/Alex/racket-pkg-build/run.rkt": [running body]
temp35_0
for-loop
run-module-instance!
perform-require!
Stopping VirtualBox machine "racket-pkg-build"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
I think @ben said he solved this by having the vm & host exchange keys, with the host’s key in the authorized_keys of the vm (which I should have already), and the vm’s key in the known_hosts of the host (which I don’t have). I don’t really know how to do that

On the other hand maybe it’s an /etc/network/interfaces
problem, I don’t know
That file is still # interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

for known_hosts
you can either: • connect manually, answer (y) if it asks you whether to add an entry to known_hosts • open ~/.ssh/known_hosts
in a text editor, add a new line with (1) the VM ip address (2) the keytype and (3) the public key example line: 192.168.99.100 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMm9mr9OxT05yMFF6csABqY20k4OBQzM/DBkWu3mimcHwTyewWSG+ykP16TT93rss7iAdmXjUneTInfedlN80es=

but your problem might be that your host ssh key is protected with a password — you can fix that by making a new key

I’m having trouble connecting manually for the first bullet point. And I don’t know what public key I should put for (3) in the second bullet point, since there’s no id_rsa.pub
on the vm, at least not that I can find

@sebi.f has joined the channel