02:00
chexum has quit [Remote host closed the connection]
02:00
chexum has joined #picolisp
02:47
chexum has quit [Remote host closed the connection]
02:47
chexum has joined #picolisp
05:21
<
tankf33der >
morning
05:21
<
tankf33der >
checked llvm15-19. the same.
05:31
<
tankf33der >
installed debian on ppc64le. will try.
05:37
<
tankf33der >
debian the same.
05:57
rob_w has joined #picolisp
06:31
<
abu[7] >
Sorry tankf33der, I did not look here yesterday any more
06:32
<
abu[7] >
Must be something special in the PPC ABI
06:33
<
tankf33der >
I checked ppc64le port of llvm-nightly. Not available.
06:33
<
tankf33der >
Latest 19.1.7 also failed.
06:35
<
abu[7] >
Something in the PPC architecture does not map to the LLVM model of PicoLisp
06:35
<
abu[7] >
Pil64 worked though
06:38
<
abu[7] >
I'll check what src64/arch/ppc64* did
06:39
<
abu[7] >
It also used little endian
06:39
<
tankf33der >
I will post list of available cpu festures of llc asap
07:03
<
tankf33der >
I came up with an idea to write a script that will check the work of the LLC for each feature to identify or rule out that the issue lies in the LLC.
07:05
<
abu[7] >
I think it must be something with the stack, speciality of coroutines
07:07
<
abu[7] >
many options
07:08
<
abu[7] >
I think we should first find out
*where* exactly it crashes in 'co'
07:09
<
tankf33der >
on x64 platform it always returned correct addresses and symbols
07:09
<
tankf33der >
here i never seen ones
07:09
<
abu[7] >
who is "it"?
07:14
<
tankf33der >
picolisp binary
07:14
<
tankf33der >
in gdb
07:15
<
abu[7] >
"-g" or so at compile time?
07:16
<
tankf33der >
of course i tried
07:16
<
tankf33der >
and no omit pointers
07:17
<
tankf33der >
i always seen question marks in gdb
07:18
<
tankf33der >
and strip ommited
07:18
<
abu[7] >
yeah, no symbols
07:25
<
tankf33der >
trying debian's gdb
07:26
<
tankf33der >
the same
07:42
<
tankf33der >
llvm14 the same
07:54
<
tankf33der >
probably problem with gdb becase i am inside docker+qemu under x64 machine
07:54
<
tankf33der >
this is not a real hardware
08:43
<
tankf33der >
i give up
08:45
<
abu[7] >
How about inserting 'dbg' calls into 'co'? That's how I debug PilSrc code, I never used gdb
08:45
<
tankf33der >
provide steps
08:45
<
tankf33der >
i do not remember details
08:46
<
abu[7] >
OK, let me prepare
08:46
<
abu[7] >
It fails with (co 'a 7) ?
08:47
<
abu[7] >
kind of minimal co
09:00
<
tankf33der >
trying
09:00
<
abu[7] >
Then compile and do
09:01
<
abu[7] >
: (co 'a 7)
09:04
<
tankf33der >
# ../bin/picolisp
09:04
<
tankf33der >
: (co 'a 7)
09:04
<
tankf33der >
Segmentation fault (core dumped)
09:06
<
abu[7] >
So it crashes in (let Main: (coroutine
09:06
<
abu[7] >
Earlier than I expected ;)
09:11
<
tankf33der >
root@0e3b70296297:~/pil21/src# ../bin/picolisp
09:11
<
tankf33der >
: (co 'a 7)
09:11
<
tankf33der >
Segmentation fault (core dumped)
09:12
<
abu[7] >
So it is (memset ..)
09:14
<
abu[7] >
thinking ...
09:17
<
taleon >
Is it possible to analyze the core dump with ktrace or other utilities?
09:18
<
abu[7] >
Hi taleon!
09:18
<
abu[7] >
ktrace tracks system calls only?
09:19
<
taleon >
ktrace /usr/bin/pil
09:19
<
tankf33der >
root@0e3b70296297:~/pil21/src# ../bin/picolisp
09:19
<
tankf33der >
: (co 'a 7)
09:19
<
tankf33der >
Segmentation fault (core dumped)
09:19
<
taleon >
kdump -f ktrace.out > pil.kdump
09:20
<
taleon >
You can then analyze the kdump with a text editor.
09:20
<
abu[7] >
ok, (stack) on the same address works
09:21
<
abu[7] >
taleon, does it track machine instructions?
09:21
<
taleon >
Not sure if ktrace only tracks system calls. I used it to find and fix Branch Target Identification (BTI).
09:22
<
abu[7] >
tankf33der, now change (stack Stk) to (stack (- Stk 10000))
09:22
<
abu[7] >
ie. try to actually decrement the stack pointer
09:23
<
abu[7] >
We now have (dbg 1 $T) (stack (- Stk 10000)) (dbg 2 0)
09:23
<
tankf33der >
root@0e3b70296297:~/pil21/src# ../bin/picolisp
09:23
<
tankf33der >
: (co 'a 7)
09:23
<
tankf33der >
Segmentation fault (core dumped)
09:24
<
abu[7] >
decrement works
09:24
<
abu[7] >
so it is indeed the memset
09:24
<
tankf33der >
afk in 30min
09:27
<
abu[7] >
Seems we are not allowed to write into the allocated stack segment
09:28
<
abu[7] >
not yet allocated
09:29
<
abu[7] >
it is
*below* current SP
09:29
<
abu[7] >
this may be illegal
09:30
<
abu[7] >
no, I'm wrong
09:30
<
abu[7] >
(stack (ofs Stk (- Siz))) temporarily decrements SP
09:30
<
abu[7] >
should be legal
09:31
<
abu[7] >
Let me think more and continue when tankf33der is back
10:31
<
abu[7] >
tankf33der: When back, please post the file @src/picolisp.s which was generated in our last test
10:35
<
abu[7] >
to see how exactly the stack is manipulated on PPC
10:35
<
tankf33der >
thinking how to cut file from image
10:37
<
tankf33der >
i am in docker+qemu
10:39
<
abu[7] >
pb1n from qemu?
10:41
<
tankf33der >
256KB file protection on pb1n,
10:41
<
tankf33der >
256KB file protection on pb1n
10:41
<
abu[7] >
hmm, then just a part of the file
10:41
<
abu[7] >
Search for ^_Co
10:42
<
abu[7] >
this is the start of 'co'
10:44
<
abu[7] >
Looks good!
10:44
<
tankf33der >
this is from alpine linux with configured ip
10:49
<
tankf33der >
meeting after 15min. maybe delays
10:49
<
abu[7] >
I investigate
10:50
<
abu[7] >
stack pointer is register 1 on ppc
11:01
<
abu[7] >
I think I found the problematic point
11:01
<
abu[7] >
It is "ld 3, 0(1)"
11:02
<
abu[7] >
PPC uses the top of stack for temp storame
11:02
<
abu[7] >
We can try a workaround later
11:12
<
abu[7] >
a safety space of 8 bytes perhaps
11:22
rob_w has quit [Remote host closed the connection]
12:34
<
abu[7] >
There are 3 places
12:35
<
tankf33der >
all from co
12:35
<
abu[7] >
2 from co, one in 'stack'
12:41
<
tankf33der >
At this pace, and while you're warmed up, maybe you'll want to look into the issues with s390x afterward? :)
12:43
<
abu[7] >
ok, let's see
13:01
<
abu[7] >
I think I have a fix
13:02
<
abu[7] >
I reserve a safety space of 8 bytes on the stack
13:02
<
abu[7] >
not needed for x86 or Arm etc
13:03
<
abu[7] >
But who knows if other CPUs also have that issue?
13:03
<
tankf33der >
i can test as wide as possible
13:04
<
tankf33der >
now picolisp works on alpine: aarch64, loongarch64, x86_64
13:04
<
tankf33der >
ppc64le-s390x-riscv64 is the queue
13:04
<
abu[7] >
I made a temporary release:
13:05
<
abu[7] >
app@7fach.de:pub/pil21.tgz
13:05
<
abu[7] >
Can you try that?
13:05
<
tankf33der >
is that maxtrix ?
13:05
<
taleon >
Well done and very good. :-)
13:06
<
abu[7] >
taleon, not sure yet :)
13:06
<
abu[7] >
It is my comany's server
13:06
<
abu[7] >
same as picolisp.com btw
13:06
<
tankf33der >
abu[7]: how to get this?
13:07
<
abu[7] >
so you can use app@picolisp.com/pub/pil21.tgz
13:07
<
abu[7] >
curl -O app@picolisp.com/pub/pil21.tgz
13:07
<
tankf33der >
ok. works.
13:09
<
taleon >
I even still have a Lemote Yeeloong 8101B with loongson architecture. Not sure if that's loongarch64, though.
13:09
<
abu[7] >
never heard of
13:10
<
tankf33der >
abu[7]: crashed
13:10
<
tankf33der >
on (co 'a 7)
13:11
<
tankf33der >
i can send you a .s file
13:12
<
abu[7] >
the old one is ok
13:13
<
abu[7] >
can you change (stack (- Lim 8)) in line 1211 ?
13:13
<
abu[7] >
8 to perhaps 32 ?
13:14
<
tankf33der >
what file ?
13:14
<
abu[7] >
Same in line 1150
13:14
<
abu[7] >
@src/flow.l
13:15
<
tankf33der >
works.
13:15
<
abu[7] >
But still I think 8 should be enough
13:15
<
tankf33der >
complex examples failed without crash
13:16
<
abu[7] >
What if you use 16
13:17
<
tankf33der >
on (co 'a 7)
13:18
<
abu[7] >
Let's continue later, I must go now
13:18
<
abu[7] >
I think more about it
13:18
<
abu[7] >
Thanks so far!
14:09
<
abu[7] >
Forget the above version. I did not yet understand the issue
14:09
<
abu[7] >
ppc is picky about the stack
14:10
<
abu[7] >
It does not notice that it just set the stack to another value
14:11
<
abu[7] >
I must study PPC (again after many years)
14:29
<
tankf33der >
No hurry. Should be easy for you then
14:33
<
abu[7] >
Not at all
14:34
<
abu[7] >
perhaps unsolvable
14:34
<
abu[7] >
if we don't find a way to stop ppc doing that
14:50
<
tankf33der >
stack align is 16 bytes. right ?
15:13
<
tankf33der >
to stop llvm doing what on ppc ?
15:15
<
abu[7] >
Not surs, 8 byte align would be ok
15:15
<
abu[7] >
PilStc controls it
15:15
<
tankf33der >
LLM sais stack align is 16
15:15
<
tankf33der >
i checked in two different models
15:17
<
abu[7] >
But the problem is that LLVM on PPC doen not handle changed stack pointer correctly, it seems
15:17
<
abu[7] >
I just came home
15:18
<
abu[7] >
searching the web
15:23
<
tankf33der >
clang --help | grep stack
15:26
<
abu[7] >
Most options are not clear to me
15:26
<
tankf33der >
the same
15:31
<
abu[7] >
Google did not help
15:33
<
tankf33der >
chatgpt ?
15:33
<
abu[7] >
I use Perplexity
15:34
<
abu[7] >
but hard to find the precise question
15:34
<
tankf33der >
what did you search ?
15:34
<
abu[7] >
LLVM PowerPC stackrestore
15:35
<
abu[7] >
stackrestore is the llvm-ir instruction
15:35
<
abu[7] >
But I still don't understand what
*exactly* is wrog
15:36
<
abu[7] >
in your .s file it writes to and reads from 0(1)
15:36
beneroth has joined #picolisp
15:36
<
abu[7] >
1 is the stack pointer
15:37
<
abu[7] >
ld 3, 0(1) mr 1, 21 std 3, 0(1)
15:37
<
abu[7] >
makes no sense to me
15:38
<
abu[7] >
mr 1, 21 changes the SP
15:38
<
abu[7] >
But why does it write to that location?
15:38
<
abu[7] >
It is overwritten then by memset
15:39
<
abu[7] >
I don't know what exactly to ask
15:41
<
tankf33der >
#ppc64 ?
15:42
<
tankf33der >
it exists
15:43
<
abu[7] >
No precise question
15:52
<
abu[7] >
revert the change
16:00
<
bjorkintosh >
tankf33der: what system is using ppc?
16:00
<
tankf33der >
ibm power8-10
16:00
<
bjorkintosh >
interesante.
16:00
<
bjorkintosh >
how did you get it?
16:00
<
tankf33der >
in docker+qemu :)
16:01
<
bjorkintosh >
ah. so it's a for exercising picolisp then?
16:01
<
tankf33der >
but i have several power7-8 in data room
17:11
<
abu[7] >
Now I asked Perplexity
17:12
<
bjorkintosh >
are you more perplexed?
17:13
<
abu[7] >
To my surprise not
17:13
<
abu[7] >
gave a reasonable answer
17:13
<
abu[7] >
I dig into it
17:25
<
bjorkintosh >
picolisp is safe.
17:46
<
tankf33der >
Ask him github issue number
17:48
<
abu[7] >
It did not give a link to an issue
17:49
<
abu[7] >
Above I inserted only the first two links
17:51
<
abu[7] >
This is the whole query:
17:53
<
abu[7] >
The proposed solutions seem all to involve fixing the LLVM/PowerPC backend code (.cpp stuff)
17:54
<
abu[7] >
I give up ;)
17:54
<
tankf33der >
Sad alpine have no llvm-next ports
17:54
<
abu[7] >
What is llvm-next ?
18:04
<
tankf33der >
every system have their own name systems
18:04
<
tankf33der >
some named llvm-devel
18:04
<
tankf33der >
nightly snapshots of llvm
18:04
<
tankf33der >
some llvm20 or llvm-20
18:05
<
tankf33der >
let me check ppc issues on github
18:06
<
abu[7] >
understand
18:07
<
tankf33der >
88 opened, reading
18:08
<
tankf33der >
with text 'stack' in subject 18 issues
18:08
<
tankf33der >
from 88
18:09
<
abu[7] >
Problem is llvm.stackrestore() I think
18:11
<
abu[7] >
Yeah, a very exotic problem
18:11
<
abu[7] >
Most langs don't use it
18:12
<
abu[7] >
I need for coroutines
18:12
<
abu[7] >
but which langs have coroutines?
18:14
<
tankf33der >
i very wanted repeat chacha20 stress test like i did in picolisp, but did find languages with such a features picolisp has
18:20
<
tankf33der >
abu[7]: check this one
18:21
<
abu[7] >
grr, I hate github! "gzip: stdin: not in gzip format" in w3m
18:22
<
abu[7] >
... viewing in PilBox then
18:22
<
tankf33der >
thank you.
18:22
<
tankf33der >
if this is it, then i will subscribe and update picolisp port in alpine
18:23
<
abu[7] >
Since today also Google search doesn't work in w3m any more
18:24
<
abu[7] >
I saw this one too this afternoon
18:24
<
abu[7] >
but a different problem
18:25
<
abu[7] >
At least no llvm.stackrestore()
18:26
<
tankf33der >
hard to open new issue then
18:27
<
tankf33der >
what if you write small llvm-ir code and it will be wrong, just for example
18:27
<
abu[7] >
Hard to say what is really wrong
18:29
<
abu[7] >
I'm not sure if we can say it is wrong if something is written above the stack pointer
18:30
<
abu[7] >
I
*believe* it is wrong if just setting the SP triggers a
*write* to this location
18:30
<
abu[7] >
yeah, must be wrong
18:31
<
abu[7] >
as far as I understood APIs until now
18:33
<
tankf33der >
the simplest
18:35
<
abu[7] >
quite simple, doen not need two arrays
18:36
<
abu[7] >
Optimized away?
18:37
<
tankf33der >
llc errcode.ll -o errcode.s
18:37
<
tankf33der >
unknown.
18:37
<
abu[7] >
stackrestore is something like "mr 1, 3"
18:37
<
abu[7] >
move to register 1
18:38
<
abu[7] >
Not in the .s
18:39
<
abu[7] >
stackrestore at the end of a fun is a no-op
18:39
<
abu[7] >
thus removed
18:41
<
tankf33der >
i opening llvm issue
18:41
<
tankf33der >
fingers crossed
18:43
<
tankf33der >
what if remove std line from picolisp.s
18:43
<
tankf33der >
is it possible?
18:44
<
abu[7] >
Basically yes, but the code stores a value there, which is then lost
18:44
<
abu[7] >
I think the code wants to store in the original stack frame
18:44
<
abu[7] >
but SP changed
18:45
<
abu[7] >
is there by default a frame pointer omitted?
18:45
<
tankf33der >
unknown
18:45
<
tankf33der >
i tried a lot of parametrs
18:46
<
abu[7] >
gcc had something like --omit-frame-ptr
18:46
<
abu[7] >
if frame pointers are omitted, all is done via stack pointer
18:47
<
tankf33der >
clang has:
18:47
<
tankf33der >
-fomit-frame-pointer Omit the frame pointer from functions that don't need it.
18:47
<
abu[7] >
This could be a fix (though it is still a bug)
18:47
<
abu[7] >
can we disable -fomit-frame-pointer ?
18:48
<
tankf33der >
crashed
18:48
<
abu[7] >
we need the opposite
18:48
<
abu[7] >
ieg -fuse-frame-pointer
18:49
<
tankf33der >
clang -O0 -fno-omit-frame-pointer ...
18:49
<
tankf33der >
crashed
18:49
<
abu[7] >
Probably using
*not* -fomit-frame-pointer does this
18:50
<
tankf33der >
picolisp.s
18:50
<
abu[7] >
Not sure, something is wrong anyway
18:50
<
tankf33der >
check again if possible remove std line
18:52
<
abu[7] >
std 5, 0(1)
18:52
<
abu[7] >
still has it
18:55
<
tankf33der >
i do not have this line
18:55
<
abu[7] >
search ^_Co:
18:56
<
abu[7] >
then "memset"
18:56
<
abu[7] >
the lines before memset
18:57
<
abu[7] >
line 33454/103537 in your pb1n
19:03
<
tankf33der >
removed std line and crashed
19:03
<
abu[7] >
you can't remove
19:04
<
abu[7] >
the value is
*read* back later
19:04
<
abu[7] >
That's why we had a pointer 070707070707
19:04
<
abu[7] >
your first error report
19:05
<
abu[7] >
memset writes 070707070707 into the whole stack frame
19:05
<
abu[7] >
And std stored something
19:06
<
abu[7] >
which is later retrieved but destroyed
19:08
<
abu[7] >
The std
*wants* to write to the original sp
19:08
<
abu[7] >
but sp changed
19:08
<
abu[7] >
so the write goes wrong
19:09
<
abu[7] >
IMHO the LLVM backend doen not notice that it just changed SP
19:10
<
abu[7] >
s/doen/does
19:15
<
abu[7] >
Let's hope there is somebody who understands it
19:17
<
abu[7] >
Nuff for today
19:17
<
abu[7] >
Thanks for all the input!
20:10
knlb has joined #picolisp
21:02
knlb has quit [Remote host closed the connection]
21:52
Serj-Aleks has joined #picolisp
21:54
Serj-Aleks has quit [Client Quit]