Multi-bytecode-sets V3PlusClosures and SistaV1 broken, build issue w/ Clang 18.1.2, CRASH Squeak 5.3 #19486
So, we had a new OSVM release 2023.12, tag 202312181441. Our CI built that using Clang 17.0.6. We bundled the binary with Squeak 5.3 #19486. Things worked.
Now, I noticed that rebuilding tag 202312181441 with the current Clang 18.1.2 produces binaries that will immediately crash Squeak 5.3 #19486. Squeak 6.0 works and so does 6.1alpha.
...
Crashed in the VM thread
...
Current byte code: 224
Primitive index: 0
...
Primitive trace:
Stack backtrace:
[00007ff7c554368a] __DTOR_LIST__
+ 0x7ff6853e3fc2 in Squeak.exe
[00007ff7c66442e8] ??? + 0x0 in (null)
Smalltalk stack dump:
0000009a09fce550 I CursorWithMask(Object)>isKindOf: 00007ff7c6cf0210: a(n) CursorWithMask
0000009a09fce598 I Cursor class>currentCursor: 00007ff7c66442e8: a(n) Cursor
0000009a09fce5e0 I CursorWithMask(Cursor)>show 00007ff7c6cf0210: a(n) CursorWithMask
0000009a09fce630 I SmalltalkImage>snapshot:andQuit:withExitCode:embedded: 00007ff7c6688088: a(n) SmalltalkImage
7ff7c8c516d8 s SmalltalkImage>snapshot:andQuit:embedded: 00007ff7c6688088: a(n) SmalltalkImage
7ff7c8c52f28 s SmalltalkImage>snapshot:andQuit: 00007ff7c6688088: a(n) SmalltalkImage
7ff7c8c53098 s [] in ReleaseBuilder class>saveAndQuit 00007ff7c6657cd8: a(n) ReleaseBuilder
7ff7c8c53228 s WorldState>runStepMethodsIn: 00007ff7c6915f38: a(n) WorldState
7ff7c8c53320 s PasteUpMorph>runStepMethods 00007ff7c6734988: a(n) PasteUpMorph
7ff7c8c53490 s WorldState>doOneCycleNowFor: 00007ff7c6915f38: a(n) WorldState
7ff7c8c53548 s WorldState>doOneCycleFor: 00007ff7c6915f38: a(n) WorldState
7ff7c8c53610 s PasteUpMorph>doOneCycle 00007ff7c6734988: a(n) PasteUpMorph
7ff7c8c536c8 s [] in MorphicProject>spawnNewProcess 00007ff7c6af0f80: a(n) MorphicProject
7ff7c8c53780 s [] in BlockClosure>newProcess 00007ff7c8c53838: a(n) BlockClosure
stack page bytes 4096 available headroom 1480 minimum unused headroom 0
What is going on? I cannot rebuild tag 202312181441 with Clang 18.1.2 to then let it run Squeak 5.3 #19486. Neither 32-bit nor 64-bit. Squeak 6.0 and 6.1alpha work. I know that tag 202312181441 used to work with Squeak 5.3 ... that's why I suspect Clang here...
The Smalltalk code after start-up that seems to trigger the crash is more or less isKindOf::
Cursor normal show.
Cursor >> show
"Make the hardware's mouse cursor look like the receiver"
Cursor currentCursor: self
Cursor class >> currentCursor: aCursor
"Make the instance of cursor, aCursor, be the current cursor. Display it.
Create an error if the argument is not a Cursor."
(aCursor isKindOf: self)
ifTrue: [ "..." ]
ifFalse: [self error: 'The new cursor must be an instance of class Cursor']
Between Squeak 5.3 and 6.0, that code path did not change. We are still setting the normal Cursor after start-up, which invokes currentCursor: and then that isKindOf: check.
This means that all recent CI builds for win32x86 and win64x64 cannot be used with Squeak 5.3 ...
It would be lovely if I still had a clang17 MSYS2 at hand. But I chose to update it yesterday and now I cannot rebuild that tag with clang17 to verify my assumption...
So, can we figure out how to build tag 202312181441 with a recent Clang18+ to still work with Squeak 5.3? There might even a bug in OSVM connected to this...
Hi Marcel, I’ll take a look v soon.,,,^..^,,, (phone)On Apr 5, 2024, at 8:25 AM, Marcel Taeumel @.***> wrote: So, we had a new OSVM release 2023.12, tag 202312181441. Our CI built that using Clang 17.0.6. We bundled the binary with Squeak 5.3 #19486. Things worked. Now, I noticed that rebuilding tag 202312181441 with the current Clang 18.1.2 produces binaries that will immediately crash Squeak 5.3 #19486. Squeak 6.0 works and so does 6.1alpha. crash.dmp ... Crashed in the VM thread ... Current byte code: 224 Primitive index: 0 ... Primitive trace:
Stack backtrace: [00007ff7c554368a] DTOR_LIST
- 0x7ff6853e3fc2 in Squeak.exe [00007ff7c66442e8] ??? + 0x0 in (null)
Smalltalk stack dump: 0000009a09fce550 I CursorWithMask(Object)>isKindOf: 00007ff7c6cf0210: a(n) CursorWithMask 0000009a09fce598 I Cursor class>currentCursor: 00007ff7c66442e8: a(n) Cursor 0000009a09fce5e0 I CursorWithMask(Cursor)>show 00007ff7c6cf0210: a(n) CursorWithMask 0000009a09fce630 I SmalltalkImage>snapshot:andQuit:withExitCode:embedded: 00007ff7c6688088: a(n) SmalltalkImage 7ff7c8c516d8 s SmalltalkImage>snapshot:andQuit:embedded: 00007ff7c6688088: a(n) SmalltalkImage 7ff7c8c52f28 s SmalltalkImage>snapshot:andQuit: 00007ff7c6688088: a(n) SmalltalkImage 7ff7c8c53098 s [] in ReleaseBuilder class>saveAndQuit 00007ff7c6657cd8: a(n) ReleaseBuilder 7ff7c8c53228 s WorldState>runStepMethodsIn: 00007ff7c6915f38: a(n) WorldState 7ff7c8c53320 s PasteUpMorph>runStepMethods 00007ff7c6734988: a(n) PasteUpMorph 7ff7c8c53490 s WorldState>doOneCycleNowFor: 00007ff7c6915f38: a(n) WorldState 7ff7c8c53548 s WorldState>doOneCycleFor: 00007ff7c6915f38: a(n) WorldState 7ff7c8c53610 s PasteUpMorph>doOneCycle 00007ff7c6734988: a(n) PasteUpMorph 7ff7c8c536c8 s [] in MorphicProject>spawnNewProcess 00007ff7c6af0f80: a(n) MorphicProject 7ff7c8c53780 s [] in BlockClosure>newProcess 00007ff7c8c53838: a(n) BlockClosure
stack page bytes 4096 available headroom 1480 minimum unused headroom 0
What is going on? I cannot rebuild tag 202312181441 with Clang 18.1.2 to then let it run Squeak 5.3 #19486. Neither 32-bit nor 64-bit. Squeak 6.0 and 6.1alpha work. I know that tag 202312181441 used to work with Squeak 5.3 ... that's why I suspect Clang here... The Smalltalk code after start-up that seems to trigger the crash is more or less isKindOf:: Cursor normal show.
Cursor >> show "Make the hardware's mouse cursor look like the receiver" Cursor currentCursor: self
Cursor class >> currentCursor: aCursor "Make the instance of cursor, aCursor, be the current cursor. Display it. Create an error if the argument is not a Cursor." (aCursor isKindOf: self) ifTrue: [ "..." ] ifFalse: [self error: 'The new cursor must be an instance of class Cursor'] Between Squeak 5.3 and 6.0, that code path did not change. We are still setting the normal Cursor after start-up, which invokes currentCursor: and then that isKindOf: check.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
Fails for both squeak.cog.spur and squeak.stack.spur, but just Squeak 5.3, not 6.0 or 6.1alpha.
However: The debug build of 202312181441 using clang18 works with Squeak 5.3. So, it seems that it is not JIT related but some kind of optimization issue? I want to understand what's so different about that Squeak 5.3 image compared to 6.0.
Well, the obvious difference would be that we switched to the SistaV1 bytecode set in Squeak 6.0 but not in 5.3 (V3 w/ full closures). Hmm....
That reminds me https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/658
The crash is not necessarily related, but the fact that I got the memory leak only in some specific (old ?) image is a clue:
- Wouldn't the CursorWithMask be used rarely in modern (6.x) images?
- Couldn't we trigger the bug by forcing usage of CursorWithMask in a 6.x?
I gave some snippets in the link above, maybe we can try them...
Couldn't we trigger the bug by forcing usage of CursorWithMask in a 6.x?
I tried the following with my OSVM clang18 fast build:
- no crash: 6.0, scale factor 1.0, a CursorWithMask is directly fed to prim 101
- CRASH: 5.3, no scale factor, bigger cursor enabled, a CursorWithAlpha is fed to prim 101
I then patched out (in 5.3) that cursor-related code from the in-image snapshot method using a debug build. I will then get a CRASH at a different place: crash-nocursor.dmp
...
Crashed in the VM thread
...
Current byte code: 208
Primitive index: 0
...
Primitive trace:
SmalltalkImage>>#vmParameterAt:
SmallFloat64>>#fractionPart
SmallFloat64>>#truncated
SmalltalkImage>>#vmParameterAt:put:
Stack backtrace:
[00007ff7d427368a] __DTOR_LIST__
+ 0x7ff694113fc2 in Squeak.exe
[00007ff7d776aad8] ??? + 0x0 in (null)
Smalltalk stack dump:
0000008f359ce960 I SmalltalkImage>clearExternalObjects 00007ff7d5488058: a(n) SmalltalkImage
0000008f359ce9b0 I SmalltalkImage>snapshot:andQuit:withExitCode:embedded: 00007ff7d5488058: a(n) SmalltalkImage
7ff7d7b98948 s SmalltalkImage>snapshot:andQuit:embedded: 00007ff7d5488058: a(n) SmalltalkImage
7ff7d7ba5c50 s SmalltalkImage>snapshot:andQuit: 00007ff7d5488058: a(n) SmalltalkImage
7ff7d7ba9108 s TheWorldMenu>saveAndQuit 00007ff7d7ba5a58: a(n) TheWorldMenu
7ff7d7baa5a0 s TheWorldMenu>doMenuItem:with: 00007ff7d7ba5a58: a(n) TheWorldMenu
7ff7d7babfa8 s [] in MenuItemMorph>invokeWithEvent: 00007ff7d7b98718: a(n) MenuItemMorph
7ff7d7bac1b8 s BlockClosure>ensure: 00007ff7d7bac270: a(n) BlockClosure
7ff7d7bac510 s CursorWithMask(Cursor)>showWhile: 00007ff7d5aeffc0: a(n) CursorWithMask
...
7ff7d7bae340 s HandMorph>processEvents 00007ff7d57d9e98: a(n) HandMorph
7ff7d7bae3f8 s [] in WorldState>doOneCycleNowFor: 00007ff7d5715f08: a(n) WorldState
7ff7d7bae4b0 s Array(SequenceableCollection)>do: 00007ff7d50ae660: a(n) Array
7ff7d7bae5a0 s WorldState>handsDo: 00007ff7d5715f08: a(n) WorldState
7ff7d7bae658 s WorldState>doOneCycleNowFor: 00007ff7d5715f08: a(n) WorldState
7ff7d7bae710 s WorldState>doOneCycleFor: 00007ff7d5715f08: a(n) WorldState
7ff7d7bae7c8 s PasteUpMorph>doOneCycle 00007ff7d5534958: a(n) PasteUpMorph
7ff7d78eff08 s [] in MorphicProject>spawnNewProcess 00007ff7d58f0d30: a(n) MorphicProject
7ff7d78effc0 s [] in BlockClosure>newProcess 00007ff7d78f0078: a(n) BlockClosure
stack page bytes 4096 available headroom 1480 minimum unused headroom 0
That CursorWithMask in the stack is misleading because "use bigger cursor" was enabled and thus an instance of CursorWithAlpha was communicated to the primitive 101 ... at least when the image was snapshotted.
Here is another excerpt when I just use the keyboard shortcut to evaluate snapshot-and-quit: crash-nocursor2.dmp
...
Exception code: C00000FD
Exception addr: 00007FF7D427368A
...
Crashed in the VM thread
...
Current byte code: 208
Primitive index: 0
...
Primitive trace:
SmalltalkImage>>#vmParameterAt:
SmallFloat64>>#fractionPart
SmallFloat64>>#truncated
SmalltalkImage>>#vmParameterAt:put:
Stack backtrace:
[00007ff7d427368a] __DTOR_LIST__
+ 0x7ff694113fc2 in Squeak.exe
[00007ff7d776aab8] ??? + 0x0 in (null)
Smalltalk stack dump:
000000e3d3fce650 I SmalltalkImage>clearExternalObjects 00007ff7d5488058: a(n) SmalltalkImage
000000e3d3fce6a0 I SmalltalkImage>snapshot:andQuit:withExitCode:embedded: 00007ff7d5488058: a(n) SmalltalkImage
7ff7d7bd6758 s SmalltalkImage>snapshot:andQuit:embedded: 00007ff7d5488058: a(n) SmalltalkImage
7ff7d7bdd538 s SmalltalkImage>snapshot:andQuit: 00007ff7d5488058: a(n) SmalltalkImage
7ff7d7bde858 s UndefinedObject>DoIt 00007ff7d50898e0: a(n) UndefinedObject
...
7ff7d7be2618 s HandMorph>processEvents 00007ff7d57d9e98: a(n) HandMorph
7ff7d7be26d0 s [] in WorldState>doOneCycleNowFor: 00007ff7d5715f08: a(n) WorldState
7ff7d7be27d0 s Array(SequenceableCollection)>do: 00007ff7d50ae660: a(n) Array
7ff7d7be28c0 s WorldState>handsDo: 00007ff7d5715f08: a(n) WorldState
7ff7d7be2978 s WorldState>doOneCycleNowFor: 00007ff7d5715f08: a(n) WorldState
7ff7d7be2a30 s WorldState>doOneCycleFor: 00007ff7d5715f08: a(n) WorldState
7ff7d7be2ae8 s PasteUpMorph>doOneCycle 00007ff7d5534958: a(n) PasteUpMorph
7ff7d7be2ba0 s [] in MorphicProject>spawnNewProcess 00007ff7d58f0d30: a(n) MorphicProject
7ff7d7a8bfe0 s [] in BlockClosure>newProcess 00007ff7d7a8bfc0: a(n) BlockClosure
stack page bytes 4096 available headroom 1480 minimum unused headroom 0
I do not think that platform-specific cursor code is involved in this issue. Not that the debug build still does not crash. These recent tests involved the 64-bit squeak.cog.spur flavor and squeak.stack.spur flavor.
So, I think/conclude that:
- the issue is not related to JIT
- the issue is not related to
CursorWithMask - the issue is not related to 32-bit vs. 64-bit
⚠️ Ha! Yes, we have a regression with the "V3 plus closures" bytecode set. It is not working anymore. When I switched Squeak 5.3 to "SistaV1" via ReleaseBuilder recompileAll, the clang18 build did not crash.
Plus: It will almost immediately crash when I start switching back to "V3 plus closures" again. But only in the fast build, the debug build is fine.
The crash seems to happen during a message send. In my two examples, we had bytecode 224 and 208, which is according to the class comment of EncoderForV3:
...
208-223 1101iiii Send Literal Selector #iiii With No Arguments
224-239 1110iiii Send Literal Selector #iiii With 1 Argument
240-255 1111iiii Send Literal Selector #iiii With 2 Arguments
...
The selector with 1 argument was isKindOf: and the one with no arguments was clearExternalObjects as listed in the crash dumps.
I tried to decompile the binary to check the switch-case in interpret(). While I was not able to fully decompile that very long method/binary, I noticed that those very big fallthrough-cases seem to be handled differently. That is, in the decompilation output, I saw that case 207 was followed by case 338. As this is V3-SistaV1-mixed, this means that the cases for "literal selection no-arg/one-arg/two-arg" seemed to be represented differently. Well, SistaV1 is working so I assume that those cases are handled somewhere later in the binary/method.
In EncoderForSistaV1 we use different bytecodes for these optimized sends:
...
128-143 1000 iiii Send Literal Selector #iiii With 0 Argument
144-159 1001 iiii Send Literal Selector #iiii With 1 Arguments
160-175 1010 iiii Send Literal Selector #iiii With 2 Arguments
...
In the switch-case there is an extra +256 encoded for SistaV1 bytecodes because that build supports both bytecode sets. I assume that the C compiler tries to re-arrange cases if similar for a better performance. Hmm.... maybe some mixup triggers for a V3 bytecode a SisteV1 case? So, maybe a V3 bytecode 208 triggers Sista's "Pop and Store Temporary Variable #0" instead of the send?
I will now try to generate and compile a V3-plus-closures-only VM, which should work with Squeak 5.3. Let's see how clang18 treats those sources.
Yes, a VM with only support for V3-plus-closures works with Squeak 5.3 using clang18. Hmm....
VMMaker class >> generateSqueakSpurStack64VM
"No primitives since we can use those from the Cog VM. Patched to not include SistaV1 bytecodes."
^VMMaker
generate: StackInterpreter
with: #(ObjectMemory Spur64BitMemoryManager
FailImbalancedPrimitives false
MULTIPLEBYTECODESETS false
bytecodeTableInitializer initializeBytecodeTableForSqueakV3PlusClosures)
to: self sourceTree, '/src/spur64.stack'
platformDir: self sourceTree, '/platforms'
including: #()
How can we fix that clang18 switch-case optimization? And what is it actually? Do we cant to bisect with all clang nightly builds between clang 17.0.6 and clang 18.1.2? Uhh....
Is this really a Windows-only problem? That MSYS2/MinGW config I use?
What if instead of doing a full debug build, you turn off compiler optimizations in the production build?
Also: Does this only happen on windows builds?
What if instead of doing a full debug build, you turn off compiler optimizations in the production build?
Well, -O1 still crashes. Only -O0 works.
If -O0 works then it's either a compiler bug – or "undefined behavior" in the source code.
Do you have all warnings enabled?
Yes, -Wall is enabled. For squeak.stack.spur, I get:
153 -Wunused-but-set-variable
51 -Wchar-subscripts
48 -Wpointer-sign
47 -Wunused-value
19 -Wshift-negative-value
11 -Wpointer-to-int-cast
8 -Wincompatible-pointer-types-discards-qualifiers
8 -Wincompatible-pointer-types
7 -Wsometimes-uninitialized
6 -Wmisleading-indentation
5 -Wparentheses
5 -Wvoid-pointer-to-int-cast
2 -Wmacro-redefined
2 -Wreturn-type
1 -Wself-assign
1 -Wextern-initializer
1 -Wincompatible-library-redeclaration
1 -Wlogical-op-parentheses
1 -Wdll-attribute-on-redeclaration
1 -Wdangling-else
And here grouped by file:
spur64.stack/gcc3x-interp.c
90 -Wunused-but-set-variable
12 -Wunused-value
2 -Wpointer-sign
1 -Wself-assign
1 -Wincompatible-pointer-types-discards-qualifiers
vm/sqAssert.h
1 -Wdll-attribute-on-redeclaration
vm/sqExternalSemaphores.c
1 -Wunused-but-set-variable
vm/sqWin32Backtrace.c
1 -Wmisleading-indentation
1 -Wunused-but-set-variable
1 -Wunused-value
vm/sqWin32DirectInput.c
1 -Wmacro-redefined
vm/sqWin32GUID.c
1 -Wmacro-redefined
vm/sqWin32SpurAlloc.c
1 -Wpointer-sign
vm/sqWin32Window.c
1 -Wunused-but-set-variable
ADPCMCodecPlugin/ADPCMCodecPlugin.c
2 -Wunused-but-set-variable
B2DPlugin/B2DPlugin.c
14 -Wunused-value
B3DAcceleratorPlugin/sqWin32D3D.c
1 -Wunused-but-set-variable
BitBltPlugin/BitBltPlugin.c
5 -Wunused-but-set-variable
5 -Wunused-value
DropPlugin/sqWin32Drop.c
1 -Wparentheses
1 -Wextern-initializer
1 -Wmisleading-indentation
FileAttributesPlugin/FileAttributesPlugin.c
5 -Wunused-but-set-variable
FileDialogPlugin/sqWin32FileDialog.c
6 -Wincompatible-pointer-types-discards-qualifiers
1 -Wincompatible-pointer-types
FilePlugin/sqWin32FilePrims.c
8 -Wpointer-sign
IA32ABI/dax64win64business.h
3 -Wunused-but-set-variable
JPEGReadWriter2Plugin/jdhuff.c
15 -Wshift-negative-value
MIDIPlugin/sqWin32MIDI.c
7 -Wpointer-sign
4 -Wunused-value
1 -Wunused-but-set-variable
RePlugin/study.c
1 -Wunused-but-set-variable
SocketPlugin/sqWin32NewNet.c
2 -Wpointer-sign
1 -Wunused-but-set-variable
SoundCodecPrims/sqSoundCodecPluginBasicPrims.c
4 -Wshift-negative-value
SoundPlugin/sqWin32Sound.c
2 -Wpointer-to-int-cast
2 -Wincompatible-pointer-types
Squeak3D/Squeak3D.c
2 -Wunused-but-set-variable
2 -Wsometimes-uninitialized
Squeak3D/b3dDraw.c
3 -Wunused-but-set-variable
Squeak3D/b3dMain.c
5 -Wsometimes-uninitialized
Squeak3D/b3dRemap.c
5 -Wpointer-to-int-cast
5 -Wvoid-pointer-to-int-cast
SqueakFFIPrims/X64Win64FFIPlugin.c
51 -Wchar-subscripts
8 -Wunused-value
SqueakSSL/sqWin32SSL.c
2 -Wparentheses
1 -Wpointer-sign
SurfacePlugin/SurfacePlugin.c
1 -Wunused-value
VectorEnginePlugin/VectorEnginePlugin.c
23 -Wpointer-sign
Win32OSProcessPlugin/Win32OSProcessPlugin.c
4 -Wincompatible-pointer-types
2 -Wunused-value
1 -Wunused-but-set-variable
1 -Wincompatible-pointer-types-discards-qualifiers
audio/header.c
1 -Wunused-but-set-variable
audio/layer2.c
1 -Wparentheses
1 -Wmisleading-indentation
libmpeg/changesForSqueak.c
2 -Wunused-but-set-variable
1 -Wincompatible-library-redeclaration
1 -Wincompatible-pointer-types
1 -Wreturn-type
libmpeg/libmpeg3.c
1 -Wreturn-type
libmpeg/mpeg3demux.c
3 -Wunused-but-set-variable
3 -Wmisleading-indentation
1 -Wparentheses
libmpeg/mpeg3io.c
3 -Wpointer-sign
1 -Wdangling-else
libmpeg/mpeg3title.c
1 -Wpointer-sign
video/getpicture.c
2 -Wunused-but-set-variable
video/headers.c
26 -Wunused-but-set-variable
1 -Wlogical-op-parentheses
video/output.c
4 -Wpointer-to-int-cast
1 -Wunused-but-set-variable
I parsed LOGF with the following regular expression:
^.*/(.*?/.*?[ch]):\d*:\d*: warning: .*\[(.*?)\]
After filtering the two groups, putting the resulting lines into the clipboard, I used Squeak to aggregate:
| warnings dict |
warnings := (Clipboard clipboardText lines collect: [:line | line asString findTokens]).
dict := Dictionary new.
warnings do: [:ea | (dict at: ea first ifAbsentPut: [Bag new]) add: ea second].
Clipboard clipboardText: (String streamContents: [:s |
dict keysSortedSafely do: [:key |
s crlf; nextPutAll: key.
(dict at: key) sortedCounts do: [:ea | s crlf; tab; nextPutAll: ea key asString; tab; nextPutAll: ea value]] ]).
For the simpler, ungrouped aggregation of warnings, I used the following regular expression:
warning: .*\[(.*?)\]
And aggregated that single group of warnings in Squeak:
| warnings |
warnings := (Clipboard clipboardText lines collect: #asString) asBag.
Clipboard clipboardText: (String streamContents: [:s |
warnings sortedCounts do: [:ea |
s crlf; nextPutAll: ea key asString; tab; nextPutAll: ea value]]).
Here are the numbers for squeak.cog.spur without the plugins:
spur64.cog/cogitX64WIN64.c
752 -Wunused-but-set-variable
30 -Wunused-value
3 -Wpointer-to-int-cast
2 -Wsometimes-uninitialized
spur64.cog/gcc3x-cointerp.c
107 -Wunused-but-set-variable
79 -Wunused-value
3 -Wincompatible-pointer-types-discards-qualifiers
2 -Wpointer-sign
1 -Wself-assign
vm/sqAssert.h
1 -Wdll-attribute-on-redeclaration
vm/sqExternalSemaphores.c
1 -Wunused-but-set-variable
vm/sqWin32Backtrace.c
1 -Wmisleading-indentation
1 -Wunused-but-set-variable
1 -Wunused-value
vm/sqWin32DirectInput.c
1 -Wmacro-redefined
vm/sqWin32GUID.c
1 -Wmacro-redefined
vm/sqWin32SpurAlloc.c
2 -Wpointer-sign
vm/sqWin32Window.c
1 -Wunused-but-set-variable
The big switch-case statement (and the interpret() function) is in gcc3x-interp.c or gcc3x-cointerp.c.
Only two warnings are in the interpret() function (lines 2493 to 12984):
../../../src/spur64.stack/gcc3x-interp.c:5623:12: warning: variable 'rcvr' set but not used [-Wunused-but-set-variable]
../../../src/spur64.stack/gcc3x-interp.c:5804:68: warning: left operand of comma operator has no effect [-Wunused-value]
The fall-throughs that seem to be wrongly optimized look like this (note the overlap between V3 and SistaV1 bytecodes):
...
BREAK;
CASE(208)
CASE(209)
CASE(210)
CASE(211)
CASE(212)
CASE(213)
CASE(214)
CASE(215)
CASE(216)
CASE(217)
CASE(218)
CASE(219)
CASE(220)
CASE(221)
CASE(222)
CASE(223)
CASE(384) /*128*/
CASE(385) /*129*/
CASE(386) /*130*/
CASE(387) /*131*/
CASE(388) /*132*/
CASE(389) /*133*/
CASE(390) /*134*/
CASE(391) /*135*/
CASE(392) /*136*/
CASE(393) /*137*/
CASE(394) /*138*/
CASE(395) /*139*/
CASE(396) /*140*/
CASE(397) /*141*/
CASE(398) /*142*/
CASE(399) /*143*/
/* sendLiteralSelector0ArgsBytecode */
{
...
We figured out that the macro behind CASE is unrelated to the issue. Just using -O0 will fix it. -O1 and -O2 corrupt these cases somehow...
This probably affects primarily Windows builds at this point because:
- most recent macOS Xcode 15.x.x comes with clang 15.x.x
- GitHub Actions Ubuntu runners come with clang 10.x.x to 15.x.x, depending on the runner version
- GitHub Actions Windows runners come with clang 16.x.x or 17.x.x, depending on the runner version BUT we use MSYS2 and its own package managemant which defaults to the most recent packages, which is clang 18.1.2 in our case
So, local builds on an up-to-date Ubuntu system could also be affected. Well, there might be a way to get more recent clang versions onto macOS outside Xcode. Not sure if this is intended.
The llvm-dev folks really like https://godbolt.org to reproduce different behavior across compiler versions (e.g. https://groups.google.com/g/llvm-dev/c/_r0D3AkyXFg)
Probably that means we would have to extract the function into a standalone test case
On Wed, Apr 10, 2024 at 2:12 AM Marcel Taeumel @.***> wrote:
Only two warnings are in the interpret() function (lines 2493 to 12984):
../../../src/spur64.stack/gcc3x-interp.c:5623:12: warning: variable 'rcvr' set but not used [-Wunused-but-set-variable] ../../../src/spur64.stack/gcc3x-interp.c:5804:68: warning: left operand of comma operator has no effect [-Wunused-value]
The fall-throughs that seem to be wrongly optimized look like this (note the overlap between V3 and SistaV1 bytecodes):
... BREAK; CASE(208) CASE(209) CASE(210) CASE(211) CASE(212) CASE(213) CASE(214) CASE(215) CASE(216) CASE(217) CASE(218) CASE(219) CASE(220) CASE(221) CASE(222) CASE(223) CASE(384) /128/ CASE(385) /129/ CASE(386) /130/ CASE(387) /131/ CASE(388) /132/ CASE(389) /133/ CASE(390) /134/ CASE(391) /135/ CASE(392) /136/ CASE(393) /137/ CASE(394) /138/ CASE(395) /139/ CASE(396) /140/ CASE(397) /141/ CASE(398) /142/ CASE(399) /143/ /* sendLiteralSelector0ArgsBytecode */ { ...
We figured out that the macro behind CASE is unrelated to the issue. Just using -O0 will fix it. -O1 and -O2 corrupt these cases somehow...
The thing to do is find out which version of the compiler introduces the bug and a) compile with the version before, and b) report the bug to the compiler maintainers
,,,^..^,,, best, Eliot