# StreamingLazyListTesting may have a leak

Bug introduced in 10.2 and fixed in 10.3

Version 10.2; Win64 Enterprise.

I'm seeing this message...

data::shdw: Symbol data appears in multiple contexts {StreamingLazyListTesting, Global}; definitions in context StreamingLazyListTesting may shadow or be shadowed by other definitions.

... while executing some transformations on a big Dataset. I'm not convinced that I created the Globaldata symbol explicitly; it's certainly the name of local symbols within Modules I have though.

I wonder though if there is a risk of a collision if I actually give data a value now.

• Can you provide some code that reproduces this? This should not affect anything, because StreamingLazyListTesting  should not be on the $ContextPath, but this is certainly not a proper behavior (I am the developer of Streaming module). I will look into this, but it would be easier to do with some code reproducing the problem. – Leonid Shifrin Jul 16 '15 at 11:38 • I'll have a go. Of course it happens in a fairly extensive bit of code which I can't post due to corporate policy but I'll see if I can reproduce in a small example. In the interim my$ContextPath is {StreamingLoader,IconizeLoader,CloudObjectLoader,PacletManager,System,Global} and I've just seen a variant where its a collision with a temporary symbol... data\$::shdw: Symbol data\$ appears in multiple contexts {StreamingLazyListTesting ,Global }; – Ymareth Jul 16 '15 at 13:04
• @LeonidShifrin I've actually seen this myself, but only occasionally. – Stefan R Jul 16 '15 at 17:14
• @LeonidShifrin I've added a response that contains minimal reproduction steps, a speculative diagnosis and a partial work-around. – WReach Jul 18 '15 at 15:13

UPDATE The behaviour no longer occurs in version 10.3.

Here are minimal reproduction steps, from a fresh 10.2.0 kernel:

Module[{data = {{1}}}, data // Dataset // Transpose]

(*
data::shdw: Symbol data appears in multiple contexts {StreamingLazyListTesting,Global};
definitions in context StreamingLazyListTesting may shadow or
be shadowed by other definitions. >>
*)


After executing this, the $ContextPath looks suspicious: $ContextPath

(* {"StreamingLazyListTesting", "Streaming", "StreamingLoader",
"IconizeLoader", "CloudObjectLoader", "PacletManager",
"System", "Global"} *)


Diagnosis

Upon further investigation, the problem appears to involve two causes. First, the streaming framework unconditionally loads and executes its test suite, adding it to the context path. To see this, inspect the following file:

NotebookOpen @ FileNameJoin @


... and note the following lines near the top:

Get[FileNameJoin[{DirectoryName[$InputFileName],"TestDSL.m"}]]; Block[{$ContextPath},
Get[FileNameJoin[{DirectoryName[$InputFileName],"Tests.m"}]] ]  The second cause appears to be related to a cyclic dependency between the Streaming and Dataset packages (and possible between other packages as well). Dataset$AvailableBackends contains an implicit reference to StreamingCachedObject, triggering a load via PackageActivateLoad. The Streaming package, in turn, has an explicit dependency upon the Dataset package.

Normally, the act of auto-loading a package makes no changes to the $ContextPath. The presence of cyclic dependencies has historically interfered with the preservation of this path, so I suspect that it is at least part of the problem here. Partial Workaround The effects of both problems can be reduced by pre-loading the Streaming package as the first action of a new kernel session: Quiet @ Block[{$ContextPath}, Needs["Streaming"]]


Module[{data = {{1}}}, data // Dataset // Transpose]
$ContextPath (* {"StreamingLoader", "IconizeLoader", "CloudObjectLoader", "PacletManager", "System", "Global"} *)  The observant reader will have noticed the presence of Quiet in the preloading step. It is needed to suppress another symbol conflict between SystemToCamelCase and GeneralUtilitiesToCamelCase. It would appear that there are similar auto-loading issues elsewhere. Therefore this solution can only really be considered as a partial work-around. • I see that the new streaming packages will make for some interesting bedtime reading... ;D – WReach Jul 18 '15 at 7:13 • Thanks, your exhaustive answer puts me to shame :). You are right on all points. Somehow, I completely forgot that I have put the unconditional test loading code into the main loader. As to the cyclic dependencies, there is no way to completely avoid them, as far as I can tell, but we are trying to reduce them to the absolute minimum. In 10.2, the coupling between Streaming and Dataset is made weaker, and it will become weaker still. – Leonid Shifrin Jul 18 '15 at 16:29 • At the risk of sounding totally stupid, while the deeper architectural issues remain to be addressed, wouldn't it be helpful for the users if the chance of collisions in symbol names could be reduced? For example, using "streaming_lazylist_something_data" instead of just "data" in the corresponding package/framework? – paramecium Aug 10 '15 at 17:07 • @paramecium It doesn't work like that. The symbols do have long names anyway. The real problem here is that the context that wasn't supposed to be loaded, was unconditionally loaded (added to $ContextPath`). This is simply a bug (my bug), there is nothing deeper about it. It came out of an oversight: the testing part wasn't supposed to ever be loaded by the system in production mode. Part of this has to do with the fact that Streaming functionality is still not finalized, but, due to its coupling to Dataset and the autoloading mechanism, still gets loaded. – Leonid Shifrin Aug 10 '15 at 18:42