Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Diego 'Flameeyes' Pettenò


On 01/feb/08, at 02:33, Josh Williams wrote:


How did you get 9?


Probably by being 2:21 AM here ;) Sorry just a thinko.



Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Josh Williams
On Jan 31, 2008 8:21 PM, Diego 'Flameeyes' Pettenò <[EMAIL PROTECTED]> wrote:
> char *foo = "ab" -> 4 + 3 = 9 bytes

How did you get 9?


Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Diego 'Flameeyes' Pettenò
On Friday 01 February 2008, you wrote:
> Yes; but I still have to manually increment the size to an appropriate
> value each time I add a bigger string; plus I'm wasting space for all
> shorter strings (which applies more to bigger-than-two-element char
> arrays);

Actually, you're not always. The actual space occupied by a pointer to 
character is

sizeof(char*) + sizeof("literal");

This means that for 32-bit (best-case)

char *foo = "a" -> 4 + 2 = 6 bytes
char *foo = "ab" -> 4 + 3 = 9 bytes
char *foo = "abc" -> 4 + 4 = 8 bytes

char foo[] = "a" -> 2 bytes
char foo[] = "ab" -> 3 bytes
char foo[] = "abc" -> 4 bytes

By that reasoning, char foo[6] will _always_ take less or equal space than 
char *foo.
But 32-bit architectures are also dying beside embedded systems, which means 
that the most common case especially in the years to come will be 
sizeof(char*) == 8 (64-bit architectures), at which point char foo[10] will 
always be smaller or equal to char *foo.

Considering you get out with an indirection less, most of the time even 
wasting 8 more bytes per string is worth the change.

> The first solution makes good sense to me, particularly for its improved
> correctness; but fixing the second problem seems like a
> nano-optimization that doesn't bring sufficient efficiency benefits to
> outweigh its drawbacks in maintainability.

It is a micro-optimisation, I admit that, but it's not just the indirection 
the problem.

Pointers, and structures containing pointers, need to be runtime-relocated for 
shared libraries and PIC code (let's assume that shared libraries are always 
PIC, for the sake of argument). In these cases the data is written 
to .data.rel, or .data.rel.ro for costants (I'm talking ELF here, other 
output formats most likely have something like that), which are copy-on-write 
sections. Without prelinking, these sections will be copied right at the 
start of the program, and when copied, they are no more shared between 
processes. Which means they'll be using pages of private memory on the 
various processes.

It is a minor thing for wget as it's not a shared library, but a 
fire-and-forget program, so even for security people using PIE it's far from 
being a big hit. It's more important for shared libraries though, especially 
because shared libraries can't always be prelinked properly. See also 
http://farragut.flameeyes.is-a-geek.org/articles/2008/01/01/reminding-a-weakness-of-prelink

Now, glib comes to the point of using the method that Mart described in the 
comments to my first blog ( 
http://farragut.flameeyes.is-a-geek.org/articles/2007/12/19/array-of-pointers-and-array-of-arrays
 ) 
and I quoted on the second ( 
http://farragut.flameeyes.is-a-geek.org/articles/2008/01/01/some-more-about-arrays-of-strings
 ) 
to avoid the increase-the-size and waste-the-space game, but making it a 
quite bigger, IMHO, maintenance problem. I haven't seen enough use yet for 
this to be a royally good idea, but I'm thinking of trying that out with 
xine-lib soon enough (without the second array, if the access can be done 
sequentially instead of randomly).

-- 
Diego "Flameeyes" Pettenò
http://farragut.flameeyes.is-a-geek.org/



signature.asc
Description: This is a digitally signed message part.


Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Micah Cowan

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

(Forgot to CC the list.

Also, my mailer seems to be screwing up the quotes. :(  -M)

Diego 'Flameeyes' Pettenò wrote:
| As for maintainability, while a character pointer is easier to handle
than a
| character array, modern compilers warns you if you tries to force
bigger data
| into an array:
|
| struct { char foo[2]; } bar[] { { "foobar" } };

Yes; but I still have to manually increment the size to an appropriate
value each time I add a bigger string; plus I'm wasting space for all
shorter strings (which applies more to bigger-than-two-element char arrays);

| There actually are quite a few differences, I've documented them on my
blog
| some time ago:
|
|
http://farragut.flameeyes.is-a-geek.org/articles/2007/12/19/array-of-pointers-and-array-of-arrays
|
http://farragut.flameeyes.is-a-geek.org/articles/2008/01/01/some-more-about-arrays-of-strings

As I understand it, you have two issues with things like:

~  static const char *additional_attributes[] = { ... }

The first is that, since additional_attributes[] itself isn't constant,
it will not reside in read-only memory, unlike the data its elements
point at. This is easily solved with:

~  static const char * const additional_attributes[] = { ... }

Which is better anyway, since it also prevents someone from accidentally
overwriting elements with something like:

~  if (additional_attributes[4] = "magic_attr) {
~/* ^ Whoops! */

The other is that there is the inefficiency of indirection, where the
code has to find the proper string by first finding the proper element
within the additional_attributes array, and then following _that_
pointer to the proper string.

The first solution makes good sense to me, particularly for its improved
correctness; but fixing the second problem seems like a
nano-optimization that doesn't bring sufficient efficiency benefits to
outweigh its drawbacks in maintainability.

Anyway, thanks for the information, and helpful suggestions. :)

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHom/y7M8hyUobTrERAkzEAJ9tV3ZbzLuqlfvZW2SLDa4YkZNJQgCeN4f5
905Ny2JMxt1hsWsgVcIGZtE=
=yvIE
-END PGP SIGNATURE-


Re: wget running in windows Vista

2008-01-31 Thread Alan Thomas
What version of wget?  What edition of Vista?  

 I have used the wget 1.10.2 on Vista before.

Alan

- Original Message - 
From: "Christopher G. Lewis" <[EMAIL PROTECTED]>
To: "Liz Labbe" <[EMAIL PROTECTED]>; 
Sent: Thursday, January 31, 2008 8:22 AM
Subject: RE: wget running in windows Vista


> On Vista, you probably have to run in an administrative command prompt.
> 
> Christopher G. Lewis
> http://www.ChristopherLewis.com
>  
> 
> > -Original Message-
> > From: Liz Labbe [mailto:[EMAIL PROTECTED] 
> > Sent: Wednesday, January 30, 2008 10:57 PM
> > To: wget@sunsite.dk
> > Subject: wget running in windows Vista
> > 
> > I just downloaded WGET and am trying to get it to work
> > under Window's Vista operating system.
> > 
> > I cannot get it to connect: for example, I tried 
> > 
> > wget http://www.yahoo.com/ 
> > wget force_html=on http://www.yahoo.com/
> > 
> > etc. 
> > I consistently get the message 
> > connecting to www.yahoo.com|99.99.99.99|99., 
> > Failed...network is down. 
> > 
> > Is there an issue with Vista or am I doing something
> > wrong?
> > 
> > Thanks,
> > Liz
> > 
> > 
> >   
> > __
> > __
> > Never miss a thing.  Make Yahoo your home page. 
> > http://www.yahoo.com/r/hs
> > 
> 


Re: wget 1.11 no-clobber still sending GET request

2008-01-31 Thread Micah Cowan
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Charles wrote:
> Hi,
> 
> Comparing the behavior of wget 1.11 and wget 1.10, in wget 1.11 using
> wget -nc url still sends a GET request to the server while this does
> not happen is wget 1.10.
> 
> My question is how do I turn off this behavior?
> 
> Looking at the code in http.c I do not see any flag to turn off the
> creation of a new request (in line 1434).

Hi Charles,

TBH, I don't understand the relevant code in http.c nearly as well as
I'd like. It's not one flag to turn it off, but several various checks
at different points, I believe. My current goal for the 1.12 codebase is
to get this area cleaned up to the point that I can navigate it with
less trouble than I currently must. :)

I'll investigate the regression; however, I can't promise to fix it for
1.11.1.

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHog+N7M8hyUobTrERAqTFAJ9hZRbwl/FO1AUq/0mFOIPRX3L/zQCghTwi
mjRzwDXfFoYCCLbY6ITq/Ro=
=5afw
-END PGP SIGNATURE-


Re: wget running in windows Vista

2008-01-31 Thread Liz Labbe
Matthias,
   It actually does put the IP address; I was just
using the 99's as an example.  I can browse yahoo from
my browser and did try a smaller page as well. 
However, I will try these suggestions and see what I
can do. 
Liz

--- Matthias Vill <[EMAIL PROTECTED]> wrote:

> Liz Labbe wrote:
> > I just downloaded WGET and am trying to get it to
> work
> > under Window's Vista operating system.
> > 
> > I cannot get it to connect: for example, I tried 
> > 
> > wget http://www.yahoo.com/ 
> > wget force_html=on http://www.yahoo.com/
> > 
> > etc. 
> > I consistently get the message 
> > connecting to www.yahoo.com|99.99.99.99|99., 
> > Failed...network is down.
> 
> Ok,
> 
> looks like wrong IP at first glance. Have you tried
> to download
> something else like www.kernel.org or some other
> small page?
> Can you browse to www.yahoo.com with you browser?
> 
> If that does not help please go to Software
> Installations inside your
> Control Center, somewhere there you can add Windows
> components.
> There should be something called "simple network
> programs" or alike
> (sorry I don't have an English Vista at hand).
> If you found and installed you can try "ping
> www.yahoo.com" and check
> the results. If this too lists 99.99.99.99 as the
> IP-Adress you maybe
> have a problem with name resolution (maybe even
> introduced by a virus)
> 
> Good look,
> 
> Matthias
> 



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



Re: wget running in windows Vista

2008-01-31 Thread Matthias Vill
Liz Labbe wrote:
> I just downloaded WGET and am trying to get it to work
> under Window's Vista operating system.
> 
> I cannot get it to connect: for example, I tried 
> 
> wget http://www.yahoo.com/ 
> wget force_html=on http://www.yahoo.com/
> 
> etc. 
> I consistently get the message 
> connecting to www.yahoo.com|99.99.99.99|99., 
> Failed...network is down.

Ok,

looks like wrong IP at first glance. Have you tried to download
something else like www.kernel.org or some other small page?
Can you browse to www.yahoo.com with you browser?

If that does not help please go to Software Installations inside your
Control Center, somewhere there you can add Windows components.
There should be something called "simple network programs" or alike
(sorry I don't have an English Vista at hand).
If you found and installed you can try "ping www.yahoo.com" and check
the results. If this too lists 99.99.99.99 as the IP-Adress you maybe
have a problem with name resolution (maybe even introduced by a virus)

Good look,

Matthias


Re: wget running in windows Vista

2008-01-31 Thread Hrvoje Niksic
"Christopher G. Lewis" <[EMAIL PROTECTED]> writes:

> On Vista, you probably have to run in an administrative command
> prompt.

You mean that you need to be the administrator to run Wget?  If so,
why?  Surely other programs managed to access the network without
administrator privileges.


RE: wget running in windows Vista

2008-01-31 Thread Christopher G. Lewis
On Vista, you probably have to run in an administrative command prompt.

Christopher G. Lewis
http://www.ChristopherLewis.com
 

> -Original Message-
> From: Liz Labbe [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, January 30, 2008 10:57 PM
> To: wget@sunsite.dk
> Subject: wget running in windows Vista
> 
> I just downloaded WGET and am trying to get it to work
> under Window's Vista operating system.
> 
> I cannot get it to connect: for example, I tried 
> 
> wget http://www.yahoo.com/ 
> wget force_html=on http://www.yahoo.com/
> 
> etc. 
> I consistently get the message 
> connecting to www.yahoo.com|99.99.99.99|99., 
> Failed...network is down. 
> 
> Is there an issue with Vista or am I doing something
> wrong?
> 
> Thanks,
> Liz
> 
> 
>   
> __
> __
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 


smime.p7s
Description: S/MIME cryptographic signature


wget 1.11 no-clobber still sending GET request

2008-01-31 Thread Charles
Hi,

Comparing the behavior of wget 1.11 and wget 1.10, in wget 1.11 using
wget -nc url still sends a GET request to the server while this does
not happen is wget 1.10.

My question is how do I turn off this behavior?

Looking at the code in http.c I do not see any flag to turn off the
creation of a new request (in line 1434).

Thanks in advance.
---
Charles