[racket] users Digest, Vol 109, Issue 70

From: Moshe Deutsch (moshedeutsch115 at gmail.com)
Date: Mon Sep 29 16:41:57 EDT 2014

Please take me off the list

Thanks

On Sun, Sep 28, 2014 at 4:29 PM,  <users-request at racket-lang.org> wrote:
> Send users mailing list submissions to
>         users at racket-lang.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.racket-lang.org/users/listinfo
> or, via email, send a message with subject or body 'help' to
>         users-request at racket-lang.org
>
> You can reach the person managing the list at
>         users-owner at racket-lang.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of users digest..."
>
>
> [Racket Users list:
>  http://lists.racket-lang.org/users ]
>
>
> Today's Topics:
>
>    1. Re: Help debugging a ffi crash (Eric Dobson)
>    2. How to document a field? (Roman Klochkov)
>    3. Re: proof assistants, DrRacket and Bootstrap (Bill Richter)
>    4. Re: aws/glacier: credential scope (Greg Hendershott)
>    5. Re: aws/glacier: credential scope (Norman Gray)
>    6. Re: aws/glacier: credential scope (Greg Hendershott)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 28 Sep 2014 11:15:33 -0700
> From: Eric Dobson <eric.n.dobson at gmail.com>
> To: Matthew Flatt <mflatt at cs.utah.edu>
> Cc: "users at racket-lang.org" <users at racket-lang.org>
> Subject: Re: [racket] Help debugging a ffi crash
> Message-ID:
>         <CAAEHQ5tWAKzi5AizADUH9smVsNXpYTbmxtO3teGm9Zj8ZDUnLg at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> That is almost surely it, thanks for the second pair of eyes. I had
> similar issues with a different type that I thought was a pointer but
> was actually a struct, but that one I couldn't even get a single call
> to work so it was much more obvious something was up.
>
> On Sun, Sep 28, 2014 at 11:08 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>> Looking at
>>
>>   http://clang.llvm.org/doxygen/CXString_8h_source.html
>>
>> it seems that CXString as returned by clang_getCursorSpelling() is not
>> a pointer:
>>
>>  typedef struct {
>>    const void *data;
>>    unsigned private_flags;
>>  } CXString;
>>
>> If that's right, I'm a little surprised that `cursor-spelling` works
>> --- but when you get representation wrong, strange things can happen,
>> including something working when it shouldn't.
>>
>> Am I looking at the right library/definitions?
>>
>> At Sun, 28 Sep 2014 10:48:06 -0700, Eric Dobson wrote:
>>> I'm trying to debug an FFI crash that I'm seeing, and because it is
>>> dealing with C code the error just presents as a segfault. I believe I
>>> have tracked down what is causing the problem, but don't understand
>>> how it could be doing so.
>>>
>>> I have two racket functions which take a "cursor" (the foreign
>>> libraries object) and return a string representation of it, which I'm
>>> trying to use for debugging.
>>>
>>> (define raw-clang-get-cstring
>>>   (get-ffi-obj "clang_getCString" lib-clang
>>>     (_fun _pointer -> _string)))
>>>
>>> (define raw-cursor-spelling
>>>  (get-ffi-obj "clang_getCursorSpelling" lib-clang
>>>    (_fun _CXCursor -> _pointer)))
>>>
>>> (define (cursor-spelling c)
>>>   (raw-clang-get-cstring (raw-cursor-spelling c)))
>>>
>>> (define cursor-spelling2
>>>  (get-ffi-obj "clang_getCursorSpelling" lib-clang
>>>    (_fun _CXCursor -> (make-ctype _pointer values (? (v)
>>> (raw-clang-get-cstring v))))))
>>>
>>> If I use cursor-spelling, I have not been able to trigger a crash. But
>>> if I use cursor-spelling2 I can reliably trigger a crash.
>>>
>>> Is there anything obvious on how these functions are different?
>>> Because they look to me like they should be doing the same thing. If
>>> it would be helpful I can try to get my code in a portable enough
>>> shape so that it will work/crash on another machine.
>>>
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 28 Sep 2014 22:39:54 +0400
> From: Roman Klochkov <kalimehtar at mail.ru>
> To: racket users list <users at racket-lang.org>
> Subject: [racket] How to document a field?
> Message-ID: <1411929594.923492574 at f67.i.mail.ru>
> Content-Type: text/plain; charset="utf-8"
>
>  At  http://docs.racket-lang.org/scribble/doc-classes.html I see classes, interfaces, methods, but don't see fields.
>
> How to document them? Via @defthing or is there some syntax with (get-field ..) (set-field! ...) template like @defparam ?
>
>
> --
> Roman Klochkov
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.racket-lang.org/users/archive/attachments/20140928/ac478807/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 28 Sep 2014 13:51:26 -0500
> From: Bill Richter <richter at math.northwestern.edu>
> Cc: users at racket-lang.org
> Subject: Re: [racket] proof assistants, DrRacket and Bootstrap
> Message-ID:
>         <201409281851.s8SIpQMx006764 at poisson.math.northwestern.edu>
>
> Matthias & Prabhakar, I think I see what you're saying now.  I need the camlp parser to turn my dialect-expressions into trees.  Then I turn my  tree into standard expressions just as one does in Scheme.  The only differences is that in Scheme we have the quote function that skips the parsing step.  So your ML code
>
> MF>   type ast = VAR of String | LAM of String * ast | APP of ast * ast | CONST of int | ADD of ast * ast
> MF>   type val = BASIC of int | FUNCTION of val -> val | ...
>
> looks a lot like the HOL Light definition of preterms:
>
> type preterm = Varp of string * pretype       (* Variable           - v      *)
>              | Constp of string * pretype     (* Constant           - c      *)
>              | Combp of preterm * preterm     (* Combination        - f x    *)
>              | Absp of preterm * preterm      (* Lambda-abstraction - \x. t  *)
>              | Typing of preterm * pretype;;  (* Type constraint    - t : ty *)
>
> and so we can see one of these preterms in a standard term:
>
> # preterm_of_term `x + y`;;
> val it : preterm =
>   Combp
>    (Combp
>      (Constp ("+",
>        Ptycon ("fun",
>         [Ptycon ("num", []);
>          Ptycon ("fun", [Ptycon ("num", []); Ptycon ("num", [])])])),
>      Varp ("x", Ptycon ("num", []))),
>    Varp ("y", Ptycon ("num", [])))
>
> So the Scheme story works fine except that I haven't understood camlp or how HOL Light turns expressions `[...]` into preterms.  But I feel better about investing the time into learning camlp now that I see the Scheme story remains intact in HOL Light. And you're right  about my ignorance:
>
> MF> 1. HtDP explains the above in a couple of sections.
>
> Right, there's something I seem not to have understood in either Scheme or ML, how when we create and evaluate our trees we retain the values of our variables.  I can figure that out, and HtDP sounds like a good place to start.
>
> PR> A Racketeer would probably tell you to use macros to define your
> PR> dialect, instead of using an eval hack. The corresponding tool for
> PR> OCaml is camlp4, and it sounds as if it would be worth your time
> PR> to learn it thoroughly.
>
> That's an interesting comparison, and since macros, maybe I can learn to like camlp.  In fact, maybe I ought to learn something about racket macros first.
>
> --
> Best,
> Bill
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 28 Sep 2014 16:01:20 -0400
> From: Greg Hendershott <greghendershott at gmail.com>
> To: Norman Gray <norman at astro.gla.ac.uk>
> Cc: users at racket-lang.org
> Subject: Re: [racket] aws/glacier: credential scope
> Message-ID:
>         <CAGspUn0tqgSVUaDuk1C3Wb6hm6s6nQ2ps-j42pkJJSY2UESL0A at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Hi, Norman.
>
> I logged an issue for this:
>
>   https://github.com/greghendershott/aws/issues/32
>
> I see the problem (or at least the main problem) and will push a fix.
>
> The bug is embarrassing, not just because it's such a silly mistake,
> but it's something a unit test could have caught. (I could say that
> doing unit tests for Glacier is challenging, because the retrieval
> process can take hours. Although that's true, I could have done more
> to test _some_ operations working among various regions.)
>
> On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray <norman at astro.gla.ac.uk> wrote:
>>
>> Greetings.
>>
>> I'm trying to use the aws/glacier package, and running into a problem where I'm being told:
>>
>>     Credential should be scoped to a valid region, not 'eu-west-1'
>>
>> I'm following the instructions at <https://github.com/greghendershott/aws/blob/master/aws/manual.md>
>>
>> My test code is:
>>
>>     % cat glacier.rkt
>>     #lang racket/base
>>
>>     (require aws/glacier
>>              aws/keys)
>>
>>     (define vault "testvault")
>>     (region "eu-west-1")
>>     (read-keys "aws-zbu-credentials") ; local file
>>
>>     (module+ main
>>       (printf "region=~a~%" (region))
>>       (printf "Vaults: ~s~%" (list-vaults))
>>       (printf "...specifically: ~s~%" (describe-vault vault)))
>>
>> Running this produces:
>>
>>     % racket glacier.rkt
>>     region=eu-west-1
>>     aws: HTTP/1.1 403 Forbidden
>>     x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4
>>     Content-Type: application/json
>>     Content-Length: 129
>>     Date: Sat, 27 Sep 2014 18:35:50 GMT
>>
>>      {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"}
>>     HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. "
>>       context...:
>>        check-response
>>        /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68
>>        request/redirect/uri
>>        (submod /checkouts/me/code/zbu/glacier.rkt main): [running body]
>>
>> Things I thought of:
>>
>>   * Printing (public-key)/(private-key) indicates that the credentials are being read correctly.
>>   * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message.
>>   * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in <http://docs.aws.amazon.com/general/latest/gr/rande.html> and which does have a host at http://glacier.eu-west-1.amazonaws.com
>>   * As far as I can see, credentials are _not_ scoped, but are all at us-east-1.
>>   * <http://docs.aws.amazon.com/general/latest/gr/signature-v4-troubleshooting.html> says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region.
>>   * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what.
>>
>> If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/"  That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service.
>>
>> I don't see any other (region) equivalents for the other services supported by the package.  Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration?
>>
>> Thanks for any pointers.
>>
>> All the best,
>>
>> Norman
>>
>>
>> --
>> Norman Gray  :  http://nxg.me.uk
>> SUPA School of Physics and Astronomy, University of Glasgow, UK
>>
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sun, 28 Sep 2014 21:29:03 +0100
> From: Norman Gray <norman at astro.gla.ac.uk>
> To: Greg Hendershott <greghendershott at gmail.com>
> Cc: users at racket-lang.org
> Subject: Re: [racket] aws/glacier: credential scope
> Message-ID: <FE320180-07AE-43E8-AE51-3AA566329E67 at astro.gla.ac.uk>
> Content-Type: text/plain; charset=us-ascii
>
>
> Greg, hello.
>
> On 2014 Sep 28, at 21:01, Greg Hendershott <greghendershott at gmail.com> wrote:
>
>> I logged an issue for this:
>>
>>  https://github.com/greghendershott/aws/issues/32
>
> Ah: I wondered if the problem might be related to that.
>
>> The bug is embarrassing, not just because it's such a silly mistake,
>> but it's something a unit test could have caught. (I could say that
>> doing unit tests for Glacier is challenging, because the retrieval
>> process can take hours.
>
> I can imagine how protracted that would be ... *shudder*.
>
> Thanks for looking at this.
>
> Also, Frank:
>
>> What happens if you read-keys before setting the region?
>
> Thanks for this suggestion: I did try that just a little earlier, but it didn't make any difference.
>
> All the best,
>
> Norman
>
>
> --
> Norman Gray  :  http://nxg.me.uk
> SUPA School of Physics and Astronomy, University of Glasgow, UK
>
>
>
>
> ------------------------------
>
> Message: 6
> Date: Sun, 28 Sep 2014 16:29:12 -0400
> From: Greg Hendershott <greghendershott at gmail.com>
> To: Norman Gray <norman at astro.gla.ac.uk>
> Cc: users at racket-lang.org
> Subject: Re: [racket] aws/glacier: credential scope
> Message-ID:
>         <CAGspUn2au5xydsH+o9E2Y3JTA1iQbPRX58zRcitywAPWh5Djng at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I pushed a fix, including running the tests across a few different AWS
> regions. They pass.
>
> I clicked "update" on pkgs.racket-lang.org. But it seems to be slower
> than usual to refresh. After it does, you can `raco pkg update aws` to
> get the fix.
>
> On Sun, Sep 28, 2014 at 4:01 PM, Greg Hendershott
> <greghendershott at gmail.com> wrote:
>> Hi, Norman.
>>
>> I logged an issue for this:
>>
>>   https://github.com/greghendershott/aws/issues/32
>>
>> I see the problem (or at least the main problem) and will push a fix.
>>
>> The bug is embarrassing, not just because it's such a silly mistake,
>> but it's something a unit test could have caught. (I could say that
>> doing unit tests for Glacier is challenging, because the retrieval
>> process can take hours. Although that's true, I could have done more
>> to test _some_ operations working among various regions.)
>>
>> On Sat, Sep 27, 2014 at 4:14 PM, Norman Gray <norman at astro.gla.ac.uk> wrote:
>>>
>>> Greetings.
>>>
>>> I'm trying to use the aws/glacier package, and running into a problem where I'm being told:
>>>
>>>     Credential should be scoped to a valid region, not 'eu-west-1'
>>>
>>> I'm following the instructions at <https://github.com/greghendershott/aws/blob/master/aws/manual.md>
>>>
>>> My test code is:
>>>
>>>     % cat glacier.rkt
>>>     #lang racket/base
>>>
>>>     (require aws/glacier
>>>              aws/keys)
>>>
>>>     (define vault "testvault")
>>>     (region "eu-west-1")
>>>     (read-keys "aws-zbu-credentials") ; local file
>>>
>>>     (module+ main
>>>       (printf "region=~a~%" (region))
>>>       (printf "Vaults: ~s~%" (list-vaults))
>>>       (printf "...specifically: ~s~%" (describe-vault vault)))
>>>
>>> Running this produces:
>>>
>>>     % racket glacier.rkt
>>>     region=eu-west-1
>>>     aws: HTTP/1.1 403 Forbidden
>>>     x-amzn-RequestId: Un3-L2zlaJBPyrIVKJrWuQcqtMMYQAr34gYUOSScg6Qepc4
>>>     Content-Type: application/json
>>>     Content-Length: 129
>>>     Date: Sat, 27 Sep 2014 18:35:50 GMT
>>>
>>>      {"message":"Credential should be scoped to a valid region, not 'eu-west-1'. ","code":"InvalidSignatureException","type":"Client"}
>>>     HTTP 403 "Forbidden". AWS Code="InvalidSignatureException" Message="Credential should be scoped to a valid region, not 'eu-west-1'. "
>>>       context...:
>>>        check-response
>>>        /Users/norman/Library/Racket/6.1/pkgs/aws/aws/glacier.rkt:97:22: temp68
>>>        request/redirect/uri
>>>        (submod /checkouts/me/code/zbu/glacier.rkt main): [running body]
>>>
>>> Things I thought of:
>>>
>>>   * Printing (public-key)/(private-key) indicates that the credentials are being read correctly.
>>>   * When I change the argument of (region) to "us-west-1", that's the region that appears in the error message.
>>>   * My "testvault" vault is in eu-west-1 (and this is indeed one of the valid regions for glacier, reported in <http://docs.aws.amazon.com/general/latest/gr/rande.html> and which does have a host at http://glacier.eu-west-1.amazonaws.com
>>>   * As far as I can see, credentials are _not_ scoped, but are all at us-east-1.
>>>   * <http://docs.aws.amazon.com/general/latest/gr/signature-v4-troubleshooting.html> says that "IAM [...] accepts only us-east-1 as its region specification", so I'm taking it that (region) is for setting the _vault_'s region.
>>>   * I'm not a great AWS expert, so I could have something in my setup broken; but if so, I've no clue what.
>>>
>>> If, however, I change the (region) argument to "us-east-1", I get a different error message "User: arn:aws:iam::786725553169:user/zbu is not authorized to perform: glacier:ListVaults on resource: arn:aws:glacier:us-east-1:786725553169:vaults/"  That makes sense, since there's no such vault, but it's interesting that it gets _further_ when the (region) matches the region for the IAM service.
>>>
>>> I don't see any other (region) equivalents for the other services supported by the package.  Is that because all of the other services supported by the package are supported by all the AWS regions, or am I missing a configuration?
>>>
>>> Thanks for any pointers.
>>>
>>> All the best,
>>>
>>> Norman
>>>
>>>
>>> --
>>> Norman Gray  :  http://nxg.me.uk
>>> SUPA School of Physics and Astronomy, University of Glasgow, UK
>>>
>>>
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users
>
>
>
> End of users Digest, Vol 109, Issue 70
> **************************************


Posted on the users mailing list.