I provided an explanation on this (see attached message). I dont know if
Konstantin succeeded in working qround that bug. I dont know what Windows
experts think of my explanations either.


----- Original Message -----
From: jose antonio garvayo <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 20, 2000 4:57 AM
Subject: Problem with BIO functions in VC++ 6.0


> Hello:
>
> I compiled openssl-0.9.5 for Visual C++,following the
> instructions of Andrew Gray, and everything looks work
> fine; but I encounter a problem with the BIO functions
> that I can resolve. Here is the code:
>
> #include <stdio.h>
> #include <openssl/ssl.h>
>
> int main() {
>
> pBioErr= BIO_new_fp(stderr,BIO_NOCLOSE);
>
> fwrite("Hello world\n", 11, 1, pBioErr->ptr);
> BIO_printf(pBioErr, "Hello, world\n");
>
> return(1);
> };
>
> The program crash in BIO_printf(...), with the next
> call stack:
>
> NTDLL! 77f7ce4c()
> NTDLL! 77f77586()
> fwrite(const void * 0x0012f70c, unsigned int 6,
> unsigned int 1, _iobuf * 0x00422a98) line 72 + 9 bytes
> file_write(bio_st * 0x009c1fb0, char * 0x0012f70c, int
> 6) line 172 + 23 bytes
> BIO_write(bio_st * 0x009c1fb0, const char *
> 0x0012f70c, int 6) line 197 + 20 bytes
> BIO_printf(bio_st * 0x009c1fb0) line 95 + 20 bytes
> main(int 1, char * * 0x00ad0e90) line 25 + 14 bytes
> mainCRTStartup() line 206 + 25 bytes
> KERNEL32! 77f1b9ea()
>
>
> And the debug window display this:
>
> Loaded 'D:\WINNT\System32\ntdll.dll', no matching
> symbolic information found.
> Loaded symbols for
> 'C:\Pruebas\openssl-0.9.5\out32dll\Debug\libeay32.dll'
> Loaded 'D:\WINNT\system32\WSOCK32.DLL', no matching
> symbolic information found.
> Loaded 'D:\WINNT\system32\KERNEL32.DLL', no matching
> symbolic information found.
> Loaded 'D:\WINNT\system32\WS2_32.DLL', no matching
> symbolic information found.
> Loaded symbols for 'D:\WINNT\system32\MSVCRT.DLL'
> Loaded 'D:\WINNT\system32\USER32.DLL', no matching
> symbolic information found.
> Loaded 'D:\WINNT\system32\GDI32.DLL', no matching
> symbolic information found.
> Loaded 'D:\WINNT\system32\ADVAPI32.DLL', no matching
> symbolic information found.
> Loaded 'D:\WINNT\system32\RPCRT4.DLL', no matching
> symbolic information found.
> Loaded 'D:\WINNT\system32\WS2HELP.DLL', no matching
> symbolic information found.
> Loaded symbols for 'D:\WINNT\system32\MSVCRTD.DLL'
> First-chance exception in leaks.exe (NTDLL.DLL):
> 0xC0000005: Access Violation.
>
> I  think its very strange that the same function call
> (fwrite) with the same parameters that works in
> main(), fails in file_write(). Maybe is a problem with
> the settings of the compilation, because the utility
> applications (openssl, etc) works ok.
>
> Anyone could help me?
> Thanks in advance.
>
>
>
> _______________________________________________________________
> Do You Yahoo!?
> Consiga gratis su dirección @yahoo.es en http://correo.yahoo.es
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]
>


I suppose you are on Windows?
This may be because of 2 reasons:
1- your app doesnt use the multithreaded version of the runtime libraries,
while the openssl dlls do.

2- you are trying to do the fwrite on a BIO opened on a standard i/o, as in
s_server.c:
  bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);

I can't provide a definite explanation, but my s_server crashed with an
access violation exception on the first BIO write. It was when trying to
_lock_str(stream); I guessed that since openssl was compiled in a dll, it
could not operate on FILE* created in the calling application. The openssl
dll and the calling executable are 2 different win32 "executables", and each
executable use its own copy of the standard C file i/o.

SO I modified the openssl build to produce static libraries instead of dlls,
I linked the libraries statically to my executable, and the bug went away.

Now I didnt continue with the sample, and did not try to find an explanation
in the docs, so maybe I' wrong with this explanation: did someone experience
the same problem and could confirm / infirm my theory?

----- Original Message -----
From: Grebelsky, Konstantin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 14, 2000 5:59 PM
Subject: BIO_write call crashes...


> I have tried a number of things:
> X509_print_fp
> PEM_write_X509
> PEM_write_DSAPrivateKey
>
>
> all of these crash when they get to fwrite in file_write in bss_file.c
> They crash when fwrite tries to lock the stream...
> Does anybody know why this is happening? All this of course inside my code
> all openssl staff works just fine.
> Is there something I am not setting?
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]
>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]


Reply via email to