{"id":25,"date":"2009-07-31T11:58:00","date_gmt":"2009-07-31T09:58:00","guid":{"rendered":"\/post\/2009\/07\/31\/The-Nested-Procedure-Menace-in-Oberon.aspx"},"modified":"2014-02-22T21:06:52","modified_gmt":"2014-02-22T20:06:52","slug":"the-nested-procedure-menace-in-oberon","status":"publish","type":"post","link":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/","title":{"rendered":"The Nested Procedure Menace in Oberon"},"content":{"rendered":"

Just stumbled across this article and interview with Niklaus Wirth<\/a>, from July 2 this year. There are quite a few interesting things in there, and also historical facts which are good to know. I’ve run into Wirth a couple of times when I was doing my master thesis at ETH. In fact, I’ve done my thesis in the group which was originally headed by Wirth and now is headed by Gutknecht (also a well-known name from the article).<\/p>\n

That’s also when I detected the following flaw in Oberon. Imagine the following module:<\/p>\n

\r\nMODULE NestedProcTest;\r\n\r\nVAR SomeProc: PROCEDURE(val: LONGINT);\r\n\r\n    PROCEDURE ProcA();\r\n    VAR someLocalVar: LONGINT;\r\n\r\n        PROCEDURE NestedProc(val: LONGINT);\r\n        BEGIN\r\n            someLocalVar := val\r\n        END NestedProc;\r\n\r\n    BEGIN\r\n        someLocalVar := 1234H;\r\n        SomeProc := NestedProc;\r\n        NestedProc(5678H);\r\n        SomeProc(0DEADH)\r\n    END ProcA;\r\n\r\nEND NestedProcTest.\r\n<\/pre>\n

On line 15 we assign the nested procedure (‘NestedProc’) to the procedure variable ‘SomeProc’. This is valid because the signatures match, right? Wrong.<\/strong> The signature for ‘NestedProc’ is different: Because nested procedures have access to the parent procedures’ variables, their signature is added a hidden parameter, the so called Static Link<\/em>. If this parameter is not passed to the procedure when it’s called, the procedure is going to read either its local variables or its parents’ variables from a wrong place (depending on the actual implementation of the calling convention). This of course is wrong and can even make this code crash in case we’d read from an unallocated or protected region.<\/p>\n

That’s why I recommended disallowing the assignment of nested procedures to procedure variables. Back in 2006 I have also proposed a change for the Oberon compiler which comes with BlueBottle<\/a>, but I cannot tell at this point whether it has made it in to the release or not.<\/p>\n

This and other findings can be found in the report for my master thesis (dated March 2006):\u00c2\u00a0Improved Stackmanagement in the Active Object Kernel – Master Thesis, Roger Keller<\/a> (742.85 kb)<\/p>\n

<\/p>","protected":false},"excerpt":{"rendered":"

Just stumbled across this article and interview with Niklaus Wirth, from July 2 this year. There are quite a few interesting things in there, and also historical facts which are good to know. I’ve run into Wirth a couple of times when I was doing my master thesis at ETH. In fact, I’ve done my … Continue reading “The Nested Procedure Menace in Oberon”<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[61],"tags":[46,12,18,45],"yoast_head":"\nThe Nested Procedure Menace in Oberon - Tales of a Code Monkey<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Nested Procedure Menace in Oberon - Tales of a Code Monkey\" \/>\n<meta property=\"og:description\" content=\"Just stumbled across this article and interview with Niklaus Wirth, from July 2 this year. There are quite a few interesting things in there, and also historical facts which are good to know. I’ve run into Wirth a couple of times when I was doing my master thesis at ETH. In fact, I’ve done my … Continue reading "The Nested Procedure Menace in Oberon"\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/\" \/>\n<meta property=\"og:site_name\" content=\"Tales of a Code Monkey\" \/>\n<meta property=\"article:published_time\" content=\"2009-07-31T09:58:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-02-22T20:06:52+00:00\" \/>\n<meta name=\"author\" content=\"roger\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"roger\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/\",\"url\":\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/\",\"name\":\"The Nested Procedure Menace in Oberon - Tales of a Code Monkey\",\"isPartOf\":{\"@id\":\"https:\/\/cymbeline.ch\/#website\"},\"datePublished\":\"2009-07-31T09:58:00+00:00\",\"dateModified\":\"2014-02-22T20:06:52+00:00\",\"author\":{\"@id\":\"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916\"},\"breadcrumb\":{\"@id\":\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cymbeline.ch\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Nested Procedure Menace in Oberon\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cymbeline.ch\/#website\",\"url\":\"https:\/\/cymbeline.ch\/\",\"name\":\"Tales of a Code Monkey\",\"description\":\"... the adventures of a guy making software.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cymbeline.ch\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916\",\"name\":\"roger\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cymbeline.ch\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g\",\"caption\":\"roger\"},\"sameAs\":[\"https:\/\/www.cymbeline.ch\"],\"url\":\"https:\/\/cymbeline.ch\/author\/roger\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Nested Procedure Menace in Oberon - Tales of a Code Monkey","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/","og_locale":"en_US","og_type":"article","og_title":"The Nested Procedure Menace in Oberon - Tales of a Code Monkey","og_description":"Just stumbled across this article and interview with Niklaus Wirth, from July 2 this year. There are quite a few interesting things in there, and also historical facts which are good to know. I’ve run into Wirth a couple of times when I was doing my master thesis at ETH. In fact, I’ve done my … Continue reading \"The Nested Procedure Menace in Oberon\"","og_url":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/","og_site_name":"Tales of a Code Monkey","article_published_time":"2009-07-31T09:58:00+00:00","article_modified_time":"2014-02-22T20:06:52+00:00","author":"roger","twitter_misc":{"Written by":"roger","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/","url":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/","name":"The Nested Procedure Menace in Oberon - Tales of a Code Monkey","isPartOf":{"@id":"https:\/\/cymbeline.ch\/#website"},"datePublished":"2009-07-31T09:58:00+00:00","dateModified":"2014-02-22T20:06:52+00:00","author":{"@id":"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916"},"breadcrumb":{"@id":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cymbeline.ch\/2009\/07\/31\/the-nested-procedure-menace-in-oberon\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cymbeline.ch\/"},{"@type":"ListItem","position":2,"name":"The Nested Procedure Menace in Oberon"}]},{"@type":"WebSite","@id":"https:\/\/cymbeline.ch\/#website","url":"https:\/\/cymbeline.ch\/","name":"Tales of a Code Monkey","description":"... the adventures of a guy making software.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cymbeline.ch\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916","name":"roger","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cymbeline.ch\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g","caption":"roger"},"sameAs":["https:\/\/www.cymbeline.ch"],"url":"https:\/\/cymbeline.ch\/author\/roger\/"}]}},"_links":{"self":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":5,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":150,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts\/25\/revisions\/150"}],"wp:attachment":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}