[MDEV-24745] Fallback CRC-32C computation wrongly uses SSE4.1 instructions Created: 2021-01-31 Updated: 2021-04-19 Resolved: 2021-04-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.5.7, 10.5.8, 10.5.9 |
| Fix Version/s: | 10.5.10 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Charlie Wilder | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | crash, regression | ||
| Environment: |
Slackware Linux 5.10.11-smp #1 SMP i686 Intel(R) Xeon(TM) CPU 2.80GHz GenuineIntel GNU/Linux |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Upgrade from glibc-2.30 to glibc-2.32 and package 10.5.8 compiled against 2.30 to 10.5.8 compiled against 2.32. Now get this error when trying to start mariadb server:
|
| Comments |
| Comment by Sergei Golubchik [ 2021-01-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
this stack doesn't make sense, these functions/methods don't call each other in that order. But it kind of looks ok, it's wrong, but not completely absurd. So it's not like the stack was overwritten by some garbage. The likely use case for such an effect is a broken build. If you have built MariaDB 10.5.8 for glibc-2.30, and then later rebuilt it for 2.32 using the same build dir. And if make didn't handle the change properly and didn't rebuild some of the files — this is exactly the kind of stack you would get on such a broken binary. Try to do a clean build of 10.5.8 on a new empty build dir. The second possible (but much less likely) reason would be that the stack is correct, but the binary was so optimized, that the stack is no longer recognizable. If you could try to build 10.5.8 without optimization (-g3 -O0 or -DCMAKE_BUILD_TYPE=Debug it'll show a readable stack that could help to point where the problem is. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Charlie Wilder [ 2021-01-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The problem started when I installed updated packages from the distro site. This morning, I compiled on my system with the package buildfile and got what appeared to be the same error (my untrained I). While it was compiling, I got your message about -g3 -O0 and have since recompiled and reinstalled. It looks to be the same error. All other software on this server appears to be running properly, so I do not believe there is memory corruption. Unfortunately it take about 2 hours to compile... Here is the latest .err info: {{2021-01-31 14:15:37 0 [Note] InnoDB: Using Linux native AIO To report this bug, see https://mariadb.com/kb/en/reporting-bugs We will try our best to scrape up some info that will hopefully help Server version: 10.5.8-MariaDB-log Thread pointer: 0x0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Charlie Wilder [ 2021-01-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have found the previous distro package (mariadb-10.5.8-i586-1.txz), installed it, and all seems well. My databases check out and seem to be up to date with no errors. Because the system has been down for so long, I won't do my next test until a weekend or when a new distro package is released. Weird that it works with glibc-2.30 and not with glibc-2.32, "all else" being equal... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-02-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
cgw, the built-in stack trace reporter is often producing inaccurate stack traces. Would it be possible to start the broken server under a debugger, to get more meaningful stack traces? man 7 signal suggests to me that signal 4 is SIGILL, that is, illegal instruction. This would make it even more important to run the server in a debugger, so that we can find the problem. Some code might fail to detect the processor correctly before using an instruction that is not part of the original AMD64 ISA. How does cat /proc/cpuinfo identify the processor? If it is not feasible to start the mariadbd executable under GDB, given that you are able to compile yourself, you could add a delay right before or after the output of the message Completed initialization of buffer pool, such as os_thread_sleep(10000000); (10 seconds) that would allow you to execute gdb -p $(pgrep -x mariadbd) while the server is starting up. In GDB, I would be interested in the backtrace of the crashing thread (I guess there are not many other interesting threads at this point), as well as the output of the disassemble command for the stack frame that triggered the signal. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Charlie Wilder [ 2021-02-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
GDB is out of my depth and I have had to do recent testing on a different system so that the production system will be available. The test system is older, lesser hardware but it does result the same error. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-02-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
cgw, thank you. In screen-exchange
It seems to correspond to the following source code line in int ha_initialize_handlerton(st_plugin_int *plugin):
This is probably calling innodb_init(). The called code is likely calling something in GNU libc and hitting the illegal instruction there. I think that if you installed the debug symbols for GNU libc, then it should be possible to disassemble the interesting stack frame. On my Debian system, the package to install would be libc6-dbg. On a quick search, I did not find what it could be on Slackware. Possibly it is glibc-devel, but that one might also just correspond to Debian’s libc-dev (header files only). There might also be a trick to force GDB to disassemble code even if the start and the end of the function are not known, but I do not know it. We really need the disassembly of the deepest stack frame (and must be able to identify that function). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-02-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Note the address that failed:
If you disassemble this location you'll probably see a non Pentium 4 instruction. Look at "cat /proc/$(pidof mariadbd)/map" even while the debugger is active on this file will show you address ranges where you can point to the shared object that has the illegal instruction. Like marko indicated the libc debuginfo packages (usually separate from devel packages) will help if you have these installed before gdb is run. Taking a not verfiied web post https://www.linuxquestions.org/questions/linux-newbie-8/how-to-install-debuginfo-for-gdb-651865/ debuginfo-install glibc is needed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Charlie Wilder [ 2021-02-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here's a new stab at it. Thank you for the pointers! The system has evolved some. It is now MariaDB 10.5.9 and glibc-2.33
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Noel [ 2021-03-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Joining this bug, rather than re-opening mine (24922) Daniel I have struck this on a third machine now, where most thing including mariadb built from source, all have glibc2.33 in common, even with a fresh initial install w/no databases the same errors occur) my build is for 32bit is cmake -DCMAKE_C_FLAGS="-O2 -fPIC" -DCMAKE_CXX_FLAGS="-O2 -fPIC" -DFEATURE_SET="community" -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_LIBDIR="lib64" -DINSTALL_SBINDIR=libexec -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_MYSQLSHAREDIR=share/mysql -DINSTALL_SQLBENCHDIR="" -DINSTALL_MYSQLTESTDIR=mysql-test -DINSTALL_MANDIR=man -DINSTALL_PLUGINDIR="lib/mysql/plugin" -DINSTALL_SCRIPTDIR=bin -DINSTALL_SUPPORTFILESDIR=share/mysql -DINSTALL_MYSQLDATADIR="/var/lib/mysql" -DMYSQL_DATADIR="/var/lib/mysql" -DMYSQL_UNIX_ADDR="/var/run/mysql/mysql.sock" -DWITH_EXTRA_CHARSETS=complex -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=ON -DWITH_LIBARCHIVE=ON -DWITH_READLINE=ON -DWITH_JEMALLOC=system -DWITH_ZLIB=system -DWITH_EXTERNAL_ZLIB=ON -DWITH_SSL=system -DCONC_WITH_SSL=ON -DUSE_ARIA_FOR_TMP_TABLES=ON -DAWS_SDK_EXTERNAL_PROJECT=OFF Can you, or another team member pick a modern OS with glibc2.33 installed maybe in a VM, and try this yourselves? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Noel [ 2021-03-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
abi-compliance-checker -test results attached if it helps those who know how to read it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-03-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
cgw, if I got it correctly, the SIMD instruction
ought to be in the mariadbd executable, if I am reading the output right:
Another SIMD instruction psrlq appears to be for bit-shifing. Unfortunately, this does not provide enough clues to me to guess which function this belongs to. Can you try to find the code in the server executable or one of the libraries? Or, can you build the server with -g so that debug symbols will be included for it? A brute-force approach without debugging symbols could be
and then searching mariadbd.s for the code snippet. nobby6, the problem is that we do not have suitably old CPUs to try this on. The instructions would be valid on newer CPUs. Maybe there is some emulator that would flag an illegal instruction, but I have no experience in those. The compat_report.html | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Noel [ 2021-03-10 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
vendor_id : GenuineIntel Yes, I know its an old box, but is solid - usually, the thing is its used as a Dev box, so if stuff fails there, you can see why I'm hesitant to use it on production boxes, because it would be irresponsible of me to assume " it'll be ok" on that newer (and 64bit) platform, mariadb is the only thing that fails, all other daemons web/mail/bind - heck, even a copy of DNEWS which hasnt been updated in 15 years runs fine. So we have to assume now that mariadb is only suitable for use on later systems, or systems that dont go above glibc2.31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-03-10 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
nobby6, nobody has produced enough details to show where exactly the problem resides. Someone should debug a mariadbd that has the debugging symbols present. It looks like the problematic instruction is in the mariadbd executable and not in any dynamically linked library. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Noel [ 2021-03-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Don't know enough about it, I am not developer, I can do basic scripting in bash and perl, and if I'm lucky I wont break basic php but real code like C and what not, have not got the faintest idea I just report my finding bugs which not sure if I mentioned here or my original bug report which is closed weeks ago, that its gotta be mariadbd/glibc related, if I accidentally allow a mariadb update with the glibc2.33 build it dies, all I do is grab just the mariadbd binary from a backup from glibc2.31 build, copy it inplace and voila! mariadbd works again. The fact that everything else works fine, points to mariadbd, the bit about the CPU may be very relevant, as another slackware user reports mariadbd works but on 64bit, but they have not confirmed when i asked are they actively running database, or did they just start it and assume it works since start script falsely reports it started I once tried the insructions for running mariadb from source build dir, I followed the bits about how to fake the database dir but that didnt work and attacked the databases (luckily on my dev box), so im not game to try it on my 64bit server which is a production server, the 32bit on my dev box dying is an annoyance, but my production dying will be a nightmare | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-03-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I could easily debug it if I got remote access to some environment where the problem is repeatable. That worked for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matteo Bernardini [ 2021-04-10 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I was able to replicate the crash during "mysql_install_db --user=mysql" on a 32bit installation of slackware-current on a samsung nc10 netbook with an Atom N270 processor. Building mariadb with -DCMAKE_BUILD_TYPE=Debug and without stripping libraries/binaries (the standard package builds with "-O2 -march=i586 -mtune=i686" and does the stripping) avoids the crash. If useful, Marko, I could give you access to the environment, just contact me privately: I also installed glibc-debug libraries in /usr/lib/debug if necessary. http://ponce.cc/slackware/testing/mariadb/mysql_install_db.txt I also tried to make a full backtrace but I used gdb occasionally so I'm not sure it's useful | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ponce, thank you. Your stack trace for Thread 1 clearly identifies the problem:
This code was last refactored by wlad. ponce, can you please post the output of the following GDB command:
I suspect that the following compile time flags in mysys/CMakeLists.txt are biting us:
This is compiling the entire compilation unit with those flags. It could enable the use of instructions such as movbe, which definitely do the original Intel Pentium ISA. ponce, could you try to build an earlier revision of the code? I think that in
I think that the correct fix should be to remove those unsafe SET_SOURCE_FILES_PROPERTIES and instead add __attribute__((target("sse4.2"))) to those functions that actually need it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Matteo Bernardini [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
this is gdb log with the disassemble output http://ponce.cc/slackware/testing/mariadb/disassemble.txt I'll try to build the earlier revision and I'll post back. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I compiled it locally and verified that the code requires at least SSE 4.1, because it is using the pinsrd instruction:
The function could use even newer instructions; I only wanted some proof that the code is invalid. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ponce, thank you, your disassembly confirms that the invalid instruction is pinsrd. I think that we have all the necessary information now. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
wlad, please review my fix on bb-10.5-release and also test it with clang-cl.exe. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This should have been broken in MariaDB Server 10.5.7 by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2021-04-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
marko, could you please minimize the diff. It is foreign code, and there is no reason to fix the whitespace in it. Also, renaming files is not necessary, it does not even add to clarity. The code duplication instead of function template needs a good and large comment though. Alternatively the minimal fix could be just some GCC deoptimize pragma in ExtendImpl, such as
This is not 100% proof against malice by GCC, but will work so far. You can also extend that to x86_64 if you think it could be necessary. In terms of lines of code, and clarity, that change would be hard to beat | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
wlad, compiling generic code with target-specific flags is comparable to running with open scissors. I did try your suggested work-around, and it did not work reliably. Either the mysys_namespace::crc32c::ExtendImpl<mysys_namespace::crc32c::Slow_CRC32> would still contain SSE4.1 (or SSE4.2) instructions (without any warning being emitted by the compiler!), or mysys_namespace::crc32c::ExtendImpl<mysys_namespace::crc32c::Fast_CRC32> would no longer contain those instructions. We have past examples of that: undefined behavior gave the permission to the compiler to optimize away some code on some platforms, in There is another issue with isSSE42() and crc32_pclmul_enabled(). They were also being compiled with -msse4.2 -mpclmul, and theoretically some future compiler version could choose to make advantage of those instruction set extensions. I think that the cleanest solution is to avoid setting any target-specific flags for compiling crc32c.cc and to move the implementation of crc32_pclmul_enabled() check to that file. For the SSE4.2 but not PCLMUL accelerated CRC-32C, it is easiest to specify target attributes on the few functions that use SSE4.2 instructions. Because we support compiling MariaDB 10.5 with GCC 4.8.5, and because header files such as <nmmintrin.h> only work without file-level flags such as -msse4.2 starting with GCC 5, we need a work-around for the old GCC. To minimize the size of the work-around, it is easiest to move all -mpclmul code to a separate compilation unit. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-04-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I got a mystery failure on Windows (only) when I converted mysys/crc32/crc32_x86.c from C to C++. mariabackup (but not the server) would crash somewhere in the pclmul accelerated my_checksum(). I tested that moving the -mpclmul dependent crc32c_3way() code to a new compilation unit mysys/crc32/crc32c_amd64.cc addressed that problem. While working on this, I noticed that mysys/crc32ieee.cc is not really needed on 64-bit POWER, because there is only one implementation of my_checksum() on that platform. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-04-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
nobby6 confirms fix in |