Hello list!
The 0x20000 crash the subject refers to is a crash which is special in
that it is caused by attempting to access memory at address 0x20000
which is unallocated resulting in a segmentation fault.
The error is triggered when hostname resolution via DNS fails (I am
using gethostbyname() ).
I think this was discussed long time ago in some bug filing that I saw
a few years ago, that it was understood the error is specific to the
x86_64 architecture and that the cause was not known at the time.
However, the error was partially fixed sometime after that - as I saw in
the git repository just now.
The problem is that va_lists are handled in a brittle way by x86_64 and
need to be copied whenever even a small breeze blows. More info:
http://www.bailopan.net/blog/?p=30
The patch is against Polipo-1.0.4.1, before the fix in the repository
was made. Beside the fix already in the repository, the patch also
va_copies the va_list arguments whenever they are passed through a
function. It also calls va_end after all instances of va_copy (the code
in repository does not).
--
Fourth law of programming:
Anything that can go wrong wi
sendmail: segmentation violation - core dumped
diff -Naur polipo-1.0.4.1-old/log.c polipo-1.0.4.1-new/log.c
--- polipo-1.0.4.1-old/log.c 2010-02-01 00:13:20.000000000 +0100
+++ polipo-1.0.4.1-new/log.c 2012-07-03 20:58:25.000000000 +0200
@@ -279,11 +279,14 @@
accumulateSyslogV(int type, const char *f, va_list args)
{
int rc;
+ va_list args2;
again:
+ va_copy(args2, args);
rc = vsnprintf(syslogBuf + syslogBufLength,
syslogBufSize - syslogBufLength,
- f, args);
+ f, args2);
+ va_end(args2);
if(rc < 0 || rc >= syslogBufSize - syslogBufLength) {
rc = expandSyslog(rc);
@@ -370,12 +373,20 @@
void
really_do_log_v(int type, const char *f, va_list args)
{
+ va_list args2, args3;
+
if(type & LOGGING_MAX & logLevel) {
- if(logF)
- vfprintf(logF, f, args);
+ if(logF) {
+ va_copy(args2, args);
+ vfprintf(logF, f, args2);
+ va_end(args2);
+ }
#ifdef HAVE_SYSLOG
- if(logSyslog)
- accumulateSyslogV(type, f, args);
+ if(logSyslog) {
+ va_copy(args3, args);
+ accumulateSyslogV(type, f, args3);
+ va_end(args3);
+ }
#endif
}
}
@@ -393,13 +404,17 @@
void
really_do_log_error_v(int type, int e, const char *f, va_list args)
{
+ va_list args2, args3;
+
if((type & LOGGING_MAX & logLevel) != 0) {
char *es = pstrerror(e);
if(es == NULL)
es = "Unknown error";
if(logF) {
- vfprintf(logF, f, args);
+ va_copy(args2, args);
+ vfprintf(logF, f, args2);
+ va_end(args2);
fprintf(logF, ": %s\n", es);
}
#ifdef HAVE_SYSLOG
@@ -407,7 +422,9 @@
char msg[256];
size_t n = 0;
- n = snnvprintf(msg, n, 256, f, args);
+ va_copy(args3, args);
+ n = snnvprintf(msg, n, 256, f, args3);
+ va_end(args3);
n = snnprintf(msg, n, 256, ": ");
n = snnprint_n(msg, n, 256, es, strlen (es));
n = snnprintf(msg, n, 256, "\n");
diff -Naur polipo-1.0.4.1-old/util.c polipo-1.0.4.1-new/util.c
--- polipo-1.0.4.1-old/util.c 2010-02-01 00:13:20.000000000 +0100
+++ polipo-1.0.4.1-new/util.c 2012-07-03 20:53:30.000000000 +0200
@@ -50,9 +50,12 @@
snnvprintf(char *restrict buf, int n, int len, const char *format, va_list args)
{
int rc = -1;
+ va_list args2;
if(n < 0) return -2;
if(n < len)
- rc = vsnprintf(buf + n, len - n, format, args);
+ va_copy(args2, args);
+ rc = vsnprintf(buf + n, len - n, format, args2);
+ va_end(args2);
if(rc >= 0 && n + rc <= len)
return n + rc;
else
@@ -268,7 +271,10 @@
{
char *r;
int rc;
- rc = vasprintf(&r, f, args);
+ va_list args2;
+ va_copy(args2, args);
+ rc = vasprintf(&r, f, args2);
+ va_end(args2);
if(rc < 0)
return NULL;
return r;
@@ -281,9 +287,14 @@
int n, size;
char buf[64];
char *string;
+ va_list args2, args3, args4;
- n = vsnprintf(buf, 64, f, args);
+ va_copy(args2, args);
+ va_copy(args4, args);
+ n = vsnprintf(buf, 64, f, args4);
+ va_end(args4);
if(n >= 0 && n < 64) {
+ va_end(args2);
return strdup_n(buf, n);
}
if(n >= 64)
@@ -293,18 +304,25 @@
while(1) {
string = malloc(size);
- if(!string)
+ if(!string) {
+ va_end(args2);
return NULL;
- n = vsnprintf(string, size, f, args);
- if(n >= 0 && n < size)
+ }
+ va_copy(args3, args2);
+ n = vsnprintf(string, size, f, args3);
+ va_end(args3);
+ if(n >= 0 && n < size) {
+ va_end(args2);
return string;
- else if(n >= size)
+ } else if(n >= size)
size = n + 1;
else
size = size * 3 / 2;
free(string);
- if(size > 16 * 1024)
+ if(size > 16 * 1024) {
+ va_end(args2);
return NULL;
+ }
}
/* NOTREACHED */
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Polipo-users mailing list
Polipo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/polipo-users