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

luajit v2.1-20170405 (openresty 1.11.2.3) - unexpected symbol near 'pragma' #10

Closed
alonbg opened this issue Apr 23, 2017 · 10 comments
Closed

Comments

@alonbg
Copy link

alonbg commented Apr 23, 2017

Reproduced on openresty_1.11.2.3/luajit/bin/luajit with https://github.com/luapower/blake2/blob/master/blake2.lua

blake2.lua:125: unexpected symbol near 'pragma' at line 14

Does not reproduce on openresty/luajit2 tag v2.1-20170405 without the -msse4.2 compilation flags or latest commit excluded.

compiled on Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz (supports SSE4.2)

@alonbg
Copy link
Author

alonbg commented Apr 23, 2017

minimal reproduction code:

echo "require'ffi'.cdef[[ #pragma pack(push, 1)]]" | src/luajit -

src/luajit: stdin:1: unexpected symbol near 'pragma'
stack traceback:
	[C]: in function 'cdef'
	stdin:1: in main chunk
	[C]: at 0x00405060

compiler flag:
-msse4.2 - reproduced
-msse4.1 - not reproduced
-msse4 - reproduced

@agentzh
Copy link
Member

agentzh commented Apr 23, 2017

@alonbg Have you tried out the latest v2.1 branch of the official luajit git repository? I'm pretty sure we never touched that part of luajit in our branch.

@alonbg
Copy link
Author

alonbg commented Apr 23, 2017

Hi @agentzh , yes I tried the latest v2.1 with the -msse4.2 flag - doesn't reproduce.

@agentzh
Copy link
Member

agentzh commented Apr 23, 2017

@alonbg Thanks for the report! I can reproduce it on my side.

@yangshuxin Will you please take a look at this? It seems that it is triggered by our lj_str_new optimizations. Thanks!

@yangshuxin
Copy link

yangshuxin commented Apr 23, 2017

Turn out the string hash is hard-coded in parser.

1763 static void cp_decl_multi(CPState *cp)                                          
1764 {                                                                               
...
1779       } else if (tok == CTOK_IDENT &&                                           
1780                  cp->str->hash == H_(187aab88,fcb60b42)) { /* line */           
...
1791     } 

@yangshuxin
Copy link

A proposed fix patch is just sent to @agentzh, since I will going to travel this Wed morning. I wonder if @agentzh can take over this bug in case this is urgent.

@yangshuxin
Copy link

I'm returning back, will make a PR ASAP.

yangshuxin pushed a commit to yangshuxin/luajit2 that referenced this issue Jun 1, 2017
It would otherwise be impossible to change string-hash algorithm.
This change fixes openresty#10

The test does not cover following situation:
    o. attribute used by MSVC
    o. attribute used only on x86 system (not familar with those attributes)
@agentzh
Copy link
Member

agentzh commented Jun 1, 2017

@alonbg Will you try @yangshuxin's LuaJIT patch in #11 on your side? Thanks!

@alonbg
Copy link
Author

alonbg commented Jun 5, 2017

@agentzh - yes. I'll update ..

@agentzh
Copy link
Member

agentzh commented Jul 30, 2017

@alonbg I believe this is already fixed in the latest v2.1-agentzh branch. I'm closing this.

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 a pull request may close this issue.

3 participants