public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problem with latest setup-x86.exe
@ 2013-11-12 17:54 Harry G McGavran Jr
  2013-11-12 18:32 ` Christopher Faylor
  2013-11-12 18:50 ` Harry G McGavran Jr
  0 siblings, 2 replies; 11+ messages in thread
From: Harry G McGavran Jr @ 2013-11-12 17:54 UTC (permalink / raw)
  To: cygwin

On only one of my Windows 7 machines the latest setup-x86.exe
works but always exits with an Access Violation.

So, I downloaded the source to setup and built it.

But in order to make the build work, I had to remove -Werror
from the Makefile and add a definition for ARRAYSIZE to main.cc.

The fix to the Access violation was to remove an extra "_" in
the code for the argv handling in main.cc

This is just FWIW -- but it fixed my problem. The patches
I used follow:



*** ./setup/Makefile.orig	2013-11-12 10:27:00.812425300 -0700
--- ./setup/Makefile	2013-11-12 10:28:53.698882000 -0700
***************
*** 462,468 ****
  BASECXXFLAGS = -Wall -Wno-uninitialized -Wpointer-arith -Wcomments \
  	       -Wcast-align -Wwrite-strings -fno-builtin-sscanf

! AM_CXXFLAGS = -Werror $(BASECXXFLAGS) ${$(*F)_CXXFLAGS}
  AM_CFLAGS = $(AM_CXXFLAGS) -Wmissing-declarations -Winline \
  	    -Wstrict-prototypes -Wmissing-prototypes

--- 462,468 ----
  BASECXXFLAGS = -Wall -Wno-uninitialized -Wpointer-arith -Wcomments \
  	       -Wcast-align -Wwrite-strings -fno-builtin-sscanf

! AM_CXXFLAGS = $(BASECXXFLAGS) ${$(*F)_CXXFLAGS}
  AM_CFLAGS = $(AM_CXXFLAGS) -Wmissing-declarations -Winline \
  	    -Wstrict-prototypes -Wmissing-prototypes

*** ./setup/main.cc.orig	2013-11-07 06:14:18.000000000 -0700
--- ./setup/main.cc	2013-11-12 10:29:06.907637500 -0700
***************
*** 85,90 ****
--- 85,94 ----
  extern char **_argv;
  #endif

+ #ifndef ARRAYSIZE
+ #define ARRAYSIZE(_ar) (sizeof (_ar) / sizeof (_ar[0]))
+ #endif
+
  bool is_64bit;

  using namespace std;
***************
*** 233,250 ****
    snprintf(locale, sizeof locale, ".%u", GetACP());
    setlocale(LC_ALL, locale);

!   char **_argv;
    int argc;
!   for (argc = 0, _argv = __argv; *_argv; _argv++)
      ++argc;
!   _argv = __argv;

    try {
      char cwd[MAX_PATH];
      GetCurrentDirectory (MAX_PATH, cwd);
      local_dir = std::string (cwd);

!     if (!GetOption::GetInstance ().Process (argc,_argv, NULL))
        exit (1);

      if (!((string) Arch).size ())
--- 237,254 ----
    snprintf(locale, sizeof locale, ".%u", GetACP());
    setlocale(LC_ALL, locale);

!   char **argv;
    int argc;
!   for (argc = 0, argv = _argv; *argv; argv++)
      ++argc;
!   argv = _argv;

    try {
      char cwd[MAX_PATH];
      GetCurrentDirectory (MAX_PATH, cwd);
      local_dir = std::string (cwd);

!     if (!GetOption::GetInstance ().Process (argc,argv, NULL))
        exit (1);

      if (!((string) Arch).size ())


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Problem with latest setup-x86.exe
@ 2013-11-18 17:59 Harry G McGavran Jr
  2013-11-18 19:30 ` Achim Gratz
  0 siblings, 1 reply; 11+ messages in thread
From: Harry G McGavran Jr @ 2013-11-18 17:59 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen wrote:
>I just explained that in a reply an the cygwin-apps list:
>http://cygwin.com/ml/cygwin-apps/2013-11/msg00075.html>
>
>I applied a patch to setup which should fix the issue.
>

I grabbed the latest source (which has the nt_fopen in it)
and built it without the argv patch, but it still has the same
problem. __argv is always zero.

So, I tried the following under cygwin's mingw32:



#include <stdio.h>
#include <stdlib.h>

/* extern char *** __p___argv(void); */


#if 1
#define argc _argc
#define argv _argv
#endif

#if 0
#define argc __argc
#define argv __argv
#endif

int main(int argc, char **argv, char **envp)
{
register int i;

printf ("_argc = 0x%x\n", _argc);
printf ("__argc = 0x%x\n", __argc);
printf ("__p___argc() = 0x%x\n", __p___argc());
printf ("*(__p___argc()) = 0x%x\n", *(__p___argc()));
printf ("\n");
printf ("_argv = 0x%x\n", _argv);
printf ("__argv = 0x%x\n", __argv);
printf ("__p___argv() = 0x%x\n", __p___argv());
printf ("*(__p___argv()) = 0x%x\n", *(__p___argv()));
printf ("\n");

printf("argc=%d\n", argc);
for (i=0; i<argc; i++)
printf("argv[%d]=%s\n", i, argv[i]);
return(0);
}

and then I ran it on my machine and four other windows 7 pro machines
using "tst abc def" and get:


_argc = 0x3
__argc = 0x0
__p___argc() = 0x755830e4
*(__p___argc()) = 0x0

_argv = 0x5b1680
__argv = 0x0
__p___argv() = 0x755830c0
*(__p___argv()) = 0x0

argc=3
argv[0]=C:\cygwin\usr\local\src\cygwin_setup\tst\tst.exe
argv[1]=abc
argv[2]=def

on all these machines.

I don't know how that for loop on __argv in main.cc can work with __argv
always returning zero, but admittedly setup.exe does work
on some of these machines without my changes, just not on others.
My changes produce a setup that does work on all of them.
I have to admit I haven't been able to figure out what __argv really
does since it always returns zero on any machine I try.  So, I'm still
puzzled.





--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Problem with latest setup-x86.exe
@ 2013-11-19 16:30 Harry G McGavran Jr
  2013-11-19 16:54 ` Corinna Vinschen
  0 siblings, 1 reply; 11+ messages in thread
From: Harry G McGavran Jr @ 2013-11-19 16:30 UTC (permalink / raw)
  To: cygwin

Achim Gratz writes:
> Corinna Vinschen writes:
>> I just explained that in a reply an the cygwin-apps list:
>> http://cygwin.com/ml/cygwin-apps/2013-11/msg00075.html
>>
>> I applied a patch to setup which should fix the issue.
>
> The patch WJFFM.
>

But in line 266 of main.cc set_cout() is still called
if unattended_mode -q (or --help) is set.



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Problem with latest setup-x86.exe
@ 2013-11-20  2:51 Harry G McGavran Jr
  0 siblings, 0 replies; 11+ messages in thread
From: Harry G McGavran Jr @ 2013-11-20  2:51 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen writes:
> > Achim Gratz writes:
> > > Corinna Vinschen writes:
> > >> I just explained that in a reply an the cygwin-apps list:
> > >> http://cygwin.com/ml/cygwin-apps/2013-11/msg00075.html
> > >>
> > >> I applied a patch to setup which should fix the issue.
> > >
> > > The patch WJFFM.
> > >
> >
> > But in line 266 of main.cc set_cout() is still called
> > if unattended_mode -q (or --help) is set.
>
> Sure.  The problem was not the set_cout function but overloading the
> fopen function.

FWIW -- what brought me to line 266 was that I started playing
with the latest setup-x86.exe (The 17-Nov. 2013 one) in a cmd
window and noticed that the problem only existed with -q or --help.
I normally use setup.exe with -q so I was seeing this all the time.
So after looking at main.cc it was too hard to pass up line 266
as a possible culprit.

A bit more interesting though is that later I started using the
Windows debugger under the cmd window on that same setup-x86.exe
and could see the null pointer problem, but of course there were
not symbols or source.  So, for grins I decided to decompress
it with "upx -d" and voila, it fixed the problem as long as I ran
the uncompressed version.  For further grins, I decided to
try compressing it again and most of the common options brought
the problem back -- BUT -- if I used "--compress-exports=0"
in upx, then I got a compressed version that doesn't have the
problem.  Even with --best and --compress-exports=0 I get
a version that works.

So, this is just FWIW -- other executables compress with upx and
work just fine. Previous versions of setup (prior to the incantations
of the current version) work just fine -- so not being a windows
person any more that I absolutely have to, I'm not going to pursue
this any further, but this might be useful information for someone someday.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-11-20  2:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-12 17:54 Problem with latest setup-x86.exe Harry G McGavran Jr
2013-11-12 18:32 ` Christopher Faylor
2013-11-17 17:55   ` Achim Gratz
2013-11-18 11:18     ` Corinna Vinschen
2013-11-18 19:48       ` Achim Gratz
2013-11-12 18:50 ` Harry G McGavran Jr
2013-11-18 17:59 Harry G McGavran Jr
2013-11-18 19:30 ` Achim Gratz
2013-11-19 16:30 Harry G McGavran Jr
2013-11-19 16:54 ` Corinna Vinschen
2013-11-20  2:51 Harry G McGavran Jr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).