13
$\begingroup$

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 {Streaming`LazyList`Testing`, Global`}; definitions in context Streaming`LazyList`Testing` may shadow or be shadowed by other definitions.

... while executing some transformations on a big Dataset. I'm not convinced that I created the Global`data 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.

$\endgroup$
4
  • $\begingroup$ Can you provide some code that reproduces this? This should not affect anything, because Streaming`LazyList`Testing` 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. $\endgroup$ Commented Jul 16, 2015 at 11:38
  • $\begingroup$ 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` }; $\endgroup$
    – Ymareth
    Commented Jul 16, 2015 at 13:04
  • $\begingroup$ @LeonidShifrin I've actually seen this myself, but only occasionally. $\endgroup$
    – Stefan R
    Commented Jul 16, 2015 at 17:14
  • 2
    $\begingroup$ @LeonidShifrin I've added a response that contains minimal reproduction steps, a speculative diagnosis and a partial work-around. $\endgroup$
    – WReach
    Commented Jul 18, 2015 at 15:13

1 Answer 1

16
$\begingroup$

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 {Streaming`LazyList`Testing`,Global`};
            definitions in context Streaming`LazyList`Testing` may shadow or
            be shadowed by other definitions. >>
*)

After executing this, the $ContextPath looks suspicious:

$ContextPath

(* {"Streaming`LazyList`Testing`", "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 @
  {"SystemFiles","Components","Streaming","StreamingLoader.m"}

... 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 Streaming`CachedObject, triggering a load via Package`ActivateLoad. 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`"]]

This preloading action leaves us with a cleaner environment:

Module[{data = {{1}}}, data // Dataset // Transpose]
(* Dataset[...] *)

$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 System`ToCamelCase and GeneralUtilities`ToCamelCase. It would appear that there are similar auto-loading issues elsewhere. Therefore this solution can only really be considered as a partial work-around.

$\endgroup$
5
  • $\begingroup$ I see that the new streaming packages will make for some interesting bedtime reading... ;D $\endgroup$
    – WReach
    Commented Jul 18, 2015 at 7:13
  • $\begingroup$ 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. $\endgroup$ Commented Jul 18, 2015 at 16:29
  • $\begingroup$ 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? $\endgroup$
    – paramecium
    Commented Aug 10, 2015 at 17:07
  • $\begingroup$ @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. $\endgroup$ Commented Aug 10, 2015 at 18:42
  • $\begingroup$ - Thanks for the clear explanation, Leonid. $\endgroup$
    – paramecium
    Commented Aug 10, 2015 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.