Opened 6 years ago

Closed 5 years ago

#12719 closed Bugs (fixed)

context test cases and examples segmentation fault when built with mingw-w64 toolchain

Reported by: patrick.zani@… Owned by: olli
Milestone: To Be Determined Component: context
Version: Boost 1.63.0 Severity: Regression
Keywords: Cc:

Description

I downloaded and successfully built Boost 1.63 with mingw-w64 (gcc.exe (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 6.2.0) toolchain on a Windows 7 64 bits computer.

I would like to use Boost.coroutines2. Unfortunately Boost.Context test cases and examples fail with a segmentation fault (except for test_apply and test_invoke).

I tested with different versions of the toolchain, but without success:

  1. gcc.exe (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 6.2.0
  2. gcc.exe (x86_64-posix-sjlj-rev1, Built by MinGW-W64 project) 6.2.0
  3. gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.4.0

Running any example executable in GDB outputs the following message:

Program received signal SIGSEGV, Segmentation fault.
jump_fcontext () at jump_x86_64_ms_pe_gas.asm:191
191     jump_x86_64_ms_pe_gas.asm: No such file or directory.

Am I missing a configuration settings? Is it a bug in jump_x86_64_ms_pe_gas.asm? Your help will be greatly appreciated.

Attachments (3)

jump_x86_64_ms_pe_gas.asm.patch (166 bytes ) - added by patrick.zani@… 6 years ago.
ontop_x86_64_ms_pe_gas.asm.patch (166 bytes ) - added by anonymous 6 years ago.
boost-1.63.0-fix-context.patch (2.1 KB ) - added by p.remmers@… 6 years ago.
add missing instructions to asm

Download all attachments as: .zip

Change History (12)

comment:1 by olli, 6 years ago

Resolution: fixed
Status: newclosed

by patrick.zani@…, 6 years ago

by anonymous, 6 years ago

comment:2 by patrick.zani@…, 6 years ago

Resolution: fixed
Severity: ProblemRegression
Status: closedreopened
Type: Support RequestsBugs

There are two problems, one in file jump_x86_64_ms_pe_gas.asm and the other in file ontop_x86_64_ms_pe_gas.asm. Register RCX is used instead of RAX.

I fixed the issues and everything works like a charm with mingw-w64 toolchain.

I attached both patch files to this ticket.

comment:3 by olli, 6 years ago

Why do you reopen the bug?I've already fixed it and closed the bug report!

Last edited 6 years ago by olli (previous) (diff)

comment:4 by olli, 6 years ago

Resolution: fixed
Status: reopenedclosed

comment:5 by p.remmers@…, 6 years ago

Resolution: fixed
Status: closedreopened

Unfortunately, the patch does not fix the crashes. When looking at the differences between the masm and the gas version, there is still something missing: + /* restore MMX control- and status-word */ + ldmxcsr 0xa0(%rsp) + /* restore x87 control-word */ + fldcw 0xa4(%rsp)

I'll attach a patch, but I haven't verified it, because boost takes so long to rebuild, and I've had trouble doing an incremental build (the fix didn't end up in the package). I will write an update when the rebuild is done. Sadly, I've seen that the next release is imminent, and this fix will probably not be included until wednesday...

by p.remmers@…, 6 years ago

add missing instructions to asm

comment:6 by p.remmers@…, 6 years ago

Ok, so the rebuild is done, and I actually can't say whether that fixed it completely or not. The strange thing is, if you run the program it works and doesn't crash anymore (yay!). However, if you run it under gdb, there will be a SIGSEGV at the ldmxcsr 0xa0(%rsp) instruction in the jump_fcontext function. I don't know whether that's a problem with gdb or whether the problem is not really fixed yet. I can single step over that instruction with visual studio in an msvc build of boost and my test program no problem. I can even use the visual studio debugger and single step over that instruction in the executable that was built by mingw. So I really don't know what's going on here. The way this behaves, I'm going to assume that the problem is basically fixed, and that this is a gdb problem.

comment:7 by olli, 5 years ago

could you check branch develop - should fixed now

comment:8 by p.remmers@…, 5 years ago

Yes, it seems to work.

It works, I can single step through the context switching disassembly, including the ldmxcsr instruction, and it does not crash. I compiled my test program using both gcc and clang.

I've had some trouble finding it, sucking it out of github (successfully avoided having to learn git until now), and compiling it as an MSYS2 package. I did not completely manage to do it. Somehow after building, the coroutines2 headers are missing, so I switched my test program to use the old coroutines library.

So aside from the other problems, I guess boost.context itself should be good now.

comment:9 by olli, 5 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.