uuuurgtag:gruntthepeon.free.fr,2024:/blog/index.php/2023-12-07T18:21:00+01:00DotCleardaily12023-12-07T18:21:00+01:00Hommage à Octave2023-12-07T18:21:00+01:00tag:gruntthepeon.free.fr,2023-12-07:/blog/83zogzogJ'ai récemment ré-essayé Octave, suite a un coup de yenamarre de Matlab : leur politique tarifaire est ridicule , quand on veut mettre à jour un matlab 2017 vers matlab 2023 , ils font payer 1000 euros par année de différence au lieu d'une somme fixe forfaitaire. Matlab passe son temps à... <p>J'ai récemment ré-essayé Octave, suite a un coup de yenamarre de Matlab : leur politique tarifaire est ridicule , quand on veut mettre à jour un matlab 2017 vers matlab 2023 , ils font payer 1000 euros par année de différence au lieu d'une somme fixe forfaitaire. Matlab passe son temps à buguer après chaque update de macOS donc c'est très difficile de continuer à travailler sur une vieille version quand on est macqueux. Avec Sonoma ça a été un vrai festival. Donc ras-le-bol de matlab, ras-le-bol des commerciaux Mathworks qui refusent de faire la moindre ristourne pour les bons clients, et ras-le-bol de la lourdeur de matlab (y'a besoin d'une jvm et c'est d'ailleurs pour cette raison qu'il passe son temps à merdouiller/cesser de fonctionner sur macOS).</p>
<p>Du coup Octave, ben ça marche pas mal du tout en 2023. La rapidité est tout à fait honorable sur un mac récent, et l'IDE qui reprend grosso modo celui de matlab est en Qt et est tout à fait fonctionnel : éditeur, debuggeur, inspecteur de variables, plots, etc. Donc thumb up pour octave et fuck you pour matlab.</p>Not happy2023-08-29T14:33:16+02:00tag:gruntthepeon.free.fr,2023-08-29:/blog/82zogzogDid you know that signing Windows binaries has gotten a lot more fun since june 2023 ? It was already a great experience, but not on the same scale as today.
So, up to june 2023, in order to sign windows binaries, you had to choose between buying:
an OV certificate, cheaper and easier... <p>Did you know that signing Windows binaries has gotten a lot more fun since june 2023 ? It was already a great experience, but not on the same scale as today.</p>
<p>So, up to june 2023, in order to sign windows binaries, you had to choose between buying:</p>
<ul>
<li>an OV certificate, cheaper and easier validation. You pay, you get a phone call for identify verification, and at the end of the process you receive a pkcs12 certificate file. You can copy this file on any computer, it is pretty easy to integrate it in you build servers etc. Life is relatively easy as long as the correct phone number is listed in the phone registry that matters to the company issuing the certificates (in my case it was not..).</li>
</ul>
<p>Drawback of the OV certificate: Microsoft does not trust you by default, so the first people that will download your signed executables will received a pretty scary warning from Windows Defender SmartScreen, telling them that they most likely have downloaded malware and they should erase it ASAP. Thank you MS, I'm glad I paid $700 for such a great service. After a few days/downloads, the warning is gone as MS now thinks your identity is trustworthy. Until.. 3 years later, when you renew the certificate, and all your earned "trust" is gone.</p>
<ul>
<li>an EV certificate, a bit more expensive, with deeper verification (no sure what), and instead of a pkcs12 file, you get a shiny USB key that must be plugged in the computer doing the signing. You are immediately trusted by Microsoft, none of your users will be scared by the SmartScreen malware alert, but having to deal with a physical token instead of a simple file is such a headache that I have always preferred the OV certificate.</li>
</ul>
<p>So, on 27 may 2023, I decided to renew our previous OV certificate which was about to expire. The provider I use is Sectigo. I could have been one of the last people on earth to receive a 3-years valid PKCS12 OV Certificate file, but no, what I got was a massive delay, and then a stupid SafeNet USB key that must be plugged when signing a file.</p>
<p>Why did this change ? Apparently there are these guys, named the 'CA/Browser forum', who have decided that handing a pkcs12 file to the user was not secure enough and that it was much more fun to make their life miserable by mailing them a stupid USB dongle.</p>
<p>How miserable ? Well quite a lot, indeed. You get a small USB key, and some software (from Thalès, mind you), the "SafeNet Authentification Client", that must be running when signing files. When you launch it, you get a screen with buttons such as "Change Token Password", "Unlock Tocken" etc. But, you cannot unlock the token because you do not have its password, the company that sold you the USB dongle is not giving you the token password. You can have a look at what is inside the token, and find that there is indeed a certificate at your name. You can only export its public key, not the private part. When signing, the SafeNet software will prompt you for a password. That is not the token admin password, but a "PIN" specific to the certificate. This one you can change.</p>
<p>So, by default, EACH time you sign a file, you get that dialog box from the SafeNet Authentification Client that asks you for the PIN of the certificate. EACH time. But that's not all, if you enter the wrong PIN 3 times, then you just bricked your dongle. This happens really quick... you type too fast once, the second time fails and then you realize your keyboard has switched to qwerty, and now you're already at your last chance then you start to sweat for the last chance) (according to what Sectigo told me, they can un-brick the dongle, so it is not completely bricked, but it is still a massive loss of time).</p>
<p>There is a setting in SafeNet to control the number of tries, but it cannot be changed by me, the 'master' password of the dongle is required, I think. Fortunately it is possible to change a setting so that it asks for the password only once per session instead of every time (until logged out, or until the screen is locked) <a href="https://stackoverflow.com/questions/76595490/avoiding-repeated-password-prompt-when-signing-with-ev-code-signing-certificate">(url)</a></p>
<p>Still, even with this setting, you have to enter the password once each time the computer reboots, and windows computer do reboot quite often..</p>
<p>There is no official way to enter the token password from command-line. It has to be typed, from you physical keyboard with your little fingers into that stupid dialog box from SafeNet. So it is not possible to automate builds. Fortunately, people have figured some hacks around this, they are ugly and a bit dangerous since the dongle is locked after three unsuccessful attempts:</p>
<ul>
<li>having an application watching the list of windows displayed, if one window title is "Token Logon", it sends it the password <a href="https://stackoverflow.com/a/24100982">(url)</a></li>
<li>using an undocumented feature of signtool <a href="https://stackoverflow.com/a/54439759">(url)</a> . It works great, but for how long ? What happens when the CA/Browser people find out that people can work around their stupid requirements ?</li>
</ul>
<p>I saw, after buying that SafeNet USB key, that some providers (not Sectigo) do offer "cloud signing" solutions. Of course it is more expensive, these poor guys have to run servers etc.. I guess in the end, for them, these new requirement from the CA/Browser forum are very good for the business, they will sell both usb keys and cloud signing solutions. For everybody else it is just a TOTAL waste of time. Also, in the end, security will be downgraded instead of improved because everybody will have a script that enters the password automatically when the dialog box appears, and will run it on a Windows boxes with auto-login enabled, because it does not work if the user is not logged on. And then this box will connect to the internet with some half-finished python script so that other machines can connect to it to sign binaries.</p>
<p>A final remark : isn't that strange that I can sign my macOS/iOS binaries from any of my macs, without any stupid Thalès USB dongle plugged in my mac ? If that is safe enough for Apple, why does Microsoft enforce this dongle on us, for a more expensive price, and with a much worse service (the SmartScreen malware warning that appears while the 'reputation' is being built is not what I call a great service) ?</p>
<p>In conclusion: fuck the CA/Browser forum, we were fine with the pkcs12 files.</p>Integrated GPU and memory throughput2019-05-07T17:55:12+02:00tag:gruntthepeon.free.fr,2019-05-07:/blog/81zogzogI have recently spent a lot of time trying to understand why the computations of my (audio) app on Windows were slowing down when I moved windows on my screen , or when I switched between workspaces. I though the CPU might just get hot and throttle, but it did not. I thought the audio thread was... <p>I have recently spent a lot of time trying to understand why the computations of my (audio) app on Windows were slowing down when I moved windows on my screen , or when I switched between workspaces. I though the CPU might just get hot and throttle, but it did not. I thought the audio thread was preempted by another thread, but it did not. I though it was interrupted by a bad graphics card driver (or wifi driver, which is very often the culprit for causing glitches in real-time audio applications), but LatencyMon told me everything was fine.</p>
<p>And it turns out it is just the integrated GPU of my core i7 7700 which is hogging the RAM (the integrated GPU does not have its own RAM, it is shared with the CPU). Since this is on a shitty Lenovo desktop with a single RAM stick, it does not have much bandwidth to share. What makes it even worse is that I have a 4k screen plugged into the integrated GPU, so the GPU has to move a lot of pixels.</p>
<p>A good way to check that is to open a simple webgl demo in the browser, preferably one that does not use much CPU, but uses a lot the GPU (the Windows task manager shows graphics for both). And then run the sisoft sandra memory benchmark with this window visible, and then with the window minimized. In the latter case, I get 11GB/s of memory bandwidth, with a latency of 24ns. But when the opengl window is visible, the bandwidth drops to "5.9G/s" and latency drops to 219ns !!</p>
<p><strong>The bandwidth is divided by 2 and the latency is multiplied by 10 when the GPU is in use</strong>. That's really bad, especially if you are running a real-time audio application that needs a stable performance. Ensuring that the CPU is not throttling , and that no other application is consuming too much CPU is not enough, one has also to make sure that the integrated GPU is not killing the performance of the RAM.</p>
<p>I have just ordered two new sticks of RAM (in order to double the bandwidth), and a pci-express graphics card, so hopefully with these two I should be able to get stable performance even when I switch between virtual desktops...</p>
<p><strong>Update</strong>: I was right, everything is solved with dual channel memory and an pci-express video card.. The spikes in the cpu load when moving windows or switching workspaces have completely disappeared.</p>Apple notarization : it sucks2019-04-17T19:18:01+02:00tag:gruntthepeon.free.fr,2019-04-17:/blog/80zogzogI've been trying to notarize my Fart3000.app the whole afternoon... I was following these directions: hardened-runtime-and-app-notarization . Everything seemed to work ,
xcrun altool --notarization-info blahblah
was displaying
Status: success
Status Message: Package Approved
At first I was... <p>I've been trying to notarize my Fart3000.app the whole afternoon... I was following these directions: <a href="https://forum.xojo.com/49408-10-14-hardened-runtime-and-app-notarization/p1#p410576" hreflang="fr">hardened-runtime-and-app-notarization</a> . Everything seemed to work ,</p>
<pre>xcrun altool --notarization-info blahblah</pre>
<p>was displaying</p>
<pre>Status: success
Status Message: Package Approved</pre>
<p>At first I was happy , until I tried to staple it:</p>
<pre>xcrun stapler staple -v Fart3000.app</pre>
<pre>CloudKit query for Fart3000.app (2/1cff807b7db46318f4c15d93199fc6b3bf454edb) failed due to "record not found".
Could not find base64 encoded ticket in response for 2/1cff807b7db46318f4c15d93199fc6b3bf454edb
The staple and validate action failed! Error 65.</pre>
<p>Strange isn't it ? The app is a fat binary with i386 and x86_64 arch. It turned out that if I build only the 64-bit file, then the stapling succeeds...</p>
<p>I don't reality need to built 32-bit versions of the App, so not a big sacrifice, but still it does not smell good, one tools says package approved and the other fails with a stupid and wrong message.</p>
<p>As a bonus, "altool" is a java application so it takes ages to start...</p>When optimizations cross the border of sanity2018-12-12T16:31:02+01:00tag:gruntthepeon.free.fr,2018-12-12:/blog/79zogzogI'm a bit annoyed because I have this toy program on my mac:
#include <iostream>
#include <cmath>
int main(int argc, char **) {
float f = 1, c = 0.1f;
for (int i=0; i < 45; ++i) {
std::cerr << "f=" << f << " sqrt(f)=" << sqrt(f) << "\n";
f... <p>I'm a bit annoyed because I have this toy program on my mac:</p>
<pre>#include <iostream>
#include <cmath>
int main(int argc, char **) {
float f = 1, c = 0.1f;
for (int i=0; i < 45; ++i) {
std::cerr << "f=" << f << " sqrt(f)=" << sqrt(f) << "\n";
f *= c;
}
return 0;
}</pre>
<p>It's pretty simple, and one would expect it to print numbers smaller and smaller until it prints zeroes. That's not what happens when built with clang and the fast-math option on macOS:</p>
<pre>clang++ -O1 -ffast-math t.cc && ./a.out
f=1 sqrt(f)=1
f=0.1 sqrt(f)=0.316228
f=0.01 sqrt(f)=0.1
f=0.001 sqrt(f)=0.0316228
f=0.0001 sqrt(f)=0.01
(skipping some output..)
f=1e-34 sqrt(f)=1e-17
f=1e-35 sqrt(f)=3.16228e-18
f=1e-36 sqrt(f)=1e-18
f=1e-37 sqrt(f)=3.16228e-19
f=1e-38 sqrt(f)=<strong>-inf</strong> # WTF ???
f=1e-39 sqrt(f)=<strong>-inf</strong>
...</pre>
<p>So when f is so small that it is represented as a denormal number, the sqrtf function returns PURE GARBAGE instead of returning 0. Or any denormal number. I would accept anything, but not, for fucks sake, a negative number. Not -inf. Please.</p>
<p>I have reported this to Apple (more than one year ago) , I got a reply (one year later), and for them it is not an issue, because the argument of sqrtf being smaller than FLT_MIN allows undefined behaviour (!??). Well, let's agree to disagree. I don't think fast-math should allow the compiler to do whatever it wants. Denormal numbers do happen. Sqrtf is a common function. There is a difference between being fast and slightly incorrect, and being fast and absolutely wrong.</p>
<p>Note: I have not been able to reproduce it with gcc or msvc, or even clang on linux. It is only the mac version of clang/libc++ which is retarded.</p>Ajouter le support du séquenceur midi ALSA quand il n'est pas fourni d'emblée avec le noyau2017-04-01T17:20:23+02:00tag:gruntthepeon.free.fr,2017-04-01:/blog/78zogzogAssez souvent avec les noyaux linux qui sont fournis avec les cartes ARM ont un minimum de modules d'activé, et bien souvent le séquenceur ALSA n'en fait pas partie. Comme ça fait plusieurs fois que je fais la manip et que j'oublie à chaque fois les differentes étapes voici ce que j'ai fait... <p>Assez souvent avec les noyaux linux qui sont fournis avec les cartes ARM ont un minimum de modules d'activé, et bien souvent le séquenceur ALSA n'en fait pas partie. Comme ça fait plusieurs fois que je fais la manip et que j'oublie à chaque fois les differentes étapes voici ce que j'ai fait pour avoir le séquenceur alsa sur une carte NanoPi Neo 2 sans s'emmerder à recompiler un kernel entier. Recuperer les sources correspondant au kernel courant, dans mon cas sur <a href="https://github.com/friendlyarm/h5_lichee">le github de friendlyarm</a> . Le dossier linux n'a pas de .config, y'en a pas dans /proc/config.gz , pour en recuperer un aller dans fa_tools et faire un <code>./build.sh -b nanopi-neo2 -p linux -t kernel</code> . Ca échoue rapidement mais on s'en fout maintenant y'a un .config dans le dossier linux.</p>
<p>Donc:</p>
<pre>cd linux</pre>
<pre>make menuconfig
et aller dans drivers / soundcard pour rajouter le support du sequenceur alsa sous forme de module.</pre>
<p>Il faut aussi recuperer Modules.symvers:</p>
<pre>cp /lib/modules/3.10.65/Module.symvers .</pre>
<p>Faire</p>
<pre>make prepare && make scripts
make CC=gcc-4.9 M=sound/core/seq/
sudo make CC=gcc-4.9 M=sound/core/seq/ modules_install
depmod -a</pre>
<p>et voilà normalement on peut maintenant faire un <code>modprobe snd-seq</code> et ça roule.</p>Executer un binaire arm 32-bit sur une distrib 64-bit (aarch64)2017-04-01T12:23:40+02:00tag:gruntthepeon.free.fr,2017-04-01:/blog/77zogzogEn fait c'est comme pour le i386 / amd64 , sur une distrib debian-like il faut commencer par un dpkg --add-architecture armhf (ou armel selon ce qu'on veut) , un apt-get update, un apt-get install libc6:armhf et ça roule.... <p>En fait c'est comme pour le i386 / amd64 , sur une distrib debian-like il faut commencer par un dpkg --add-architecture armhf (ou armel selon ce qu'on veut) , un apt-get update, un apt-get install libc6:armhf et ça roule.</p>Le macbook pro 2016 avec sa touchbar magique et révolutionnaire2017-02-28T20:52:16+01:00tag:gruntthepeon.free.fr,2017-02-28:/blog/75zogzogJ'ai un macbook pro 2016 depuis un bon gros mois et ça y est j'en ai marre faut que ça sorte. Ce matin il a refusé de sortir de veille, et ce soir cette bourrique qui renacle a obstinément refusé de se mettre veille. D'ailleurs la sortie de veille est un problème récurrent sur ce mac, il... <p><img src="http://totoz.eu/img/jeanpierrefoucault%3A1" alt="pas content" style="float:right; margin: 0 0 1em 1em;" /> J'ai un macbook pro 2016 depuis un bon gros mois et ça y est j'en ai marre faut que ça sorte. Ce matin il a refusé de sortir de veille, et ce soir cette bourrique qui renacle a obstinément refusé de se mettre veille. D'ailleurs la sortie de veille est un problème récurrent sur ce mac, il semblerait que l'adapteur pour écran externe hdmi soit dans le coup. Des fois en sortant de veille , ou en s'éteignant, je vois apparaitre des rectangles rouges sur l'écran du mac, en général c'est quand il renacle. C'est le genre de truc sur un vieux laptop dell sous windows on se dit "pff les drivers MACHIN c'est vraiment de la merde" ou "purée windows c'est vraiment de la merde en branche", mais là comme c'est un laptop apple "que c'est les meilleurs parce qu'ils controlent le matos et le soft et c'est pour ça que l'experience utilisateur est tellement léchée et polie" ben ça pique un peu. On pourrait aussi parler de l'adapteur pour écran externe, vendu par apple, pour la modique somme de 59euros et qui semble être impliqué dans pas mal de problèmes, cf ses notes et reviews ici: <a href="http://www.apple.com/shop/product/MJ1K2AM/A/usb-c-digital-av-multiport-adapter">usb-c-digital-av-multiport-adapter</a></p>
<p>La grosse nouveauté de ce macbook c'est sa touchbar. Elle permet (et c'est sans doute son usage le plus spectaculaire) d'afficher la liste entière des emojis unicode quand on rédige un mail , c'est assez impressionnant et bien sûr crucialement utile. On trouve aussi sur internet plein de gens qui disent que la touche escape transformée en touche non physique sur la touchbar eh ben "saipagrave", personnellement je penche plus pour le "sapuducul". Ca m'a donné l'occasion de réaliser qu'en position de repos j'ai tendance à laisser trainer le petit doigt pas loin de cette touche escape et comme maintenant elle s'active dès qu'elle est frôlée j'ai tendance à balancer des rafales de ESC intempestifs dans emacs ou dans le terminal (des rafales parce que tant qu'on laisse le doigt dessus elle passe en mode autorepeat, c'est vraiment malin). En mode rédaction de mail, un bouton 'Send' apparait juste à côté de la touche escape, ce qui est une riche idée sauf pour ceux qui ont l'habitude d'avoir le petit doigt qui traine dans le coin. A l'extrême droite y'a le bouton <del>marine</del>siri que j'ai aussi pas mal tendance à activer par erreur. Le réglage du volume sonore se fait aussi sur la touchbar, mais là ou autrefois on avait une touche pour augmenter, une touche pour baisser, il faut maintenant appuyer d'abord sur un bouton qui fait apparaitre un slider pour ensuite ajuster le volume, c'est très joli mais ça fait deux "clics" au lieu d'un. A part ça, la touchbar ne me sert à rien. Donc en gros on peut un peu dire que la touchbar c'est de la merde. Peut être qu'avec du retour haptique elle serait potable.</p>
<p>Le clavier est nouveau aussi, et il n'est ni magique ni révolutionnaire. En plus il fait du bruit (dans le bureau c'est clairement moi qui ai le clavier le plus bruyant maintenant), et ce n'est pas un bruit soigneusement designé qui évoque le matos cher et sophistiqué, mais plutot un vieux ploc cartonné qui me rappelle les pires netbooks avec leur claviers mous et gondolés. En plus je n'arrête pas de faire des fautes de frappe sur ce clavier.</p>
<p>Le bruit: j'ai pris le modele quad-coeur core i7 pour avoir une machine qui a la niaque quand il s'agit de compiler des trucs. Eh bien au bout de 10 minutes de compilation intensive le macbook réussit à faire plus de bruit que mon ancien mac pro (la grosse tour qui pèse au moins 200kg). Pas mal ! Et ça n'empeche pas le cpu d'être à 100°C (d'après l'application intel dont j'ai oublié le nom). Donc le corps du mac est confortablement chaud, comme une bonne bouillote de mamie, j'ai hâte de voir ce que ça va donner cet été.</p>
<p>Une feature sympa quand même: le touch-id , qui marche bien et j'apprécie de devoir saisir mon mot de passe un peu moins souvent. Et l'usb-C, si on oublie l'adapteur hdmi moisi de apple , pour le reste c'est plutot sympa.</p>
<p>En conclusion je décerne un 2/20 à ce macbook.</p>De la fragilité des outils de debug2016-09-24T17:12:46+02:00tag:gruntthepeon.free.fr,2016-09-24:/blog/74zogzogUne des choses les plus exaspérantes avec le dev en c/c++ c'est de ne pas comprendre *pourquoi* tel outil de profiling ou de debugage n'est pas foutu d'afficher les noms de fonctions corrects, ou d'afficher le code source. C'est par exemple perdre des heures à chercher pourquoi la fonction... <p>Une des choses les plus exaspérantes avec le dev en c/c++ c'est de ne pas comprendre *pourquoi* tel outil de profiling ou de debugage n'est pas foutu d'afficher les noms de fonctions corrects, ou d'afficher le code source. C'est par exemple perdre des heures à chercher pourquoi la fonction backtrace de la glibc a besoin d'une option particuliere du compilateur (-rpath) pour donner des noms de fonctions au lieu de leur addresse, alors que celle de la libunwind se demerde toute seule comme une grande. C'est perdre des heures à chercher comment faire en sorte que perf sous linux sur arm affiche des noms de symboles plutot que des addresses hexa. Ca n'est pas spécifique à une plateforme, sur *chaque* plateforme je me retrouve à un moment où a un autre à me battre contre des outils récalcitrants et autistes , qui ne fonctionnent pas et qui ne disent pas quel est leur problème. Mentions spéciales à perf sous linux, windbg sous windows et Instruments.app sous macos.</p>
<p>Et donc pour Instruments.app , ce qui est nécessaire si on veut que cette mule soit capable d'annoter les sources du code profilé, c'est de bien veiller à compiler les sources en donnant le chemin *absolu* à clang, et non pas un chemin relatif.</p>Editer un script bash pendant qu'il est en cours d'execution2016-07-17T17:54:43+02:00tag:gruntthepeon.free.fr,2016-07-17:/blog/73zogzogOn est en 2016 et bash n'est toujours pas capable de gérer correctement la situation où on édite un script alors qu'il est en cours d'exécution (gérer correctement, càd ignorer les changements et continuer à executer le script initial, et pas tenter d'executer un bout semi-aléatoire de la... <p><img src="http://totoz.eu/img/historia.gif" alt="" style="float:right; margin: 0 0 1em 1em;" /> On est en 2016 et bash n'est toujours pas capable de gérer correctement la situation où on édite un script alors qu'il est en cours d'exécution (gérer correctement, càd ignorer les changements et continuer à executer le script initial, et pas tenter d'executer un bout semi-aléatoire de la nouvelle version du script pour finalement se planter comme une merde)</p>