This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH] setup.exe SEGV on WinXP/Pro
- From: Achim Gratz <Stromeko at nexgo dot de>
- To: cygwin-apps at cygwin dot com
- Date: Thu, 08 Aug 2013 20:34:54 +0200
- Subject: [PATCH] setup.exe SEGV on WinXP/Pro
I've been having sporadic SEGV on WinXP/Pro just after the MD5 of a
package was checked that used to clear up after a reboot. Today, with a
freshly built setup.exe this failure was now entirely reproduceable.
I've fixed it by reimplementing the string formatting for the MD5 digest
using C++ stream functions.
>From 677e2e89d1e4046c967dd1759ac53116f6643bd9 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Thu, 8 Aug 2013 20:23:31 +0200
Subject: [PATCH] fix SEGV on WinXP/Pro
* csu_util/MD5Sum.cc (MD5Sum::operator std::string() const):
Reimplement using stringstream to avoid a SEGV on WinXP/Pro.
---
csu_util/MD5Sum.cc | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/csu_util/MD5Sum.cc b/csu_util/MD5Sum.cc
index 3399dad..eb679b5 100644
--- a/csu_util/MD5Sum.cc
+++ b/csu_util/MD5Sum.cc
@@ -13,7 +13,10 @@
*/
#include "MD5Sum.h"
-#include <string.h>
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <iomanip>
#include <stdexcept>
MD5Sum::MD5Sum(const MD5Sum& source)
@@ -79,22 +82,12 @@ MD5Sum::finish()
MD5Sum::operator std::string() const
{
- char hexdigest[33];
- hexdigest[32] = '\0';
+ std::ostringstream hexdigest;
- for (int i = 0; i < 16; ++i)
- {
- int hexdigit = 2 * i;
- char tmp;
-
- tmp = digest[i] >> 4;
- hexdigest[hexdigit] = (tmp < 10) ? (tmp + '0') : (tmp + 'a' - 10);
-
- tmp = digest[i] & 0x0f;
- hexdigest[hexdigit + 1] = (tmp < 10) ? (tmp + '0') : (tmp + 'a' - 10);
- }
-
- return std::string(hexdigest);
+ hexdigest << std::hex << std::setfill('0') << std::setw(2);
+ for (int i=0; i<16; ++i )
+ hexdigest << static_cast<unsigned int>(digest[i]);
+ return hexdigest.str();
}
bool
--
1.8.3.1
The version on cygwin.com does not exhibit this behaviour, but when I
rebuild the same version it also crashes. Earlier versions I've built
myself were not affected or only sporadically, but are if I build them
again using the current toolchain. So there must be an interaction with
the build environment (I've been using the native gcc 4.7.3 on 32bit
Cygwin for building) or a bug in gcc that manifests here.
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada