Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

andrewcmyers/master #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

andrewcmyers/master #5

wants to merge 9 commits into from

Conversation

npe9
Copy link
Owner

@npe9 npe9 commented Aug 7, 2022

  • Add missing prototypes.
  • Check in config file for now. Should be autogenerated.
  • Simple autoconf script.
  • The actual configuration script
  • Fix prototype
  • Fix newlines
  • Make PCLU driver program build again
  • Don't assume . in path
  • initial autotools support to make it easier to debug the compiler

@npe9
Copy link
Owner Author

npe9 commented Aug 7, 2022

@andrewcmyers I got sick of futzing with the makefiles so I made an initial autotools setup to get the compiler building with common compilers and flags. Make sure I haven't messed up too much.

This new setup allowed me to dig deeper into the problem. The relevant backtrace is:

* thread #1, queue = 'com.apple.main-thread', stop reason = step in
  * frame #0: 0x00000001000f2410 pclu`_chanOPgetb(chref=CLUREF @ rbx, bv=CLUREF @ rsi, ans=0x00007ff7bfefe660) at _chan.c:1381:18 [opt]
    frame #1: 0x00000001000bf7e6 pclu`streamOPgetc(st=CLUREF @ r12, ret_1=0x00007ff7bfefe6d0) at stream.c:2334:23 [opt]
    frame #2: 0x0000000100094dce pclu`p_envOPscanline(e=<unavailable>) at penv.c:3020:19 [opt]
    frame #3: 0x00000001000942c3 pclu`p_envOPnext_token(e=CLUREF @ rbx, ret_1=0x00007ff7bfefe768) at penv.c:1764:15 [opt]
    frame #4: 0x0000000100093df3 pclu`p_envOPreset(e=CLUREF @ rbx, comp=CLUREF @ r14, inst=CLUREF @ r15, errst=CLUREF @ r12) at penv.c:1376:11 [opt]
    frame #5: 0x00000001000b103d pclu`reset_stuff(e=CLUREF @ rbx, fn=CLUREF @ r13) at top2.c:1219:11 [opt]
    frame #6: 0x00000001000b0859 pclu`compile1(e=CLUREF @ r13, fn=CLUREF @ r14, ret_1=0x00007ff7bfefe898) at top2.c:611:11 [opt]
    frame #7: 0x00000001000b0475 pclu`compile_IB_1(iv_1=<unavailable>, locals=0x00007ff7bfefea60, iecode=0x00007ff7bfefe9d8) at top2.c:250:23 [opt]
    frame #8: 0x00000001000aeda9 pclu`all_input_names_IB_1(iv_1=<unavailable>, locals=0x00007ff7bfefe9c0, iecode=0x00007ff7bfefe9d8) at top1.c:4021:19 [opt]
    frame #9: 0x00000001000af3d9 pclu`all_derived_names(fs=CLUREF @ rbx, suffix=<unavailable>, tyo=<unavailable>, proc=<unavailable>, user_locals=<unavailable>, iecode=0x00007ff7bfefe9d8) at top1.c:4297:22 [opt]
    frame #10: 0x00000001000aeb4e pclu`all_input_names(args=CLUREF @ rbx, suffix=<unavailable>, tyo=<unavailable>, proc=<unavailable>, user_locals=<unavailable>, iecode=0x00007ff7bfefea68) at top1.c:3960:30 [opt]
    frame #11: 0x00000001000b01c9 pclu`compile(mode=<unavailable>, args=<unavailable>, outst=CLUREF @ r15, ret_1=0x00007ff7bfefeb70) at top2.c:86:22 [opt]
    frame #12: 0x00000001000aa227 pclu`process_commands(line=<unavailable>, tyo=CLUREF @ 0x00007ff7bfefeb60, from=<unavailable>, ret_1=<unavailable>) at top1.c:695:27 [opt]
    frame #13: 0x0000000100086833 pclu`initialize_specs at init.c:353:11 [opt]
    frame #14: 0x00000001000865a3 pclu`initialize_compiler(ret_1=0x00007ff7bfefec80) at init.c:211:11 [opt]
    frame #15: 0x00000001000a9b40 pclu`start_up at top1.c:98:19 [opt]
    frame #16: 0x000000010010200b pclu`main_2(_argc=<unavailable>, _argv=<unavailable>, _envp=<unavailable>) at util.c:233:11 [opt]
    frame #17: 0x000000010032951e dyld`start + 462

It looks like the token stream is invalid (it's bombing out on _chan$getb because the stream reference is poisoned). This is a huge PITA to debug because the compiler code is intermediate representation from a bootstrapped clu compiler. Cross referencing with the original clu files helps.

@npe9
Copy link
Owner Author

npe9 commented Aug 7, 2022

Looks like the poison is here: https://github.com/npe9/pclu/blob/master/code/sysasm/Opt/_chan.c#L170

So the next hypothesis is that the mode isn't getting set correctly when the channel is being opened.

Edit: a quick trip through the debugger confirms it.

@andrewcmyers
Copy link

andrewcmyers commented Aug 7, 2022

I may have changed line 172 because it was clearly bogus but maybe it was compensating for an error elsewhere. That !flags&1 is bad code but i think it causes rd to be set when the mode is read only. Note that ! has higher precedence than &

@andrewcmyers
Copy link

andrewcmyers commented Aug 7, 2022

The logic of this code is just wrong. You can't write stuff like (flags & O_RDWR). You might write (flags & O_ACCMODE) == O_RDWR, but the flags don't work the way this code seems to think they do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants