Bug 1073

Summary: rigol-ds: Driver crash when fetching logic channels
Product: libsigrok Reporter: Stefan Brüns <stefan.bruens>
Component: Driver: rigol-dsAssignee: Nobody <nobody>
Status: RESOLVED FIXED    
Severity: normal CC: uwe
Priority: Normal    
Version: unreleased development snapshot   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Stefan Brüns 2017-12-11 04:09:00 CET
Backtrace:

* thread #11, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x00000001005257a7 libsigrok.4.dylib`sr_scpi_send_variadic(scpi=0x0000000100526af0, format=":WAV:SOUR LA", args=0x000070000eccab10) at scpi.c:305 [opt]
   302          buf[len] = '\n';
   303
   304      /* Send command. */
-> 305      ret = scpi->send(scpi->priv, buf);
   306
   307      /* Free command buffer. */
   308      g_free(buf);
Target 0: (pulseview) stopped.
(lldb) bt
* thread #11, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x00000001005257a7 libsigrok.4.dylib`sr_scpi_send_variadic(scpi=0x0000000100526af0, format=":WAV:SOUR LA", args=0x000070000eccab10) at scpi.c:305 [opt]
    frame #1: 0x0000000100553e8f libsigrok.4.dylib`rigol_ds_config_set(sdi=0x000000010d8705a0, format=<unavailable>) at protocol.c:314 [opt]

The following line is the culprit:
https://sigrok.org/gitweb/?p=libsigrok.git;a=blob;f=src/hardware/rigol-ds/protocol.c;h=833104e890ddac4c74645a474b1a9077a011ffee;hb=HEAD#l224

---
 223         if (ch->type == SR_CHANNEL_LOGIC) {
 224                 if (rigol_ds_config_set(sdi->conn, ":WAV:SOUR LA") != SR_OK)
 225                         return SR_ERR;
 226         } else {
 227                 if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
 228                                 ch->index + 1) != SR_OK)
---

The "sdi->conn" is wrong, rigol_ds_config_set reqires a "struct sr_dev_inst*", i.e. just "sdi"
Comment 1 Uwe Hermann 2017-12-26 20:46:13 CET
Merged in bbcffe51d29343f7648e1e2f3b925dd571984bd3, thanks!