Weird behaviour when using dsm I am using Drupal 7 on a CentOS 6.5 box. I am trying to debug some code which produces the following error:


  User error: ImageMagick error 1: convert: no decode delegate for this
  image format  /tmp/thesis-163.OBJ.xml' @ constitute.c/ReadImage/503.
  convert: missing an image  filename
  jpg:/tmp/thesis-163.OBJ.PREVIEW.jpg' @
  convert.c/ConvertImageCommand/2800.  in _imagemagick_convert_exec()
  (line 519 of
  /var/www/html/sites/all/modules/imagemagick/imagemagick.module).


I can see that the problem is caused by the fact that ImageMagick is trying to make jpg out of a xml file. What the error is about, isn't really the issue. The issue is that, when I insert a dsm statement to check what is going and run the program again, the error goes away. If I comment out the dsm statement and run the program again the error returns. I have never seen this type of behaviour before and can't explain it. 

Unfortunately, I can't reproduce this behavior with a small snippet of code otherwise I would post it here.

Can someone explain why this is happening so that I can fix it?
You may be experiencing a Krumo side effect:

https://drupal.org/node/1855468

The problem is that PHP handles references to array elements in a risky way, see this article: PHP: References To Array Elements Are Risky

I haven't read the post deeply, and can't assure you have this problem, but you may try the workaround to see if it works: use Krumo NG.

Another way is to use dd to dump your traces to a file, see functions documentation: https://api.drupal.org/api/devel/devel.module/function/dd/7