I have a read-only type data structure which must be shared between many packages from many developers. We recurse over it and make it read-only after creation using Internals::SvREADONLY before the other packages are loaded begin executing. However, some developers circumvented that with the same subroutine Internals::SvREADONLY. I'm contemplating taking a lexically scoped code ref to Internals::SvREADONLY and then redefining Internals::SvREADONLY to some subroutine which warns them "not to even think about it" when called. In some limited testing this seems to work.

Before I commit this change I was looking for some input on just how terribly bad this idea is. Does anybody know of unintended consequences or other reasons this could cause trouble? Are there other methods to circumvent data that has been marked read-only?

From what I read and tested breaking Internals::SvREADONLY didn't produce any visible problems. But as the monks have pointed out its far from air tight. The route were going now is adding a subroutine to the test suite that checks the DS after loading and executing the modules from other developers. It ensures that the DS is still marked readonly and that it hasn't changed been changed by comparing against an internal copy of the DS. When it discovers changes electric shocks are promptly delivered through the mouses to all SW developers


In reply to redefining Internals::SvREADONLY by ChiefAl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.