ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
patrixl has quit [Read error: Connection reset by peer]
aw- has joined #picolisp
patrixl has joined #picolisp
_whitelogger has joined #picolisp
<aw-> Regenaxer hi
<aw-> i found a bug in pil21 which has to do with (listen) or (poll) or something...
<aw-> i'll wait until you're online to explain, but essentially it seems my parent process goes into an infinite 'poll' loop after i make a tcp connection
<aw-> brings the CPU core to 100% unless i kill it
<aw-> confirmed it's in the parent, not the child that gets forked on the TCP
<aw-> more details later
<aw-> i'll make a reproducible test for you to analyze, and post it to pastebin shortly
<Regenaxer> Good morning aw-
<Regenaxer> Cool, thanks!
<aw-> Regenaxer morning, we're in the middle of a really bad typhoon here
<aw-> no electricity since 3am
<aw-> but i'm fine, staying in a hotel temporarily, quiet time for coding ;)
<Regenaxer> yeah, I know. Masako is watching news of Okinawa
<aw-> this paste has strace output
<aw-> you can see the child process exit, and parent goes in infinite poll loop
<aw-> doesn't happen on pil64
<Regenaxer> Hmm, the ubuntu paste does not work well in w3m
<Regenaxer> I can't get raw display
<aw-> oh
<aw-> ok one sec
<aw-> omg they changed it
<aw-> now you need to login to vieww plain text
<aw-> stupid shit
<Regenaxer> no problom
<aw-> one sec
<Regenaxer> I can read
<Regenaxer> cool you made an strace
<aw-> i paste plaintext to pastebin
<Regenaxer> good
<Regenaxer> perfect
<aw-> yes strace was useful to pinpoint if the problem is the child or parent
<aw-> ok i'll be back in a bit
<aw-> hope this helps
<aw-> thanks
<Regenaxer> yes, good
<Regenaxer> I'll check more closely soon
patrixl has quit [Read error: Connection reset by peer]
patrixl has joined #picolisp
_whitelogger has joined #picolisp
<Regenaxer> Hmm, not sure what exactly goes wrong
<Regenaxer> the nonblocking is not reset?
<Regenaxer> listen by itself works, could it be 'fork'?
<Regenaxer> Perhaps we should compare with strace on pil64
<aw-> Regenaxer:
<aw-> raw paste of pil64 (aarch64) same code
<Regenaxer> Cool! Thanks!
<aw-> no, thank you
<Regenaxer> F_SETFL is ok it seems
<Regenaxer> hmm, the second uses pselect and it block as expected
<Regenaxer> the first uses ppoll, and it returns ([{fd=10, revents=POLLHUP}])
<Regenaxer> 10 is returned by fcntl(3, F_DUPFD, 10)
<Regenaxer> Never checked what POLLHUP is
rob_w has joined #picolisp
<Regenaxer> seems ok though
<Regenaxer> So why is 10 not closed?
<Regenaxer> All strace is in the parent, right?
orivej has quit [Ping timeout: 256 seconds]
<Regenaxer> I wonder what file descriptor 10 is
<aw-> yes in parent
<Regenaxer> dup() is not called here, and dup2() only on some pipes after fork()
<Regenaxer> So it must be one of the child pipes
<Regenaxer> Nothing to do with the networking
<aw-> oh interesting
<Regenaxer> hmm, no, it could be the files
<Regenaxer> not fork()
<aw-> wait i have an idea
<aw-> i'll send another pastbin in a minute
<Regenaxer> ok
<aw-> it's a pipe
<Regenaxer> ah, ok
<Regenaxer> not a socket?
<aw-> this is on my rock64, same test
<aw-> 4887 is the parent pid
<aw-> before the TCP connection there were only FDs 1 to 4
<aw-> err.. 0 to 4
<aw-> fd 6,7,9,10 appeared after TCP connection and infinite poll loop
<aw-> with pil21
<Regenaxer> Is it the same allocation of FDs?
<aw-> on each run? yes
<aw-> it seems there's 2 extra pipes with pil21
<Regenaxer> looks a lot like the pipes from forkLisp
<aw-> with pil64 i only have FDs 0 to 4 and FDs 6, 7 after TCP connection
<Regenaxer> TCP connection makes no pipes, only (fork) does
<aw-> right
<Regenaxer> but it is ok if the pipes are open
<aw-> so (fork) is creating more pipes than necessary?
<Regenaxer> why does it send a HUP
<Regenaxer> no, seems correct
<Regenaxer> 4 or 6 pipes
<Regenaxer> 6 in top level parent
<Regenaxer> well, 3 pipe() calls, giving 6 FDs
<aw-> n pil21 you're using ppoll() instead of pselect() ?
<Regenaxer> yes
<Regenaxer> poll() vs select() on C level
<Regenaxer> ppoll etc are the internal system calls
<aw-> are you handling the result from poll() correctly?
<Regenaxer> I hope so
<aw-> it seems like i receives the result but continues to poll instead of exit
<aw-> as if there was no data on the fd
<Regenaxer> it returns ([{fd=10, revents=POLLHUP}])
<Regenaxer> not POLLIN
<aw-> oh
<aw-> it's NOT reading after poll returs 1
<Regenaxer> yes, because it does not say there are data
<aw-> or is that how poll() works? i don't know :P
<Regenaxer> data are there if POLLIN
<Regenaxer> but it sends a HUP event
<aw-> hmmm
<Regenaxer> I don't know if this is correct
<Regenaxer> or if I must handle it somehow
<Regenaxer> I mean, is it normal to get HUP? Feels like
<aw-> i dont know enough about C syscalls :\
<Regenaxer> Some closed socket
<Regenaxer> as expected by the name HUP :)
<aw-> hahaha
<Regenaxer> Somewhere closing the wrong socket perhaps
<aw-> closing the socket in the child but not in the parent?
<Regenaxer> This is ok, or even necessary
<Regenaxer> "Linux sets POLLIN|POLLHUP when the other end of a socket closed the socket"
<Regenaxer> This would be fine
<Regenaxer> cause then pil closes the socket
<Regenaxer> Problem is that we get *only* POLLHUP
<Regenaxer> so pil does not handle it
<aw-> what is revents? compared to events?
<Regenaxer> 'r' is for "receive"
<Regenaxer> "events" is what we are interested in
<Regenaxer> and "revents" is what we get back
<aw-> oh ok
<aw-> thanks
<Regenaxer> Man page: "The field events is an input parameter, a bit mask specifying the events the application is interested in"
<Regenaxer> I think I do not specify POLLHUP
<Regenaxer> in src/lib.c
<Regenaxer> p->events = POLLIN;
<Regenaxer> Correct as far as I understand it
<Regenaxer> I always used select() before
<Regenaxer> poll() is better in some regards
<Regenaxer> especially, not limited to 1024 FDs
<Regenaxer> hmm, there is an example in the above stackoverflow
<Regenaxer> it receives HUP
<Regenaxer> and then closes
<Regenaxer> But I close when POLLIN and then zero
<Regenaxer> This should be ok to my understanding
<Regenaxer> I rely on the man page "Linux sets POLLIN|POLLHUP"
patrixl has quit [Read error: Connection reset by peer]
<Regenaxer> I try it here
<Regenaxer> same
<Regenaxer> Ah, POLLHUP is not the problem!
<Regenaxer> the infinite loop is returning POLLIN as expected
<Regenaxer> ok
Regenaxer has left #picolisp [#picolisp]
Regenaxer has joined #picolisp
<Regenaxer> So there is indeed something wrong with closing
<Regenaxer> I have some other stuff to do. Will check later
<Regenaxer> Thanks so far! :)
patrixl has joined #picolisp
<aw-> ok thanks Regenaxer
aw- has quit [Quit: bbl]
orivej has joined #picolisp
razzy has joined #picolisp
razzy has quit [Quit: Connection closed]
aw- has joined #picolisp
razzy has joined #picolisp
rob_w has quit [Quit: Leaving]
<aw-> back
<Regenaxer> I had no time yet. Let's see this evening
<aw-> no problem
jibanes has quit [Ping timeout: 258 seconds]
jibanes has joined #picolisp
beneroth has quit [Remote host closed the connection]
beneroth has joined #picolisp
<Regenaxer> Uuuhhh!
<Regenaxer> Got it
<Regenaxer> aw-, there are two reasons:
<Regenaxer> One is that I need indeed check also for POLLHUP and also POLLERR. They may both come without POLLIN
<Regenaxer> But the other is really, really stupid!
<Regenaxer> I did
<Regenaxer> while (p->fd != fd)
<Regenaxer> ++fd;
<Regenaxer> but correct is
<Regenaxer> while (p->fd != fd)
<Regenaxer> ++p;
<Regenaxer> I.e. when searching for a pollfd structure entry, I did not increment the pointer (the searched structure array), but the file descriptor!!
<Regenaxer> It is a big wonder that *anything* worked until now
<aw-> ohhhh
<aw-> wow
<aw-> because the pointer address was the same as the fd? so it worked without you noticing
<Regenaxer> no, the pointer points to the fd entry
<Regenaxer> it points to a struct
<aw-> right
<Regenaxer> and I need to find it
<Regenaxer> by fy
<Regenaxer> fd
<aw-> well i'm glad you found the bug
<Regenaxer> yeah
<Regenaxer> thanks for the straces
<aw-> np
<Regenaxer> I tracked down fd 10
<aw-> let me know when you make a new release, i'll test it
<Regenaxer> it is the 'tell' pipe
<Regenaxer> yes
<aw-> yes i knew it was a pipe
<Regenaxer> T
<aw-> great!
<aw-> rare bug, good to find it early
<Regenaxer> yes
orivej has quit [Ping timeout: 260 seconds]
<Regenaxer> ok, released the fix
<Regenaxer> If you have time, please check
<Regenaxer> Still in the hotel?
<aw-> no no i'm home now
<Regenaxer> Good to hear
<aw-> works!
<aw-> no more CPU pinned at 100%, strace looks fine
<Regenaxer> Perfect :)
<aw-> thanks
<Regenaxer> Thank you!
razzy has quit [Quit: Connection closed]
<beneroth> Regenaxer, hihi, bad typo
<beneroth> aw-, how is the weather? all good?
<beneroth> is it over now?
<Regenaxer> hi beneroth, really stupid
<beneroth> happens
<Regenaxer> Strange that it did not go infinite loop
<Regenaxer> and *something* worked at all
<beneroth> Ada guys would say that a fd should not even have a ++ operator, I guess
<beneroth> yeah
<Regenaxer> In some context it makes sense to inc the fd
<Regenaxer> well, not much
<aw-> beneroth: good thanks, typhoon has passed now
<beneroth> Regenaxer, I guess.. special devices, embedded?
<Regenaxer> yes
<beneroth> aw-, good to hear so
<aw-> beneroth: https://a1w.ca/u/d7dcb3/ blackout chart from my UPS
<beneroth> pretty clear
<Regenaxer> yes
<Regenaxer> more than 12 h down
<Regenaxer> or all the day?
<aw-> actually my server didn't turn back on automatically haha
<aw-> power was out for "only" 12h
<Regenaxer> all Okinawa?
<aw-> no, but many parts of it
<aw-> and power is not restored everywhere yet
root has joined #picolisp
root is now known as Guest84035
root____ has quit [Ping timeout: 240 seconds]
<beneroth> Termux Android 10 issue seems to be solved: https://github.com/termux/termux-packages/wiki/Termux-and-Android-10
<beneroth> "We got suggestions from using proot as binary loader to extremelly ridiculous variants like "rewrite packages in WASM"."
<beneroth> maybe our friend? :P
<Regenaxer> Sounds good!
<Regenaxer> I have not yet tried to build PilBox with API 29. Only Penti so far
<Regenaxer> But PilBox *has* the code in the APK, so perhaps OK
<Regenaxer> Hmm
<Regenaxer> cannot invoke exec() on files within the app's home
<Regenaxer> that's what PilBox does
<beneroth> yep
<beneroth> back to turning pilbox apps into apk's, maybe :(
<Regenaxer> Must check
<Regenaxer> Forgot all details
<Regenaxer> I use copyAssets() to copy from APK to the home directory. Not sure if that is allowed
<Regenaxer> I don't understand most of it
<Regenaxer> What are "untrusted apps" in the first place?
<Regenaxer> Is PilBox untrusted?
<Regenaxer> It is checked by the Google Play Store
<beneroth> no idea
<beneroth> I guess could be that
<Regenaxer> I must try
<Regenaxer> Just build with 29
<Regenaxer> For PentiKeyboard it was a no-brainer
<Regenaxer> I just changed the number in the make script
<beneroth> penti does no exec, I guess?
<Regenaxer> right
<Regenaxer> not an issue here
<Regenaxer> If there are troubles with PilBox, I remove it from Play Store
<beneroth> meanwhile Apple is signing malware https://objective-see.com/blog/blog_0x4E.html
<Regenaxer> yeah
<beneroth> so make about the security this theater provides...
<beneroth> s/make/much
<Regenaxer> T
<beneroth> my pinephone arrived today (foss linux smartphone). running postmarketOS (linux distro, gnome) - will have to test if it is feasible as everyday device (it's a beta/community release to get more people fiddling with it)
<beneroth> I have only unpacked it so far - but it looks very nice
<Regenaxer> Cool
<beneroth> in the worst case.. let's hope that production of these (and similiar) devices gets more widespread
<Regenaxer> The problems I saw with Ubuntu Touch was that there seemed no easy way to install a custom keyboard like Penti
<Regenaxer> Gnome is the same probably
<beneroth> then instead of selling pilbox let's sell pilbox devices which can also be used as phones! ;-)
<Regenaxer> ok :)
<beneroth> oh, I will try out
<Regenaxer> It is a general problem in Linux
<Regenaxer> also on Desktop and Notebook
<Regenaxer> I had to write a kernel driver
<beneroth> I didn't have penti on my phone (too small screen for my taste), but I never was happy with the keyboards I had on android... well i was happy on my 10 year old samsung, somewhat
<beneroth> ah right
<beneroth> maybe I can develop native picolisp apps on it
<beneroth> or on the librem phone, once it arrives
<beneroth> should be less of a problem than on android
<Regenaxer> T
<beneroth> it even has an android emulator: https://wiki.postmarketos.org/wiki/Anbox
<Regenaxer> great
<tankf33der> pil21 tests passed.
<Regenaxer> Thanks!
<beneroth> thanks tankf33der :)
orivej has joined #picolisp
orivej has quit [Ping timeout: 240 seconds]
orivej has joined #picolisp
_whitelogger has joined #picolisp
orivej has quit [Ping timeout: 260 seconds]