3fe4305d047b9d7cd7fd40788d871ea696a49fb3
braney
  Wed May 27 14:38:11 2026 -0700
lolly: skip items that do not quickLift instead of reusing a stale pop

In lollyLoadItems, when quickLiftIntervalsToBed returned NULL (an item
that did not lift to the target assembly), the loop fell through and
reused a stale/uninitialized pop pointer, writing item fields into the
wrong memory.  This clobbered the lolly subtrack's trackDb track/
shortLabel/type pointers, later surfacing as "Can't find tdb for
subtrack ... was getSubtrackTdb called on non-subtrack?".  Initialize
pop to NULL and continue past items that do not lift.

refs #37646

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

diff --git src/hg/hgTracks/lollyTrack.c src/hg/hgTracks/lollyTrack.c
index bc714061350..a29c88174ba 100644
--- src/hg/hgTracks/lollyTrack.c
+++ src/hg/hgTracks/lollyTrack.c
@@ -332,31 +332,31 @@
     //lollyCart->radius = 4;
     lollyCart->height =  lollyCart->origHeight / 1.5;
     }
 struct lm *lm = lmInit(0);
 struct bbiFile *bbi =  fetchBbiForTrack(tg);
 struct asObject *as = bigBedAsOrDefault(bbi);
 struct bigBedInterval *bb, *bbList; 
 char *quickLiftFile = cloneString(trackDbSetting(tg->tdb, "quickLiftUrl"));
 struct hash *chainHash = NULL;
 if (quickLiftFile)
     bbList = quickLiftGetIntervals(quickLiftFile, bbi, chromName, winStart, winEnd, &chainHash);
 else
     bbList =  bigBedIntervalQuery(bbi, chromName, winStart, winEnd, 0, lm);
 char *bedRow[bbi->fieldCount];
 char startBuf[16], endBuf[16];
-struct lolly *popList = NULL, *pop;
+struct lolly *popList = NULL, *pop = NULL;
 
 unsigned lollyField = getField(tg->tdb, "lollyField", as, 5);  // we use the score field by default
 int lollySizeField = getField(tg->tdb, "lollySizeField", as, -1);  // no size field by default
 
 double minVal = DBL_MAX, maxVal = -DBL_MAX;
 //double sumData = 0.0, sumSquares = 0.0;
 unsigned count = 0;
 
 int trackHeight = tg->lollyCart->height;
 struct bigBedFilter *filters = bigBedBuildFilters(cart, bbi, tg->tdb);
 char *mouseOverField = cartOrTdbString(cart, tg->tdb, "mouseOverField", NULL);
 int mouseOverIdx = bbExtraFieldIndex(bbi, mouseOverField) ;
 
 char *mouseOverPattern = NULL;
 char **fieldNames = NULL;
@@ -393,30 +393,32 @@
     if (quickLiftFile)
         {
         struct bed *bed;
         if ((bed = quickLiftIntervalsToBed(bbi, chainHash, bb)) != NULL)
             {
             // don't draw lollies off the screen
             if (bed->chromStart < winStart)
                 continue;
 
             AllocVar(pop);
             slAddHead(&popList, pop);
             pop->val = val;
             pop->start = bed->chromStart;
             pop->end = bed->chromEnd;
             }
+        else 
+            continue;
         }
     else
         {
         // don't draw lollies off the screen
         if (atoi(bedRow[1]) < winStart)
             continue;
 
         AllocVar(pop);
         slAddHead(&popList, pop);
         pop->val = val;
         pop->start = atoi(bedRow[1]);
         pop->end = atoi(bedRow[2]);
         }
     pop->name = cloneString(bedRow[3]);
     pop->radius = -1;