Hi Alex. I'm on Win2k Pro, 5.00.2195, Service Pack 4, and VC++ 6.0.
Crashes consistently on SNMP_FREE, called from snmptranslate -Dread_config -IR -Td linkDown. Here's a stack trace, for what it's worth: NTDLL! 77fb6972() NTDLL! 77f8be26() KERNEL32! 7c58f76e() _CrtIsValidHeapPointer(const void * 0x0031f52d) line 1697 _free_dbg_lk(void * 0x0031f52d, int 1) line 1044 + 9 bytes _free_dbg(void * 0x0031f52d, int 1) line 1001 + 13 bytes free(void * 0x0031f52d) line 956 + 11 bytes netsnmp_getenv(const char * 0x00468764) line 1034 + 16 bytes read_config_files(int 1) line 1057 + 10 bytes read_premib_configs() line 854 + 7 bytes init_snmp(const char * 0x0045366c) line 820 main(int 5, char * * 0x00314198) line 238 + 10 bytes mainCRTStartup() line 338 + 17 bytes KERNEL32! 7c59893d() Thanks, Phil Gillis -----Original Message----- From: Alex Burger [mailto:[EMAIL PROTECTED] Sent: Monday, December 06, 2004 10:15 PM To: Gillis, Philip W (Philip) Cc: Net-Snmp-Coders (E-mail) Subject: Re: 5.2 crash in win32 Hi Phil. Gillis, Philip W (Philip) wrote: > In 5.2 win32, my snmp commands now crash, quite early on. What version of Windows and MSVC are you using? > I tracked it to netsnmp_getenv() in libsnmp\tools.c. First, it sets > temp = getenv(name), then looks in the registry if name was not found in > the registry. Then it calls setenv(temp) to set it from now on. Then > (here comes the crash), it calls SNMP_FREE(temp). If temp was found in > the environment first (not the registry), this crashes. On the second > call for the same variable, it will certainly be found in the > environment, and we crash. What you suggest makes sense. Getenv on both Windows and Linux returns a pointer to the variable in the environment space. It's not a copy of it, it's a pointer to the enviornment variable. Freeing this would be a bad idea. I tested on my system (Windows 2000, MSVC 6) and there is no crash when using either the registry or the environment variable, even when SNMPCONFPATH is loaded multiple times. For my testing I used: snmptranslate -Dread_config -IR -Td linkDown I also tested with a MinGW build before the 5.2 release and I didn't have any problems. I'm not sure why it's crashing for you but not for me but like I said, your change does seem to make sense. Knowing the version of your Windows etc may help. > Also, I found that when I just download and build the source, and use > build.bat, and let it install after building, the registry is not set > with the net-SNMP variables. Running win32\install-net-snmp.bat does > not help. I had to install the binaries, to get the variables in the > environment. I thought that the README.WIN32 file was updated with that information. I guess it didn't make it in. It's mentioned in the README for the binary (win32/dist/README.txt), which is included in the binary which you installed. I'll fix that for the next release. Alex > > I did a quick fix to tools.c to prevent the freeing of vars returned > from getenv(): > > int got_env = 0; // PWG kludge to avoid freeing temp from > getenv() > > ... > > /* Try environment variable first */ > > temp = getenv(name); > > if (temp){ > > DEBUGMSGTL(("read_config", "netsnmp_getenv will return from ENV: > %s\n",temp)); > > got_env =1; // PWG added > > } > > ... > > if (temp && !got_env) { // PWG added !got_env > > setenv(name, temp, 1); > > SNMP_FREE(temp); > > } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Net-snmp-coders mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
