Modify

Ticket #12719 (reopened Bugs)

Opened 4 months ago

Last modified 2 days ago

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

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

Change History

comment:1 Changed 4 months ago by olli

  • Status changed from new to closed
  • Resolution set to fixed

Changed 4 months ago by patrick.zani@…

Changed 4 months ago by anonymous

comment:2 Changed 4 months ago by patrick.zani@…

  • Status changed from closed to reopened
  • Type changed from Support Requests to Bugs
  • Resolution fixed deleted
  • Severity changed from Problem to Regression

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 Changed 4 months ago by olli

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

Last edited 4 months ago by olli (previous) (diff)

comment:4 Changed 4 months ago by olli

  • Status changed from reopened to closed
  • Resolution set to fixed

comment:5 Changed 13 days ago by p.remmers@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

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...

Changed 13 days ago by p.remmers@…

add missing instructions to asm

comment:6 Changed 13 days ago by p.remmers@…

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 Changed 8 days ago by olli

could you check branch develop - should fixed now

comment:8 Changed 2 days ago by p.remmers@…

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.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as reopened
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.