videolabs / libdsm

Defective SMb: A minimalist implementation of a client library for SMBv1 using Plain'Ol C

Home Page:http://videolabs.github.io/libdsm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with multiple downloads at the same time

sumanksk2006 opened this issue · comments

Hi,

I am trying to download multiple files from SMB to iPad's app Sandbox.

From code wise, I get SIGABRT at smb_session_login while checking connection before file download gets start.

Sometimes, smb_tree_connect is not creating treeID and I get SIGABRT at smb_fopen while opening file.

I faced same errors even if I create a session for each download task.

Does this library not allow multiple downloads?
Please suggest me here.

Please provide backtrace if you have SIGABRT

Hi!
I faced the same issue.
I use libdsm (v0.2.5) in my tvOS app.
When I try to download multiple files at the same time, I get SIGABRT due to the error

malloc: *** error for object 0x7f87aa71a490: pointer being freed was not allocated

Here is the stack trace:

* thread #12: tid = 0x18945, 0x00000001057d0b90 tvOSTestApp`_asn1_delete_list + 16 at parser_aux.c:510, queue = 'NSOperationQueue 0x7f87aa57f040 :: NSOperation 0x7f87aa7a5da0 (QOS: UTILITY)', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x00000001057d0b90 tvOSTestApp`_asn1_delete_list + 16 at parser_aux.c:510
    frame #1: 0x00000001057d1da7 tvOSTestApp`asn1_array2tree(array=0x0000000106a4eb70, definitions=<unavailable>, errorDescription=<unavailable>) + 583 at structure.c:272
    frame #2: 0x0000000105b850c3 tvOSTestApp`smb_session_login_spnego [inlined] init_asn1(s=0x00007f87ac825030) + 99 at smb_spnego.c:67
    frame #3: 0x0000000105b85095 tvOSTestApp`smb_session_login_spnego(s=0x00007f87ac825030, domain="SAMBA2", user="admin", password="admin") + 53 at smb_spnego.c:342
    frame #4: 0x00000001055dad43 tvOSTestApp`-[SMBFileDownloadOperation main](self=0x00007f87aa7a5da0, _cmd="main") + 1971 at SMBFileDownloadOperation.m:162
    frame #5: 0x000000010908e0da Foundation`-[__NSOperationInternal _start:] + 646
    frame #6: 0x000000010908dceb Foundation`__NSOQSchedule_f + 194
    frame #7: 0x000000010b26949b libdispatch.dylib`_dispatch_client_callout + 8
    frame #8: 0x000000010b24f8ec libdispatch.dylib`_dispatch_queue_drain + 2215
    frame #9: 0x000000010b24ee0d libdispatch.dylib`_dispatch_queue_invoke + 601
    frame #10: 0x000000010b251a56 libdispatch.dylib`_dispatch_root_queue_drain + 1420
    frame #11: 0x000000010b2514c5 libdispatch.dylib`_dispatch_worker_thread3 + 111
    frame #12: 0x000000010b5b54de libsystem_pthread.dylib`_pthread_wqthread + 1129
    frame #13: 0x000000010b5b3341 libsystem_pthread.dylib`start_wqthread + 13

Please fix it. Thanks in advance.

I just found out that smb_session_login is not reentrant because libtasn1 is not reentrant.
You can easily fix this issue by protecting smb_session_login calls with a mutex.

In the meantime, we'll search for a solution.

libtasn1 not reentrant is a big issue, I'd say...