The C Source, Patches and (shudder!) Bugs
Post Reply
Posts: 1
Joined: 05 Dec 2014, 15:51

Segfault with freeing active configuration twice

Post by do3cc » 05 Dec 2014, 16:02


I am trying to use the usb_modeswitch with my Alcatel onetouch X602D
There was a thread here explaining that I have to change the configuration profile. ... 02d#p13926

For me, this triggers a SegFault.

After Relearning C, I think I drilled it down to improper handling of a global variable for the configuration descriptor.
In my case, get_current_configuration() gets called twice in one run. In the first run, the global variable active_config is NULL, but get_current_configuration needs a active_config, so it gets an active_config and stores the pointer in the global variable. At the end of the method, the active_config is freed, but the global variable still points to the same, now freed adress.
On the second run, no get_active_config from libusb gets called, so no new address gets assigned. Now usb_modeswitch tries to free the descriptor again at the end of the method. Here comes the segfault.
There are multiple locations in the code where an active config gets loaded, then freed but the global variable does not get NULLed. I NULLed the variable in the source in this one invocation, now I don't get segfaults any more. Unfortunately I now get the notification that changing the configuration has failed...

Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Segfault with freeing active configuration twice

Post by Josh » 14 Dec 2014, 19:48

Thanks for the report - I'll look into it.

Post Reply