c++/4501: Function argument passed in wrong register

ben.hutchings@roundpoint.com ben.hutchings@roundpoint.com
Mon Oct 8 04:56:00 GMT 2001


>Number:         4501
>Category:       c++
>Synopsis:       Function argument passed in wrong register
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 08 04:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     ben.hutchings@roundpoint.com
>Release:        gcc-3.0.1
>Organization:
>Environment:
Solaris 8 on SPARC
>Description:
The string::append tests for libstdc++ fail with a segment
violation. I see that there were 8 test failures on all the
platforms for which libstdc++ has officially been tested,
though there are no details of which tests these were.

I traced through the test program to isolate the code that
was failing, and have produced a rather shorter program that
exhibits the same failure. What happens is:

1. Test program calls std::string::append with a pos
   argument that is too large.
2. append calls _M_check to check the pos parameter.
3. _M_check calls __throw_out_of_range with a static
   constant string as its argument (in register %o0).
4. __throw_out_of_range gets an invalid pointer as its
   parameter (appears to expect it in register %i1).
5. std::logic_error::logic_error uses this invalid pointer;
   *boom*.

So the problem appears to be between 3 and 4.
>How-To-Repeat:
Compile and run the attached program. Use gdb to confirm
the above description.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cc"

I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkZXhjZXB0PgojaW5jbHVkZSA8c3RyaW5n
PgoKaW50IG1haW4oKQp7CiAgICB0cnkKICAgIHsKCXN0ZDo6c3RyaW5nIHM7CglzLmFwcGVuZChz
LCAxLCAwKTsKICAgIH0KICAgIGNhdGNoKHN0ZDo6b3V0X29mX3JhbmdlJikKICAgIHsKCXN0ZDo6
Y2VyciA8PCAiY2F1Z2h0IGV4cGVjdGVkIGV4Y2VwdGlvblxuIjsKCXJldHVybiAwOwogICAgfQog
ICAgc3RkOjpjZXJyIDw8ICJubyBleGNlcHRpb24gdGhyb3duIVxuIjsKICAgIHJldHVybiAwOwp9
Cg==



More information about the Gcc-bugs mailing list