[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: Exception handling!!!
>
> Sorry, this is the first time posting to any forum, So, am missing
> important data.
>
> Below is the, part of code where am initializing and binding connection
> with the server.
>
> res = ldap_initialize(&ld, ldapuri);
> if( res != LDAP_SUCCESS )
> {
> char *errorM = NULL;
> errorM = ldap_err2string(res);
> if(errorM != NULL)
> // Print Error
>
> return NULL;
> }
>
> if(ld != NULL)
This test is basically pointless, because if res == LDAP_SUCCESS, ld
cannot be NULL.
> {
> res = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &protocol );
>
> if(res == LDAP_OPT_SUCCESS)
> {
> if(ld != NULL)
This test is not only pointless, but conceptually wrong, because obviously
ldap_set_option() cannot change its value.
> {
> res = ldap_start_tls_s(ld, NULL, NULL);
> if(res == LDAP_SUCCESS)
> {
> if(ld != NULL)
Same here.
> {
> res = ldap_sasl_interactive_bind_s( ld, NULL,"NTLM",
> NULL, NULL,
> sasl_flags,
> saslInteract, &auth );
>
> }
> }
> }
> else
> {
> //ld is null
> }
> }
> }
>
> And below is the backtrace of the crash.
>
> 0 liblber-2.3.0.dylib 0x007b9583 ber_sockbuf_ctrl + 147
> 1 libldap-2.3.0.dylib 0x007d25ad ldap_host_connected_to + 93
> 2 libldap-2.3.0.dylib 0x007c67f1 ldap_int_sasl_bind + 177
> 3 libldap-2.3.0.dylib 0x007c9064 ldap_sasl_interactive_bind_s
> + 84
> 4 myApp 0x003f54fb 0x1000 + 4146427
> 5 myApp 0x003f7e50 0x1000 + 4157008
> 6 com.apple.Foundation 0x94176ff1 __NSFireMachPort + 325
> 7 com.apple.CoreFoundation 0x94c03402 __CFMachPortPerform + 338
> 8 com.apple.CoreFoundation 0x94bff16b __CFRunLoopRun + 6523
> 9 com.apple.CoreFoundation 0x94bfd0f4 CFRunLoopRunSpecific + 452
> 10 com.apple.CoreFoundation 0x94bfcf21 CFRunLoopRunInMode + 97
> 11 com.apple.Foundation 0x9414f380 -[NSRunLoop(NSRunLoop)
> runMode:beforeDate:] + 279
> 12 com.apple.Foundation 0x9414f25d -[NSRunLoop(NSRunLoop) run]
> + 76
> 13 com.polycom.CMADesktop 0x003f4c53 0x1000 + 4144211
> 14 com.apple.Foundation 0x941158dc -[NSThread main] + 45
> 15 com.apple.Foundation 0x9411588c __NSThread__main__ + 1499
> 16 libSystem.B.dylib 0x965d5a19 _pthread_start + 345
> 17 libSystem.B.dylib 0x965d589e thread_start + 34
This trace is pointless: it doesn't state at what line of code the error
occurs, and it does not allow to know the value of the arguments. Please
follow the guidelines I pointed you to, especially
<http://www.openldap.org/faq/data/cache/59.html> and remember to use an
*unstripped* binary compiled with -g -O0
BTW, I notice a "thread_start" as the first call; is your application
multi-threaded? If yes, are you linking libldap or libldap_r? And, are
you taking precautions to make sure only one thread at a time accesses
your LDAP handler? Finally, do you realize that, even applications
designed to access LDAP handlers concurrently, operations like Start TLS
and bind need to be performed once for each handle, and serially?
p.