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

panic: could not match regexp #184

Closed
mikowiec opened this issue Jul 3, 2017 · 17 comments
Closed

panic: could not match regexp #184

mikowiec opened this issue Jul 3, 2017 · 17 comments

Comments

@mikowiec
Copy link

mikowiec commented Jul 3, 2017

Test 1 Precondition:
Windows 7, SP1, 32 bit
Visual Studio 2015 community edition
LLVM-3.9.1-win32
Windows 10 SDK (10.0.15063.468)
go version go1.8.1 windows/386

Test 2 Precondition:
mac 1.9.5
go version go1.8.1 darwin/amd64

\go\c2go>c2go transpile examples\fib.c
panic: could not match regexp '(?P

[0-9a-fx]+) <(?P.)> "(?P.?)"(?P ".*?")?' with string 'DeprecatedAttr 0x3b732f0 line:1107:12 Inherited "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." ""'

goroutine 1 [running]:
github.com/elliotchance/c2go/ast.groupsFromRegex(0x57acb2, 0x3b, 0x120594a8, 0xd6, 0x56f0c4)
E:/dev/gocode/src/github.com/elliotchance/c2go/ast/ast.go:407 +0x2a7
github.com/elliotchance/c2go/ast.parseDeprecatedAttr(0x120594a8, 0xd6, 0x571939)
E:/dev/gocode/src/github.com/elliotchance/c2go/ast/deprecated_attr.go:15 +0x3f
github.com/elliotchance/c2go/ast.Parse(0x120594a8, 0xd6, 0xda, 0x11c189c0)
E:/dev/gocode/src/github.com/elliotchance/c2go/ast/ast.go:276 +0x1dbb
main.convertLinesToNodes(0x11c7a000, 0x18a5, 0x18a5, 0x11c7a000, 0x18a5, 0x18a5)
E:/dev/gocode/src/github.com/elliotchance/c2go/main.go:66 +0x165
main.Start(0x0, 0x11c4d8c0, 0xe, 0x0, 0x0, 0x56f599, 0x4, 0x11c48118, 0x8)
E:/dev/gocode/src/github.com/elliotchance/c2go/main.go:191 +0x628
main.main()
E:/dev/gocode/src/github.com/elliotchance/c2go/main.go:305 +0x2c2

@mikowiec
Copy link
Author

mikowiec commented Jul 3, 2017

I've got the same issue for mac 10.9.5

@mikowiec mikowiec changed the title panic: could not match regexp, with windows 7 panic: could not match regexp Jul 3, 2017
@elliotchance
Copy link
Owner

Hi @mikowiec this error is caused by it not able to understand a line outputted from clang - likely because it has extra special characters (like double quotes) that make it not match the expected regex.

The fix is to add a new test case, just like this one:

https://github.com/elliotchance/c2go/blob/master/ast/deprecated_attr_test.go#L9-L15

This will cause go test to fail (for the same reason) and then this regex needs to be adjusted:

https://github.com/elliotchance/c2go/blob/master/ast/deprecated_attr.go#L13

Are you feeling up to the challenge? 😄

@mikowiec
Copy link
Author

mikowiec commented Jul 5, 2017

Tell me, please, what golang version do you compile?

there is log from 1.8.1 golang, mac 1.9.5:
➜ c2go2 ./c2go transpile prime.c
panic: could not match regexp '(?P

[0-9a-fx]+) <(?P.*)> always_inline' with string 'AlwaysInlineAttr 0x102882a40 line:346:24'

goroutine 1 [running]:
github.com/elliotchance/c2go/ast.groupsFromRegex(0x11b7973, 0x20, 0x4213ba9df, 0x2a, 0x4212cf3a0)
/Users/xxxxxxxx/gocode/src/github.com/elliotchance/c2go/ast/ast.go:407 +0x392
github.com/elliotchance/c2go/ast.parseAlwaysInlineAttr(0x4213ba9df, 0x2a, 0x11b3b65)
/Users/xxxxxxxx/gocode/src/github.com/elliotchance/c2go/ast/always_inline_attr.go:13 +0x4e
github.com/elliotchance/c2go/ast.Parse(0x4213ba9df, 0x2a, 0x2e, 0x42133c330)
/Users/xxxxxxxx/gocode/src/github.com/elliotchance/c2go/ast/ast.go:236 +0x2a0c
main.convertLinesToNodes(0x4213c0000, 0x268, 0x268, 0x4213c0000, 0x268, 0x268)
/Users/xxxxxxxx/gocode/src/github.com/elliotchance/c2go/main.go:65 +0x1ef
main.Start(0x0, 0x7fff5fbff669, 0x7, 0x0, 0x0, 0x11b148f, 0x4, 0x4212da330, 0x421334268)
/Users/xxxxxxxx/gocode/src/github.com/elliotchance/c2go/main.go:162 +0x788
main.main()
/Users/xxxxxxxx/gocode/src/github.com/elliotchance/c2go/main.go:276 +0x373

and there golang 1.6.2 and c2go version from april:
➜ c2go1 ./c2go transpile prime.c
panic: stat transpile: no such file or directory

goroutine 1 [running]:
panic(0x1c3d80, 0x8203745a0)
/usr/local/go/src/runtime/panic.go:481 +0x3e6
main.Check(0x88203c0290, 0x8203745a0)
/Users/xxxxxx/gocode/src/github.com/elliotchance/c2go/main.go:126 +0x4b
main.Start(0x820374370, 0x2, 0x2, 0x0, 0x0)
/Users/xxxxxx/gocode/src/github.com/elliotchance/c2go/main.go:139 +0x139
main.main()
/Users/xxxxxx/gocode/src/github.com/elliotchance/c2go/main.go:206 +0xaaxxxxxx

@Konstantin8105
Copy link
Contributor

Konstantin8105 commented Jul 5, 2017

I use:

go version

Output:

go version go1.8.3 linux/amd64

Also,

clang --version

Output:

clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@Konstantin8105
Copy link
Contributor

In according to integration test of c2go https://github.com/elliotchance/c2go/blob/master/.travis.yml , guarantee supported next version of clang 3.4 ... 3.9, OS linux, osx:

os:
  - linux
  - osx

env:
  - CLANG=3.9

matrix:
  include:
    - env: CLANG=3.8
      os: linux
    - env: CLANG=3.7
      os: linux
    - env: CLANG=3.6
      os: linux
    - env: CLANG=3.4
      os: linux

@mikowiec
Copy link
Author

mikowiec commented Jul 5, 2017

➜ clang --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

@Konstantin8105
Copy link
Contributor

@mikowiec Thank you for result of 2 checking.
I see 2 different errors. I haven't any recommendations, except : try install clang in list 3.4,3.6,3.7,3.8 for your Mac desktop and update Go for Win.

@mikowiec
Copy link
Author

mikowiec commented Jul 7, 2017

update Go for Win

x>c2go transpile prime.c
panic: could not match regexp '(?P

[0-9a-fx]+) <(?P.)> "(?P.?)"(?P ".*?")?' with
string 'DeprecatedAttr 0xad3460 line:1107:12 Inherited "This function or variable may be unsafe. Consider using _snwp
rintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." ""'

goroutine 1 [running]:
github.com/elliotchance/c2go/ast.groupsFromRegex(0x57ad8f, 0x3b, 0x11bee8dc, 0xd5, 0x56f184)
/src/github.com/elliotchance/c2go/ast/ast.go:407 +0x2a7
github.com/elliotchance/c2go/ast.parseDeprecatedAttr(0x11bee8dc, 0xd5, 0x5719f9)
/src/github.com/elliotchance/c2go/ast/deprecated_attr.go:15 +0x3f
github.com/elliotchance/c2go/ast.Parse(0x11bee8dc, 0xd5, 0xd9, 0x11acaf80)
/src/github.com/elliotchance/c2go/ast/ast.go:276 +0x1dbb
main.convertLinesToNodes(0x11820000, 0x18ba, 0x18ba, 0x11820000, 0x18ba, 0x18ba)
/src/github.com/elliotchance/c2go/main.go:66 +0x165
main.Start(0x0, 0x117c2190, 0x7, 0x0, 0x0, 0x56f659, 0x4, 0x117c4128, 0x8)
/src/github.com/elliotchance/c2go/main.go:191 +0x628
main.main()
/src/github.com/elliotchance/c2go/main.go:305 +0x2c2

go version
go version go1.8.3 windows/386

@Konstantin8105
Copy link
Contributor

@mikowiec Thank you for update.
So, what we check? Versions of Golang, Clang.
But - What the version of glibc?
For integration test used glibc 2.24-9.
On my laptop:
ldd

@mikowiec
Copy link
Author

mikowiec commented Jul 7, 2017

osx mac does not have ldd.
The osx equivalent is called otool -L
command "otool -L ./c2go" show me nothing shared library used.

@Konstantin8105
Copy link
Contributor

Main point - find version of standard library C.
Maybe https://stackoverflow.com/questions/9705660/check-glibc-version-for-a-particular-gcc-compiler help to find.
I will try today to check c2go with old glibc.

@mikowiec
Copy link
Author

mikowiec commented Jul 7, 2017

osx base system does not use glibc

@elliotchance
Copy link
Owner

elliotchance commented Jul 8, 2017

@Konstantin8105, Apple has a fork of clang that uses a different versioning scheme. It is not something that can be tested on travis.

The issue here is simple - it has nothing to do with clang versions or programs install. clang is outputting a line that is not understood by c2go's parsing mechanism. It is fixed by making the changes I outlined in my comment #184 (comment)

@mikowiec
Copy link
Author

mikowiec commented Jul 8, 2017

@elliotchance

this regex needs to be adjusted.

exactly.
I've resolved this issue and it will be fixed soon.

@Konstantin8105
Copy link
Contributor

Like I understood - that issue is closed.

@elliotchance
Copy link
Owner

@Konstantin8105 feel free to close this issue if it is resolved.

@Konstantin8105
Copy link
Contributor

:) I haven't permission for that

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

No branches or pull requests

3 participants