[ic] Cautious eval error handling
Jon Jensen
jon at endpoint.com
Sun Aug 23 01:09:01 UTC 2009
Interchange users,
A few months ago I had an adventure tracking down a very obscure bug in
Interchange that was caused by a check for $@ too long after an eval was
called. The biggest reason it was hard to find was that even a logging
command had an eval that reset $@, making later checks fail. The fix was
here:
http://git.icdevgroup.org/?p=interchange.git;a=commitdiff;h=9f9d7c578da699776722641ec3c1edd4b51f3a99
That reinforces that it's good hygiene to only check $@ immediately after
the routine that sets it. And any routine expected to set it should
guarantee that it's cleared when there's no error.
I decided it would be good to go through the whole Interchange codebase
looking for any potential problems, and clean them up to save
troubleshooting and unexpected corner case failures later.
I'm only about halfway through and am committing most changes separately
so that they're small and have per-case explanations. I've pushed the work
so far to a new GitHub branch:
http://github.com/jonjensen/interchange/commits/cautious-eval-errors/
Many of the changes should make no difference at all right now, but could
prevent later problems and/or clarify the intent of the code.
Others change the way code checks for errors, trying to avoid $@. So far
the only functions I think are valid for setting $@ are eval, Safe's
reval, and Interchange's string_to_ref. When I come across others I'm
trying to have Interchange use the return code & whatever API exists
rather than rely on $@.
I'd appreciate any feedback or offers to help review & test, if any of you
is interested.
Thanks,
Jon
--
Jon Jensen
End Point Corporation
http://www.endpoint.com/
More information about the interchange-users
mailing list