Re: [Hamlib-developer] Hamlib Segfault (rig with rig_set_trn along with dummy)
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: Stephane F. <f8...@fr...> - 2002-09-29 19:55:38
|
On Sat, Sep 28, 2002, Chuck Hemker wrote:
> Here is my entry for the Segfault-award :)
Congrat Chuck, you're in :)
> If you:
> Open one rig (I happen to use an Icom).
> call rig_set_trn to enable notifications from the rig if you turn the knob.
> Open dummy as a second rig.
> Try to do anything with the first rig.
> It will segfault in search_rig_and_decode when attempting to check to see if
> there is any input on the fd associated with dummy. Because dummy doesn't have
> a fd when it tries to call FD_SET with a fd of -1.
>
> There's even a note at the top of search_rig_and_decode saying it assumes the
> fd is valid (>=0).
I guess the dummy backend was created later to the event support.
> I'd submit a patch, but I wasn't sure how you wanted to fix it:
>
> 1. Dummy for now could be a special case that doesn't have a fd.
> (May blow up later when they start putting network interfaces on rigs)
> 2. Check for fd == -1
> 3. Do you want to check for input if rig_set_trn is not set for that rig?
woul be neat, but the rig state does not have such information. Maybe
this would be worth adding.
> 4. Something else?
yes, port type.
So this gives the followin line at beginning of search_rig_and_decode:
if (rig->state.rigport.type != RIG_PORT_SERIAL ||
rig->state.rigport.fd == -1)
return -1;
Thanks Chuck for the nice report. The fix has been commited.
Cheers,
Stephane
PS: in your test example, that's a very good habit to use rig_set_conf to
change some rig state. way to go. Acutally, conf.c should be augmented
one day to access every state field this way.
|