Re: [racket-users] Segfault when using Graphical Debugger

2018-04-24 Thread Matthew Flatt
Reporting back: The problem was a bug in the bytecode compiler, and
commit 88d8ba00e0 is the repair.

The debugger works by modifying a program so that local variables are
mutable. Meanwhile, Philip's program uses the contracts in a way that
expands to `call-with-immediate-continuation-mark`. The compiler
mishandled `call-with-immediate-continuation-mark` on a `lambda` whose
argument variable is mutable.

At Sat, 21 Apr 2018 07:38:32 -0600, Matthew Flatt wrote:
> Thanks for the crash report! It doesn't immediately point to the
> problem, but it's good starting point. I'll ask you for more debugging
> help off-list, and we can report back here afterwards.
> 
> At Sat, 21 Apr 2018 05:11:10 -0500, Philip McGrath wrote:
> > In a particular module, I can consistently trigger a segfault by opening
> > DrRacket's graphical debugger, setting a breakpoint, and evaluating an
> > expression at the REPL. I am using Racket 6.12 on Mac OS 10.13.2: I have
> > not (yet) tried to reproduce this on other platforms.
> > 
> > Unfortunately I don't have anything approaching a minimal example: the file
> > that's triggering the issue is part of a large library.
> > 
> > I've attached the crash report in case that is illuminating. I'm happy to
> > help try to find the problem to the extent I can.
> > 
> > -Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Segfault when using Graphical Debugger

2018-04-21 Thread Matthew Flatt
Since the crash is consistent, can you try a snapshot build from
https://pre.racket-lang.org/ to check whether the crash persists?

The only repair I remember since v6.12 that seems relevant is
55ffc24011. Your crash is consistent with the bug fixed by that commit,
but my guess is that it's something else.

Assuming you do see a crash with the snapshot, then I'll ask that you
run in lldb and disassemble in the vicinity of the crash:

 $ lldb path/to/snapshot/racket
 (lldb) run -l drracket
 [... eventually, a crash at some instruction X ...]
 (llsb) disassem -s (X-100) -e (X+100)

replacing X above with the reported instruction address.

At Sat, 21 Apr 2018 05:11:10 -0500, Philip McGrath wrote:
> In a particular module, I can consistently trigger a segfault by opening
> DrRacket's graphical debugger, setting a breakpoint, and evaluating an
> expression at the REPL. I am using Racket 6.12 on Mac OS 10.13.2: I have
> not (yet) tried to reproduce this on other platforms.
> 
> Unfortunately I don't have anything approaching a minimal example: the file
> that's triggering the issue is part of a large library.
> 
> I've attached the crash report in case that is illuminating. I'm happy to
> help try to find the problem to the extent I can.
> 
> -Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Segfault when using Graphical Debugger

2018-04-21 Thread Matthew Flatt
Thanks for the crash report! It doesn't immediately point to the
problem, but it's good starting point. I'll ask you for more debugging
help off-list, and we can report back here afterwards.

At Sat, 21 Apr 2018 05:11:10 -0500, Philip McGrath wrote:
> In a particular module, I can consistently trigger a segfault by opening
> DrRacket's graphical debugger, setting a breakpoint, and evaluating an
> expression at the REPL. I am using Racket 6.12 on Mac OS 10.13.2: I have
> not (yet) tried to reproduce this on other platforms.
> 
> Unfortunately I don't have anything approaching a minimal example: the file
> that's triggering the issue is part of a large library.
> 
> I've attached the crash report in case that is illuminating. I'm happy to
> help try to find the problem to the extent I can.
> 
> -Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Segfault when using Graphical Debugger

2018-04-21 Thread Philip McGrath
In a particular module, I can consistently trigger a segfault by opening
DrRacket's graphical debugger, setting a breakpoint, and evaluating an
expression at the REPL. I am using Racket 6.12 on Mac OS 10.13.2: I have
not (yet) tried to reproduce this on other platforms.

Unfortunately I don't have anything approaching a minimal example: the file
that's triggering the issue is part of a large library.

I've attached the crash report in case that is illuminating. I'm happy to
help try to find the problem to the extent I can.

-Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Process:   DrRacket [12286]
Path:  /Applications/Racket 
v6.12/DrRacket.app/Contents/MacOS/DrRacket
Identifier:org.racket-lang.DrRacket
Version:   6.12 (6.12)
Code Type: X86-64 (Native)
Parent Process:??? [1]
Responsible:   DrRacket [12286]
User ID:   501

Date/Time: 2018-04-21 04:39:19.217 -0500
OS Version:Mac OS X 10.13.2 (17C88)
Report Version:12
Anonymous UUID:604CFB4A-63CB-15B4-CB40-57C502E63B8A

Sleep/Wake UUID:   EDFBFBDD-5374-4428-919C-B0F20EB37130

Time Awake Since Boot: 170 seconds
Time Since Wake:   51000 seconds

System Integrity Protection: enabled

Crashed Thread:0  Dispatch queue: com.apple.main-thread

Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:   EXC_I386_GPFLT
Exception Note:EXC_CORPSE_NOTIFY

Termination Signal:Segmentation fault: 11
Termination Reason:Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   ??? 0x000111a1b146 0 + 4590776646
1   ??? 0x00010da2276b 0 + 4523698027
2   ??? 0x00010da1ebf7 0 + 4523682807
3   Racket  0x00010c6505c2 _apply_native + 194
4   Racket  0x00010c65116a 
scheme_apply_chaperone + 1642
5   Racket  0x00010c61dba3 scheme_do_eval + 8627
6   Racket  0x00010c61fd1c 
_scheme_apply_multi_from_native + 396
7   ??? 0x00010fee83d5 0 + 4562256853
8   ??? 0x00010f0ac04d 0 + 4547330125
9   Racket  0x00010c61cffe scheme_do_eval + 5646
10  Racket  0x00010c622ce2 splice_execute + 306
11  Racket  0x00010c61eb09 scheme_do_eval + 
12569
12  Racket  0x00010c61fd1c 
_scheme_apply_multi_from_native + 396
13  ??? 0x00010da2039e 0 + 4523688862
14  Racket  0x00010c61cffe scheme_do_eval + 5646
15  Racket  0x00010c655207 
scheme_finish_apply_for_prompt + 535
16  Racket  0x00010c655535 
scheme_apply_for_prompt + 101
17  Racket  0x00010c645168 call_with_prompt + 
2568
18  ??? 0x00010da15383 0 + 4523643779
19  ??? 0x00010da1ffe4 0 + 4523687908
20  ??? 0x00010fee6089 0 + 4562247817
21  Racket  0x00010c61cffe scheme_do_eval + 5646
22  Racket  0x00010c655207 
scheme_finish_apply_for_prompt + 535
23  Racket  0x00010c655535 
scheme_apply_for_prompt + 101
24  Racket  0x00010c645168 call_with_prompt + 
2568
25  Racket  0x00010c61fd55 
_scheme_apply_multi_from_native + 453
26  ??? 0x00010fee83d5 0 + 4562256853
27  ??? 0x00010fee77c9 0 + 4562253769
28  Racket  0x00010c61cffe scheme_do_eval + 5646
29  Racket  0x00010c61fd1c 
_scheme_apply_multi_from_native + 396
30  ??? 0x00010da2177e 0 + 4523693950
31  Racket  0x00010c61cffe scheme_do_eval + 5646
32  Racket  0x00010c655207 
scheme_finish_apply_for_prompt + 535
33  Racket  0x00010c655535 
scheme_apply_for_prompt + 101
34  Racket  0x00010c645168 call_with_prompt + 
2568
35  ??? 0x00010da15383 0 + 4523643779
36  Racket  0x00010c61cffe scheme_do_eval + 5646
37  

Re: [racket-users] Segfault

2016-02-29 Thread Matthew Flatt
Your C code doesn't cooperate with the "3m" garbage collector, which is
the way Racket is built by default. For example, the object that `env`
references might be moved by the GC without the `env` variable being
updated.

See

 http://docs.racket-lang.org/inside/embedding.html#%28part._3m_.Embedding%29

for more information.



At Mon, 29 Feb 2016 18:01:11 -0800 (PST), Felipe Oliveira Carvalho wrote:
> I'm trying to embed Racket into a test C program (minimal.c). I can 
> successfully compile it with clang on Mac OS X, but the program segfaults 
> when 
> I try to run it. Any idea on what I'm doing wrong?
> 
> 
> 
> #include 
> #include 
> 
> #include "base.c"
> 
> static int our_scheme_main(Scheme_Env *env, int argc, char *argv[]) {
>   puts("our_scheme_main:");
> 
>   declare_modules(env);
>   scheme_namespace_require(scheme_intern_symbol("racket/base"));
> 
>   scheme_eval_string("(+ 2 1)", env);
> 
>   return 0;
> }
> 
> int main(int argc, char *argv[]) {
>   int status = scheme_main_setup(1, our_scheme_main, argc, argv);
> 
>   return status;
> }
> 
> 
> 
> 
> 
> felipe@Felipes-MacBook-Pro:~/code/embed_racket (master #%)$ make
> clang -I "/Users/felipe/Applications/Racket v6.4"/include/ --std=gnu99 -g -F 
> "/Users/felipe/Applications/Racket v6.4"/lib/ -framework Racket minimal.c
> 
> 
> felipe@Felipes-MacBook-Pro:~/code/embed_racket (master #%)$ ./a.out
> our_scheme_main:
> Segmentation fault: 11
> 
> 
> felipe@Felipes-MacBook-Pro:~/code/embed_racket (master #%)$ lldb ./a.out
> (lldb) target create "./a.out"
> Current executable set to './a.out' (x86_64).
> (lldb) r
> Process 8849 launched: './a.out' (x86_64)
> our_scheme_main:
> Process 8849 stopped
> * thread #1: tid = 0x3eb99, 0x000100400b99 Racket`do_scope_at_phase + 
> 249, 
> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
> address=0x0)
> frame #0: 0x000100400b99 Racket`do_scope_at_phase + 249
> Racket`do_scope_at_phase:
> ->  0x100400b99 <+249>: movzwl (%rsi), %eax
> 0x100400b9c <+252>: cmpl   $0x4f, %eax
> 0x100400b9f <+255>: jne0x100400cac   ; <+524>
> 0x100400ba5 <+261>: testb  $0x1, 0x2(%rsi)
> (lldb) thread backtrace
> * thread #1: tid = 0x3eb99, 0x000100400b99 Racket`do_scope_at_phase + 
> 249, 
> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
> address=0x0)
>   * frame #0: 0x000100400b99 Racket`do_scope_at_phase + 249
> frame #1: 0x0001003e6d39 Racket`stx_adjust_scope + 345
> frame #2: 0x0001003efbc1 Racket`scheme_stx_push_module_context + 161
> frame #3: 0x00010013cc9c Racket`scheme_top_introduce + 348
> frame #4: 0x000100143b8e Racket`compile_k + 670
> frame #5: 0x000100166f66 Racket`scheme_top_level_do_worker + 2102
> frame #6: 0x00010013cfbc Racket`scheme_eval + 220
> frame #7: 0x00010013ed53 Racket`do_eval_string_all + 627
> frame #8: 0x00010e96 
> a.out`our_scheme_main(env=0x0001026897e8, 
> argc=1, argv=0x7fff5fbff8e8) + 86 at minimal.c:12
> frame #9: 0x0001000d8323 Racket`call_with_basic + 147
> frame #10: 0x0001000d824a Racket`scheme_main_stack_setup + 330
> frame #11: 0x0001000d80f3 Racket`scheme_main_setup + 35
> frame #12: 0x00010e2b a.out`main(argc=1, argv=0x7fff5fbff8e8) 
> + 59 at minimal.c:18
> frame #13: 0x7fff96bbd5ad libdyld.dylib`start + 1
> frame #14: 0x7fff96bbd5ad libdyld.dylib`start + 1
> (lldb)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Segfault

2016-02-29 Thread Felipe Oliveira Carvalho
I'm trying to embed Racket into a test C program (minimal.c). I can 
successfully compile it with clang on Mac OS X, but the program segfaults when 
I try to run it. Any idea on what I'm doing wrong?



#include 
#include 

#include "base.c"

static int our_scheme_main(Scheme_Env *env, int argc, char *argv[]) {
  puts("our_scheme_main:");

  declare_modules(env);
  scheme_namespace_require(scheme_intern_symbol("racket/base"));

  scheme_eval_string("(+ 2 1)", env);

  return 0;
}

int main(int argc, char *argv[]) {
  int status = scheme_main_setup(1, our_scheme_main, argc, argv);

  return status;
}





felipe@Felipes-MacBook-Pro:~/code/embed_racket (master #%)$ make
clang -I "/Users/felipe/Applications/Racket v6.4"/include/ --std=gnu99 -g -F 
"/Users/felipe/Applications/Racket v6.4"/lib/ -framework Racket minimal.c


felipe@Felipes-MacBook-Pro:~/code/embed_racket (master #%)$ ./a.out
our_scheme_main:
Segmentation fault: 11


felipe@Felipes-MacBook-Pro:~/code/embed_racket (master #%)$ lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) r
Process 8849 launched: './a.out' (x86_64)
our_scheme_main:
Process 8849 stopped
* thread #1: tid = 0x3eb99, 0x000100400b99 Racket`do_scope_at_phase + 249, 
queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x0)
frame #0: 0x000100400b99 Racket`do_scope_at_phase + 249
Racket`do_scope_at_phase:
->  0x100400b99 <+249>: movzwl (%rsi), %eax
0x100400b9c <+252>: cmpl   $0x4f, %eax
0x100400b9f <+255>: jne0x100400cac   ; <+524>
0x100400ba5 <+261>: testb  $0x1, 0x2(%rsi)
(lldb) thread backtrace
* thread #1: tid = 0x3eb99, 0x000100400b99 Racket`do_scope_at_phase + 249, 
queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x0)
  * frame #0: 0x000100400b99 Racket`do_scope_at_phase + 249
frame #1: 0x0001003e6d39 Racket`stx_adjust_scope + 345
frame #2: 0x0001003efbc1 Racket`scheme_stx_push_module_context + 161
frame #3: 0x00010013cc9c Racket`scheme_top_introduce + 348
frame #4: 0x000100143b8e Racket`compile_k + 670
frame #5: 0x000100166f66 Racket`scheme_top_level_do_worker + 2102
frame #6: 0x00010013cfbc Racket`scheme_eval + 220
frame #7: 0x00010013ed53 Racket`do_eval_string_all + 627
frame #8: 0x00010e96 a.out`our_scheme_main(env=0x0001026897e8, 
argc=1, argv=0x7fff5fbff8e8) + 86 at minimal.c:12
frame #9: 0x0001000d8323 Racket`call_with_basic + 147
frame #10: 0x0001000d824a Racket`scheme_main_stack_setup + 330
frame #11: 0x0001000d80f3 Racket`scheme_main_setup + 35
frame #12: 0x00010e2b a.out`main(argc=1, argv=0x7fff5fbff8e8) + 
59 at minimal.c:18
frame #13: 0x7fff96bbd5ad libdyld.dylib`start + 1
frame #14: 0x7fff96bbd5ad libdyld.dylib`start + 1
(lldb)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#include 
#include 

#include "base.c"

static int our_scheme_main(Scheme_Env *env, int argc, char *argv[]) {
  puts("our_scheme_main:");

  declare_modules(env);
  scheme_namespace_require(scheme_intern_symbol("racket/base"));

  scheme_eval_string("(+ 2 1)", env);

  return 0;
}

int main(int argc, char *argv[]) {
  int status = scheme_main_setup(1, our_scheme_main, argc, argv);

  return status;
}