Strange behavior of std::string find method in SS12

Hi
I faced with strange behavior of std::string.find method while compiling with Sunstudio12.
Compiler: CC: Sun C++ 5.9 SunOS_sparc Patch 124863-14 2009/06/23
Platform: SunOS xxxxx 5.10 Generic_141414-07 sun4u sparc SUNW,Sun-Fire-V250
Sometimes find method does not work, especially when content of string is larger than several Kb and it is needed to find pattern from some non-zero position in the string
For example, I have some demonstration program which tries to parse PDF file.
It loads PDF file completely to a string and then iterately searches all ocurrences of "obj" and "endobj".
If I compile it with GCC from Solaris - it works
If I compile it with Sunstudio12 and standard STL - does not work
If I compile it with Sunstudio12 and stlport - it works.
On win32 it always works fine (by VStudio or CodeBlocks)
Is there any limitation of standard string find method in Sunstudio12 STL ?
See below the code of tool.
Compilation: CC -o teststr teststr.cpp
You can use any PDF files larger than 2kb as input to reproduce the problem.
In this case std::string failes to find "endobj" from some position in the string,
while this pattern is located there for sure.
Example of output:
CC -o teststr teststr.cpp
teststr in.pdf Processing in.pdf
Found object:1
Broken PDF, endobj is not found from position1155
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
bool parsePDF (string &content, size_t &position)
    position = content.find("obj",position);
    if( position == string::npos ) {
        cout<<"End of file"<<endl;
        return false;
    position += strlen("obj");
    size_t cur_pos = position;
    position = content.find("endobj",cur_pos);
    if( position == string::npos ){
        cerr<<"Broken PDF, endobj is not found from position"<<cur_pos<<endl;;
        return false;
    position += strlen("endobj");
    return true;
int main(int argc, char ** argv)
    if( argc < 2 ){
        cout<<"Usage:"<<argv[0]<<" [pdf files]\n";
        return -3;
    else {
        for(int i = 1;i<argc;i++) {
            ifstream pdfFile;
            pdfFile.open(argv,ios::binary);
if( pdfFile.fail()){
cerr<<"Error opening file:"<<argv[i]<<endl;
continue;
pdfFile.seekg(0,ios::end);
int length = pdfFile.tellg();
pdfFile.seekg(0,ios::beg);
char *buffer = new char [length];
if( !buffer ){
cerr<<"Cannot allocate\n";
continue;
pdfFile.read(buffer,length);
pdfFile.close();
string content;
content.insert(0,buffer,length);
delete buffer;
// the lets parse the file and find all endobj in the buffer
cout<<"Processing "<<argv[i]<<endl;
size_t start = 0;
int count = 0;
while( parsePDF(content,start) ){
cout<<"Found object:"<<++count<<"\n";
return 0;

Well, there is definitely some sort of problem here, maybe in string::find, but possibly elsewhere in the library.
Please file a bug report at [http://bugs.sun.com] and we'll have a look at it.

Similar Messages

  • Strange behavior  in entity bean : get Timestamp

    Hello:
    I'm working with SUNONE 7 AppServer , over SunOS 5.9
    I've a strange behavior with entity's get methods which return Timestamp value.
    For example, I've got
    Timestamp date;
    If I do
    entity.setF(date) , ( date is a Timestamp with value "12/12/2005 12:30:00" )
    all works right, and in database is wrote right ( "12/12/2005 12:30:00" )
    But , if I do
    date = entity.getF()
    the, date variable has the value "12/12/2005 00:00:00"
    So, in get method is lost the time value of a Timestamp data
    Could be a code bug in my source , but if I use Jboss AS over Windows XP , all work right ( set and get methods ). The database is the same one ( Oracle 9i )

    Well, I found the solution.
    The problem was the ojdbc14.jar driver, which made wrong schema files.
    Exactly, with the bad ojdbc14.jar, generated this entry
    <_type>91</_type>
    when the right one for date types ( Timestamp ) is
    <_type>93</_type>
    I dont know why the new ojdbc14.jar works fine, but I paste its size
    good ojdbc14.jar : 1181679 bytes

  • String.replaceAll strange behavior...

    I have found strange behavior of String.replaceAll method:
    "aaaabaaaa".replaceAll("b","a"); // working fine
    "aaaabaaaa".replaceAll("b","a${"); // throws an exceptionThat could be probably a bug?
    p.s. using jdk_1.6.0_12-b04

    Welcome to the Sun forums.
    >
    "aaaabaaaa".replaceAll("b","a${"); // throws an exception
    Please always copy/paste the [exact error message|http://pscode.org/javafaq.html#exact]. We do not have crystal ball, and cannot see the output on your PC.
    >
    That could be probably a bug? >(chuckle) It has more to do with special characters in Strings, that need to be escaped. I am not up on the fine details, but try this code.
    import javax.swing.*;
    class TestStringReplace {
      public static void main(String[] args) {
        String result = "aaaabaaaa".replaceAll("b","c"); // working fine
        JOptionPane.showMessageDialog(null, result);
        result = "aaaabaaaa".replaceAll("b","c\\${"); // chars escaped
        JOptionPane.showMessageDialog(null, result);
    }

  • Method cellForRowAtIndexPath if (cell == nil) {} condition strange behavior

    This tableView’s are making me crazy. I just tested this behavior on new test project (iPad) with one tableView. I added 30 sections with one row per section and put this line inside if( cell == nil ) {} condition in cellForRowAtIndexPath method:
    NSLog(@”Creating cell %d”,indexPath.section);
    When I launch application I get this in output:
    Creating cell 0
    Creating cell 1
    Creating cell 2
    Creating cell 20
    Creating cell 21
    Only 22 cells are visible on first run. That’s ok, tableView created only cells that are visible. So far so good.
    But when I scroll down to see the rest of the cells (8 other cells) the console only shows me this:
    Creating cell 22
    Why did tableView skipped creating last 7 rows and used them from queue instead? isn’t that kind a strange behavior? Or maybe is this a bug in apple’s tableView? Or maybe I am wrong and don’t quite understand the background of tableView reusing…?
    Any help appriciated, thanks!

    Ok, I find out that this is normal and native behavior for tableView's.

  • Strange behavior: action method not called when button submitted

    Hello,
    My JSF app is diplaying a strange behavior: when the submit button is pressed the action method of my managed bean is not called.
    Here is my managed bean:
    package arcoiris;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.model.SelectItem;
    public class SearchManagedBean {
        //Collected from search form
        private String keyword;
        private String country;
        private int[] postcode;
        private boolean commentExists;
        private int rating;
        private boolean websiteExists;
        //Used to populate form
        private List<SelectItem> availableCountries;
        private List<SelectItem> availablePostcodes;
        private List<SelectItem> availableRatings;
        //Retrieved from ejb tier
        private List<EstablishmentLocal> retrievedEstablishments;
        //Service locator
        private arcoiris.ServiceLocator serviceLocator;
        //Constructor
        public SearchManagedBean() {
            System.out.println("within constructor SearchManagedBean");
            System.out.println("rating "+this.rating);
        //Getters and setters
        public String getKeyword() {
            return keyword;
        public void setKeyword(String keyword) {
            this.keyword = keyword;
        public String getCountry() {
            return country;
        public void setCountry(String country) {
            this.country = country;
        public boolean isCommentExists() {
            return commentExists;
        public void setCommentExists(boolean commentExists) {
            this.commentExists = commentExists;
        public int getRating() {
            return rating;
        public void setRating(int rating) {
            this.rating = rating;
        public boolean isWebsiteExists() {
            return websiteExists;
        public void setWebsiteExists(boolean websiteExists) {
            this.websiteExists = websiteExists;
        public List<SelectItem> getAvailableCountries() {
            List<SelectItem> countries = new ArrayList<SelectItem>();
            SelectItem si_1 = new SelectItem();
            SelectItem si_2 = new SelectItem();
            SelectItem si_3 = new SelectItem();
            si_1.setValue("2");
            si_1.setLabel("ecuador");
            si_2.setValue("1");
            si_2.setLabel("colombia");
            si_3.setValue("3");
            si_3.setLabel("peru");
            countries.add(si_1);
            countries.add(si_2);
            countries.add(si_3);
            return countries;
        public void setAvailableCountries(List<SelectItem> countries) {
            this.availableCountries = availableCountries;
        public List<SelectItem> getAvailablePostcodes() {
            List<SelectItem> postcodes = new ArrayList<SelectItem>();
            SelectItem si_1 = new SelectItem();
            SelectItem si_2 = new SelectItem();
            SelectItem si_3 = new SelectItem();
            si_1.setValue(75001);
            si_1.setLabel("75001");
            si_2.setValue(75002);
            si_2.setLabel("75002");
            si_3.setValue(75003);
            si_3.setLabel("75003");
            postcodes.add(si_1);
            postcodes.add(si_2);
            postcodes.add(si_3);
            return postcodes;
        public void setAvailablePostcodes(List<SelectItem> availablePostcodes) {
            this.availablePostcodes = availablePostcodes;
        public List<SelectItem> getAvailableRatings() {
            List<SelectItem> ratings = new ArrayList<SelectItem>();
            SelectItem si_1 = new SelectItem();
            SelectItem si_2 = new SelectItem();
            SelectItem si_3 = new SelectItem();
            si_1.setValue(1);
            si_1.setLabel("1");
            si_2.setValue(2);
            si_2.setLabel("2");
            si_3.setValue(3);
            si_3.setLabel("3");
            ratings.add(si_1);
            ratings.add(si_2);
            ratings.add(si_3);
            return ratings;
        public void setAvailableRatings(List<SelectItem> availableRatings) {
            this.availableRatings = availableRatings;
        public int[] getPostcode() {
            return postcode;
        public void setPostcode(int[] postcode) {
            this.postcode = postcode;
        public List<EstablishmentLocal> getRetrievedEstablishments() {
            return retrievedEstablishments;
        public void setRetrievedEstablishments(List<EstablishmentLocal> retrievedEstablishments) {
            this.retrievedEstablishments = retrievedEstablishments;
        //Business methods
        public String performSearch(){
            System.out.println("performSearchManagedBean begin");
            SearchRequestDTO searchRequestDto = new SearchRequestDTO(this.keyword,this.country,this.postcode,this.commentExists,this.rating, this.websiteExists);
            SearchSessionLocal searchSession = lookupSearchSessionBean();
            List<EstablishmentLocal> retrievedEstablishments = searchSession.performSearch(searchRequestDto);
            this.setRetrievedEstablishments(retrievedEstablishments);
            System.out.println("performSearchManagedBean end");
            return "success";
        private arcoiris.ServiceLocator getServiceLocator() {
            if (serviceLocator == null) {
                serviceLocator = new arcoiris.ServiceLocator();
            return serviceLocator;
        private arcoiris.SearchSessionLocal lookupSearchSessionBean() {
            try {
                return ((arcoiris.SearchSessionLocalHome) getServiceLocator().getLocalHome("java:comp/env/ejb/SearchSessionBean")).create();
            } catch(javax.naming.NamingException ne) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
                throw new RuntimeException(ne);
            } catch(javax.ejb.CreateException ce) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ce);
                throw new RuntimeException(ce);
    }Here is my jsp page:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
             <html>
                 <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                     <META HTTP-EQUIV="pragma" CONTENT="no-cache">
                     <title>JSP Page</title>
                 </head>
                 <body>
                     <f:view>
                         <h:panelGroup id="body">
                             <h:form id="searchForm">
                                 <h:panelGrid columns="2">
                                     <h:outputText id="keywordLabel" value="enter keyword"/>   
                                     <h:inputText id="keywordField" value="#{SearchManagedBean.keyword}"/>
                                     <h:outputText id="countryLabel" value="choose country"/>   
                                     <h:selectOneListbox id="countryField" value="#{SearchManagedBean.country}">
                                         <f:selectItems id="availableCountries" value="#{SearchManagedBean.availableCountries}"/>
                                     </h:selectOneListbox>
                                     <h:outputText id="postcodeLabel" value="choose postcode(s)"/>   
                                     <h:selectManyListbox id="postcodeField" value="#{SearchManagedBean.postcode}">
                                         <f:selectItems id="availablePostcodes" value="#{SearchManagedBean.availablePostcodes}"/>
                                     </h:selectManyListbox>
                                     <h:outputText id="commentExistsLabel" value="with comment"/>
                                     <h:selectBooleanCheckbox id="commentExistsField" value="#{SearchManagedBean.commentExists}" />
                                     <h:outputText id="ratingLabel" value="rating"/>
                                     <h:selectOneListbox id="ratingField" value="#{SearchManagedBean.rating}">
                                         <f:selectItems id="availableRatings" value="#{SearchManagedBean.availableRatings}"/>
                                     </h:selectOneListbox>
                                     <h:outputText id="websiteExistsLabel" value="with website"/>
                                     <h:selectBooleanCheckbox id="websiteExistsField" value="#{SearchManagedBean.websiteExists}" />
                                     <h:commandButton value="search" action="#{SearchManagedBean.performSearch}"/>
                                 </h:panelGrid>
                             </h:form>
                         </h:panelGroup>
                     </f:view>
                 </body>
             </html>
         here is my faces config file:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
        <managed-bean>
            <managed-bean-name>SearchManagedBean</managed-bean-name>
            <managed-bean-class>arcoiris.SearchManagedBean</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <navigation-rule>
           <description></description>
            <from-view-id>/welcomeJSF.jsp</from-view-id>
            <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>index.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
    </faces-config>The problem occurs when the field ratingField is left blank (which amounts to it being set at 0 since it is an int).
    Can anyone help please?
    Thanks in advance,
    Julien.

    Hello,
    Thanks for the suggestion. I added the tag and it now says:
    java.lang.IllegalArgumentException
    I got that from the log:
    2006-08-17 15:29:16,859 DEBUG [com.sun.faces.el.ValueBindingImpl] setValue Evaluation threw exception:
    java.lang.IllegalArgumentException
         at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.faces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:178)
         at com.sun.faces.el.impl.ArraySuffix.setValue(ArraySuffix.java:192)
         at com.sun.faces.el.impl.ComplexValue.setValue(ComplexValue.java:171)
         at com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:234)
         at javax.faces.component.UIInput.updateModel(UIInput.java:544)
         at javax.faces.component.UIInput.processUpdates(UIInput.java:442)
         at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:935)
         at javax.faces.component.UIForm.processUpdates(UIForm.java:196)
         at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:935)
         at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:935)
         at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:363)
         at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:81)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
         at java.lang.Thread.run(Thread.java:595)
    2006-08-17 15:29:16,875 DEBUG [com.sun.faces.context.FacesContextImpl] Adding Message[sourceId=searchForm:ratingField,summary=java.lang.IllegalArgumentException)Do you see where the problem comes from??
    Julien.

  • 12.4 Beta, Error: Could not find a match for std::_Tuple_impl 0, std::string && ::_Tuple_impl(std::tuple std::string &&

    Hi,
    would you guys say code that compiles fine without -std=c++11 should also compile *with* -std=c++11?
    raider@sol112_x86:/tmp $ CC -V
    CC: Sun C++ 5.13 SunOS_i386 Beta2 2014/06/17
    raider@sol112_x86:/tmp $ CC buggy.cc  
    raider@sol112_x86:/tmp $ CC -std=c++11 buggy.cc         
    Error: Could not find a match for std::_Tuple_impl<0, std::string &&>::_Tuple_impl(std::tuple<std::string &&>, std::string ) needed in std::tuple<std::string &&>::tuple<std::string, void>(std::string &&).
    "/opt/SolarisStudio12.4-beta_jul14-solaris-x86/lib/compilers/CC-gcc/include/c++/4.8.2/tuple", line 868:     Where: While instantiating "std::tuple<std::string &&>::tuple<std::string, void>(std::string &&)".
    "/opt/SolarisStudio12.4-beta_jul14-solaris-x86/lib/compilers/CC-gcc/include/c++/4.8.2/tuple", line 868:     Where: Instantiated from std::forward_as_tuple<std::string>(std::string &&).
    "/opt/SolarisStudio12.4-beta_jul14-solaris-x86/lib/compilers/CC-gcc/include/c++/4.8.2/bits/stl_map.h", line 485:     Where: Instantiated from non-template code.
    1 Error(s) detected.
    raider@sol112_x86:/tmp $ cat buggy.cc
    #include <map>
    #include <string>
    typedef std::map<std::string, std::string> StrStrMap;
    int main(void)
        StrStrMap dict;
        dict["bug"] = "feature";
        return 0;

    C++11 is approximately a superset of C++03. If you write in the common subset, the code will compile in any mode. For example, a basic hello-world program
    #include <iostream>
    int main() { std::cout << "Hello, world!\n"; }
    will compile and run as C++98/03, as C++11, as C++14, and I'm sure will also work with the next standard, planned for 2017.
    But if you use syntax or library types and functions that are new in C++11, the code will not compile as C++03.
    In my previous post, I might have sounded too negative about compiling C++03 code in C++11 mode. If you have a C++03 program that is intended to be portable, and that works with different compilers on different platforms, chances are good that it will continue to work in C++11. The chances are very good that only minor modifications will be needed.

  • Find(String pkey) method returns multiple object of the same row

    I'm not quite sure what i've done or havent done, but I've implemented updating a row using the em.persist(Object) method.....works great, but after i did that a few times the find(String pkey) method returns multiple copies of 1 row in the db
    here are two rows in the db
    personid(PK) firstName lastName
    1234 joe jones
    2345 rachel jones
    when i execute any query looking for people with the last name jones, ie
    select object(p) from Person p where p.lastName='jones'
    it returns multiple objects of each row ie
    1234 joe jones
    1234 joe jones
    1234 joe jones
    1234 joe jones
    2345 rachel jones
    2345 rachel jones
    2345 rachel jones
    2345 rachel jones
    There is only one row for both rachel and joe in the db, but why is the entity manager returning multiple objects of each, and how do i prevent that without using DISTINCT?
    Thanks for the help in advance

    Sorry, i forgot to mention i'm using ejb 3 and jboss

  • Assign global array of structures of structures of std strings in a dll

    I have a dll which consists of three c files. Find bellow the c file of the loader and the three files of the dll. In dll, file 1 and file 2 are almost identical, static arrays names and sizes, structure names, Prepare_1() and Prepare_2() functions. There
    is a small difference in the function Prepare_1 in the way MuxStatusSupl[ u32Idx ].FileInfo.Name is assigned and there I get an exception. Another difference is that the structure StructStatus in file 2 has an extra member compare to file 1. From this point
    I couldn't strip down even more the sample code because small changes make the problem disappear without, I'm afraid, really solving the problem. That's why I have put so much code here, I'm not even sure what is relevant and what not. For example, if I add
    in file 1 in the StructStatus the extra member u32ExitPoint (and, of course, I modify Status_Init accordingly), I don't see the problem anymore.
    ///////////////////////////////////////////////////// loader file begin ////
    #include "stdafx.h"
    int main(int argc, char* argv[])
    {   HINSTANCE hDLL = LoadLibrary( DLL_FQN_FILE_NAME );
        if( void ( * pCreateDllInterface )( void ) =
                (void(*)())GetProcAddress( hDLL, "CreateDllInterface" ) )
            pCreateDllInterface();
        FreeLibrary( hDLL );
    ///////////////////////////////////////////////////// loader file end //////
    ///////////////////////////////////////////////////// dll main file begin //
    extern void Prepare_1( void );
    extern void Prepare_2( void );
    extern "C" _declspec(dllexport) void CreateDllInterface( ) { Prepare_1(); }
    ///////////////////////////////////////////////////// dll main file end ////
    ///////////////////////////////////////////////////// dll file 1 begin /////
    #include <string>
    #include <sys/stat.h>
    #define STORAGE_SIZE  254
    typedef unsigned long  int uint32;
    struct StructFileInfo
    {   std::string Name; 
        struct stat FileStatus; 
    static struct StructStatus
    {   bool bDownloaded;      bool bDownloadedLast;
        bool bCalled;          bool bCalledLast;
        uint32 u32EntryPoint;
        StructFileInfo FileInfo;
    } MuxStatusMain[ STORAGE_SIZE ], MuxStatusSupl[ STORAGE_SIZE ];
    void Prepare_1() 
    {   struct stat Stat_Init;
        memset( &Stat_Init, 0, sizeof(struct stat) );
        StructStatus Status_Init =
                        { false, false, false, false, 0, { "", Stat_Init } };
        std::fill_n( MuxStatusMain, STORAGE_SIZE, Status_Init ); //  this seems
                               // to overwrite MuxStatusSupl[ 3 ].FileInfo.Name
        for( uint32 u32Idx = 0; u32Idx < STORAGE_SIZE; u32Idx++ )
            MuxStatusSupl[ u32Idx ].FileInfo.Name = ""; // crash when u32Idx==3 
    ///////////////////////////////////////////////////// dll file 1 end ///////
    ///////////////////////////////////////////////////// dll file 2 begin /////
    #include <string>
    #include <sys/stat.h>
    #define STORAGE_SIZE  254
    typedef unsigned long  int uint32;
    struct StructFileInfo
    {   std::string Name; 
        struct stat FileStatus; 
    static struct StructStatus
    {   bool bDownloaded;      bool bDownloadedLast;
        bool bCalled;          bool bCalledLast;
        uint32 u32EntryPoint;  uint32 u32ExitPoint;
        StructFileInfo FileInfo;
    } MuxStatusMain[ STORAGE_SIZE ], MuxStatusSupl[ STORAGE_SIZE ];
    void Prepare_2()
    {   struct stat Stat_Init;
        memset( &Stat_Init, 0, sizeof(struct stat) );
        StructStatus Status_Init =
            { false, false, false, false, 0, 0xFFFFFFFF, { "", Stat_Init } };
        std::fill_n( MuxStatusMain, STORAGE_SIZE, Status_Init );
        std::fill_n( MuxStatusSupl, STORAGE_SIZE, Status_Init );
    ///////////////////////////////////////////////////// dll file 2 end ///////
    I get the crash with the message: Unhalted exception at 0x10001f90 in Test.exe: 0xC0000005: Access violation writing location 0x1006d320
    Another strange phenomena is that in watch window, expressions
        sizeof(MuxStatusMain)/sizof(MuxStatusMain[0])
        sizeof(MuxStatusMain)/sizof(MuxStatusMain[0])
    show both a value of 232 instead of 254 (but if I add in file 1 in the struct the missing member they show the correct values). On the other hand, if I printf those values, they are correct, 254.

    "Another difference is that the structure StructStatus in file 2 has an extra member compare to file 1."
    That's not going to work. It is possible to define the same struct in different translation units but the definitions need to be identical. Use different names for StructFileInfo and StructStatus.

  • Strange Behavior connecting to Oracle

    Hi to All,
    On Server Windows 2003 I have installed Oracle 10g R2. On this Server run Toad for Oracle.
    If I run Oracle console, all work fine; running Toad the ORA-12154 error is displayed.
    I have tried to connect to DB with Toad from a client and all works.
    Have someone an idea on this strange behavior ?
    Thank You and Best Regards
    Gaetano

    This may be a problem?NO!
    12154, 00000, "TNS:could not resolve the connect identifier specified"
    // *Cause:  A connection to a database or other service was requested using
    // a connect identifier, and the connect identifier specified could not
    // be resolved into a connect descriptor using one of the naming methods
    // configured. For example, if the type of connect identifier used was a
    // net service name then the net service name could not be found in a
    // naming method repository, or the repository could not be
    // located or reached.
    // *Action:
    //   - If you are using local naming (TNSNAMES.ORA file):
    //      - Make sure that "TNSNAMES" is listed as one of the values of the
    //        NAMES.DIRECTORY_PATH parameter in the Oracle Net profile
    //        (SQLNET.ORA)
    //      - Verify that a TNSNAMES.ORA file exists and is in the proper
    //        directory and is accessible.
    //      - Check that the net service name used as the connect identifier
    //        exists in the TNSNAMES.ORA file.
    //      - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA
    //        file.  Look for unmatched parentheses or stray characters. Errors
    //        in a TNSNAMES.ORA file may make it unusable.
    //   - If you are using directory naming:
    //      - Verify that "LDAP" is listed as one of the values of the
    //        NAMES.DIRETORY_PATH parameter in the Oracle Net profile
    //        (SQLNET.ORA).
    //      - Verify that the LDAP directory server is up and that it is
    //        accessible.
    //      - Verify that the net service name or database name used as the
    //        connect identifier is configured in the directory.
    //      - Verify that the default context being used is correct by
    //        specifying a fully qualified net service name or a full LDAP DN
    //        as the connect identifier
    //   - If you are using easy connect naming:
    //      - Verify that "EZCONNECT" is listed as one of the values of the
    //        NAMES.DIRETORY_PATH parameter in the Oracle Net profile
    //        (SQLNET.ORA).
    //      - Make sure the host, port and service name specified
    //        are correct.
    //      - Try enclosing the connect identifier in quote marks.
    //   See the Oracle Net Services Administrators Guide or the Oracle
    //   operating system specific guide for more information on naming.This error is clear.
    SQL*Net is being asked to resolved TNS_ALIAS & it reports that it can not find the requested name.
    EITHER
    1) the requested name is not correct
    or
    2) SQL*Net is looking in the wrong tnsnames.ora file & still not finding the requested name.
    Good Luck solving your mystery

  • Strange Behavior in modifying the values in VO

    I have a VO based on EO from a custom table. The query is something like:
    select EO.x, EO.y, (EO.x*EO.y) xy from EO
    I have displayed the values from this VO on to a table in OAF page. All the columns are messageTextInput but the third column (xy) is read-only. I have written a fireAction to execute when x or y values are changed to update the xy value accordingly.
    Code in CO:
    if ("ValueChange".equals(pageContext.getParameter(EVENT_PARAM)))
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    am.invokeMethod("UpdateXY");
    pageContext.forwardImmediately(<Same Page>, null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null, null, true,
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
    Code in AM:
    public void UpdateXY()
    xxVOImpl vo = getxxVO1();
    Row r = vo.first();
    while (vo.hasNext())
    r = vo.next();
    Object X = r.getAttribute("X");
    String X_string = X.toString();
    float X_value = Float.parseFloat(X_string);
    Object Y = r.getAttribute("Y");
    String Y_string = Y.toString();
    float Y_value = Float.parseFloat(Y_string);
    Float XY = new Float(X_value*Y_value);
    r.setAttribute("XY",(Object)XY);
    The problem is as follows. During the first time I try to update a value, the control goes through the logic and returns to the page but the XY value is not updated. But if i change a second value and tab out, the codes works and displays both the updated values of XY. From then on, the code is working fine.
    I'm also not updating the first row and so I didnt perform any logic in AM for the first row.
    Please help me out in finding out the reason for this strange behavior.

    This nature is fine, basically initially your EO x and y columns are null and unless you do a commit, these values don't go in db. The third column will take x and Y coumns values from db and multiply and will get null.
    To solve this issue, you get the values from VO columns x and y in PPR and and put x*y in the third column of Vo, IN THAT ROW.or you can directly get hold of the bean which hold the value of x*y and use setValue after getting x*y.
    ---Mukul

  • Strange behavior with DefaultCellEditor

    Hello everybody,
    I found a strange behavior with DefaultCellEditor using a JTextField in a JTable. The following line will show, what I mean:
    setDefaultCellEditor(String.class,new DefaultCellEditor(new JTextField()));
    Imho this should do the same as JTable does already, when it installs a JTextField as default cell editor for cell values of the String class. But, it seems, that it is not the same:
    When I add this line in the constructor of a JTable subclass the editor component seems to be less wide and less high to the right and bottom - it looks so with Win95 with JDK 1.4.0 - but with Win2000 it is correct for example.
    My question is - how can it be, that the normal default cell editor does not have this behavior but when I use the line above, it is displayed in the wrong way?- What does the default cell editor in another way than I do it, that it has not this ugly display?
    I would like to look in the sources, but unfortunately I can't find the source code in JDK 1.4.0 - perhaps you have a hint, where to find it.
    greetings Marsian

    It seems the Label doesn't like it, that it is in a GridCell with rowspan = 2
    If it is in a normal cell (no rowspan), it works.
    If I add ColumnConstraints to the gridpane, it kind of works, but the Label still occupies more space than it should.
    Edited by: csh on 19.07.2012 03:51

  • Strange behavior of GetStringUTFChars in Linux

    Good evening!
    I made an implementation of a native method in C++ for Windows and Linux, in windows it works fine, but in Linux I have a strange behavior of GetStringUTFChars here is the piece code :
    JNIEXPORT jint JNICALL Java_MyNativeMethod
    (JNIEnv *env, jobject obj, jstring IpAddress) {
    const char * ccpIpAddress = env->GetStringUTFChars(IpAddress, 0);
    jsize size = env->GetStringLength(ccpIpAddress);
    trace("IpAddress : %s size: %d", ccpIpAddress, size);
    Absolute normal... but when I pass as parameter a string '192.168.1.11'
    I receive from 'IpAddress : HB&#317;1 size: 0' to 'IpAddress : P9D7D6DwD&#65533;MS\H#M\H : 251'
    I made a little and simple test to print a String to verify if is Linux problem but IT WORKED FINE!
    I've notice that the differences between both programs are that the wrong one has been linked with a C lib, but the #define __cplusplus is OK also, and all the compile process use C++ code...
    This is my compilation line
    g++ -o lib{myLib}.so {myImpl}.cpp lib{C li}.so libstdc++.so -I {JAVA_HOME}/include/ -I {JAVA_HOME}/include/linux/ -shared -static -L{JAVA_HOME}/jre/lib/i386/
    (variables put for clarity) and (I tried with gcc also)
    the libstrd++.so is been used in my simple test link options too.
    I was wondering if there is some -Doption which should be defined that
    functions->GetStringChars(this,str,isCopy); implementation ask for...
    or if the link with a C code is messing the things in a different behavior
    Thanks for the help
    Pedro Ribeiro
    Sao Paulo - Brazil

    JNIEXPORT jint JNICALL Java_MyNativeMethod
    (JNIEnv *env, jobject obj, jstring IpAddress) {
    const char * ccpIpAddress = env->GetStringUTFChars(IpAddress, 0);
    jsize size = env->GetStringLength(ccpIpAddress);
    trace("IpAddress : %s size: %d", ccpIpAddress, size);
    =====================
    You tried to get the string length of C character array.
    I think you can get the length of jstring alone.
    Please advice me if I am wrong

  • JDEV Team: Strange behavior in TOMCAT using DATATAGS (VERY CRITICAL)

    I am encountering some strange behavior when I deploy my application to TOMCAT.
    If I run in JDeveloper (webtogo) everything works fine but the behavior changes completely in TOMCAT.
    Let me try and explain my situation here.
    I have 3 jsps :
    1.iss_listApps.jsp which is used to browse all the available records, allows the user to navigate to a specific record and edit or delete.
    2. app_edit.jsp which is used to edit/delete a specific row passed from iss_listApps.jsp.
    3. app_edit_post.jsp which is used to save the changes.
    Note that I use an anchor ">Edit</a> to pass a row from the browser page to the edit page.
    For your convenience I have listed all the source files below.
    Now here are my problems:
    Problem 1. If I run it in JDeveloper, I am able to browse the records and go to a specific record to edit and delete by clicking on the "Edit" anchor provided in the browser page.
    I can also go to the edit page and backout out of it by not saving the changes. In that case I am back in my browser page and I can again click on the "Edit" anchor to a specific record.
    However if I am in TOMCAT, I am able to browse and go to a specific record so long as I make changes to it and save it. If for any reason, I do not save a record and I go back to my browser
    page then any subsequent calls to to edit a specific record goes to the same OLD RECORD that I did not save.
    I fail to understand why? Maybe the "webtogo" server automatically refreshes when I click on the "back tab". If so, how do I automatically refresh a jsp page when I click on the "back tab" in TOMCAT.
    I would sincerely appreciate any help on this.
    Problem 2. I have an include jsp tag in my browser page. defined as
    <jsp:include page="Message.jsp" flush="true">
    <jsp:param name="colspan" value="2"/>
    </jsp:include>.
    This section of the code is currently commented out because if I uncomment it then it runs ok in JDeveloper but in Tomcat it causes the browser page to always navigate to the first record if I want to edit a specific record.
    I would sincerely appreciate any answer on this.
    Here are my source files:
    1. iss_ListApps.jsp (browser page). Please see how the anchor is formed. It causes no problems
    in JDeveloper.
    <%@ page contentType="text/html;charset=WINDOWS-1252"%>
    <HTML>
    <base target="contentsframe">
    <head>
    </head>
    <body>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <jbo:ApplicationModule id="NewBC4J.NewBC4JModule" configname="NewBC4J.NewBC4JModule.NewBC4JModuleLocal" username="issue" password="issue"/>
    <jbo:RollBack appid="NewBC4J.NewBC4JModule" />
    <jbo:DataSource id="app_vo" appid="NewBC4J.NewBC4JModule" viewobject="ApplicationsView" ></jbo:DataSource>
    <jbo:RefreshDataSource datasource="app_vo" />
    <table width="100%" bgcolor="tan" border="0" align="center" cellpadding="3" cellspacing="0">
    <%--
    <jsp:include page="Message.jsp" flush="true">
    <jsp:param name="colspan" value="2"/>
    </jsp:include> --%>
    <form name="list" target="body" action="app_edit.jsp" method="post">
    <tr><th colspan="4">List of Valid Applications</th></tr>
    <tr>
    <th> </th>
    <th align="left"><u>Code</u></th>
    <th align="left"><u>Name</u></th>
    <th align="left"><u>Description</u></th>
    </tr>
    <tr>
    <jbo:RowsetIterate datasource="app_vo">
    <td>
    <a href="app_edit.jsp?RowKeyValue=<jbo:ShowValue datasource="app_vo" dataitem="RowKey"/>">Edit</a>
    </td>
    <td>
    <jbo:ShowValue datasource="app_vo" dataitem="Code" />
    </td>
    <td>
    <jbo:ShowValue datasource="app_vo" dataitem="Name" />
    </td>
    <td>
    <jbo:ShowValue datasource="app_vo" dataitem="A ppDesc" />
    </td>
    </tr>
    </jbo:RowsetIterate>
    </form>
    </table>
    <table width="100%" bgcolor="skyblue" align="center" cellpadding="10" cellspacing="0" >
    <tr>
    <form NAME="AddForm" action="app_add.jsp">
    <td>
    <input type = "submit" name="submit" value="Add" align="center" >
    </td>
    </form>
    </tr>
    </table>
    </body>
    <jbo:ReleasePageResources releasemode="Stateful" appid="NewBC4J.NewBC4JModule" />
    </html>
    2. Second Source File: app_edit.jsp (Allows editing of a record)
    <%@ page contentType="text/html;charset=WINDOWS-1252"%>
    <HTML>
    <base target="contentsframe">
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=WINDOWS-1252">
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    <TITLE>
    </TITLE>
    </HEAD>
    <BODY>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <jbo:ApplicationModule id="NewBC4J.NewBC4JModule" configname="NewBC4J.NewBC4JModule.NewBC4JModuleLocal" />
    <jbo:DataSource id="app_vo" appid="NewBC4J.NewBC4JModule" viewobject="ApplicationsView" />
    <jbo:Row id="myrow" datasource="app_vo" rowkeyparam="RowKeyValue" action="Find">
    <jbo:SetAttribute dataitem="*"/>
    </jbo:Row>
    <table width="100%" bgcolor="skyblue" border="0" align="center">
    <tr>
    <td>
    <table width="100%" bgcolor="tan" border="0" align="center" cellpadding="3" cellspacing="0">
    <form NAME="iForm" action="app_edit_post.jsp">
    <tr>
    <th colspan="2">
    "Edit/Delete Applications"
    </th>
    </tr>
    <jsp:include page="Message.jsp" flush="true">
    <jsp:param name="colspan" value="2"/>
    </jsp:include>
    <tr>
    <td align="right"><b><font color="red"> Name:</font></b></td>
    <td> <jbo:InputText datasource="app_vo" dataitem="Name" cols="50" />
    </td>
    </tr>
    <tr>
    <td align="Right"><b><font color="red"> Description: </font></b></td>
    <td> <jbo:InputTextArea datasource="app_vo" dataitem="AppDesc" cols="50" rows="5" />
    </td>
    </tr>
    </table>
    <!-- Create a table for the save and Delete Buttons -->
    <table width="100%" bgcolor="skyblue" align="center" cellpadding="10" cellspacing="0" >
    <tr>
    <input name="RowKeyValue" type="hidden" value="<jbo:ShowValue datasource="app_vo" dataitem="RowKey"/>" />
    <td>
    <input type = "submit" name="submit" value="Save">
    </td>
    </form>
    <form NAME="DelForm" action="app_del_post.jsp">
    <input name="RowKeyVal" type="hidden" value="<jbo:ShowValue datasource="app_vo" dataitem="RowKey"/>" />
    <td>
    <input type = "submit" name="submit" value="Delete">
    </td>
    </form>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </BODY>
    </HTML>
    <jbo:ReleasePageResources releasemode="Stateful" />
    3. Third source file app_edit_post.jsp (ALlows saving the changes made to a specific record)
    <%@ page contentType="text/html;charset=ISO-8859-1"%>
    <HTML>
    <BODY>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <jbo:ApplicationModule id="NewBC4J.NewBC4JModule" configname="NewBC4J.NewBC4JModule.NewBC4JModuleLocal" />
    <jbo:DataSource id="app_vo" appid="NewBC4J.NewBC4JModule" viewobject="ApplicationsView" ></jbo:DataSource>
    <%
    try
    %>
    <jbo:Row id="row3" datasource="app_vo" rowkeyparam="RowKeyValue" action="Update" >
    <jbo:SetAttribute dataitem="*" />
    </jbo:Row>
    <jbo:Commit appid="NewBC4J.NewBC4JModule" />
    <p><font face="Arial, Helvetica, sans-serif"><b><font color="006699">Application Successfully Updated</b></font></font> </p>
    <%
    catch(Exception exc)
    out.println("<pre> ");
    exc.printStackTrace(new java.io.PrintWriter(out));
    out.println("</pre>");
    %>
    <br>
    <br>
    <form action="app_ListApps.jsp" method="post"><input type="submit" value="Click to Continue"></form
    <jbo:ReleasePageResources releasemode="Stateful" />
    </BODY>
    </HTML>
    null

    I would not expect the 'back' button to automatically refresh the page. This button basically traverses the history of pages. Since Tomcat is caching your pages, you can try to control it's interaction with the browser by:
    1. Adding cache control pragmas to the returned content so it doesn't get cached.(look at www.w3c.org at the HTTP spec)
    2. dont rely on the back button, place a link on your pages to go back to the list page.
    3. change your cache control settings in your browser to check for a new page every time a url is visited.

  • Finder  method in Entity bean

    how many Finder method in Entity bean i can write ?
    look below...
    public Account findByPrimaryKey(AccountPK key) throws FinderException,
    RemoteException;
    public Enumeration findByOwnerName(String name) throws FinderException,
    RemoteException;here 2 finder methods are there.......i am asking how much freedom i have ? can write as many as finder method i wish ?
    say, findXXXX() ?

    my problem is on the signature of the find
    method.
    OK let me ask you some other way.
    java DOC says
    Each enterprise Bean has a home interface. The home
    interface must extend the javax.ejb.EJBHome
    interface, and define the enterprise Bean type
    specific create and finder methods (session Beans do
    not have finders).
    look it says " finder methods "....right .
    so i want to ask 2 question about this phrase . PLZ
    do confirm me whether i am right or wrong.
    fact 1. finder methods means you can write
    any method name which starts with word find
    and ONLY find
    Example: findABCD( ) , findEFGH(),
    findBLAHBLAH()...any thing starts with find[i]
    are called finder methods...others are NOT.
    is This fact correct ?
    Yes.
    fact 2. Is not it Strange that i need to
    append some letters after the word find to
    get a finder method name !! why not wrting a simple
    method name ( say abcdfgrty () instead of
    findXXXX() which will do the job ??You can... but it has to be called form a findXXXX() method :)
    As such there is no problem in writng a
    find_ANY_WORDS_HERE() to get a finder method but
    problem is why i need to stick to the word
    find and append some words after it
    t to get a finder method ? if i had to do it
    seriously then whats the role of the container ? how
    w it is linking ?Once someone takes the pain of going through the EJB specs, he would not have a problem. Imagine each vendor using his own brains and the developer getting bugged with new features in each AS. EJB specs are flexible enough already :)

  • Compiler strange behavior

    Hi friends,
    I dont know whether this is the right forum page to post this topic.
    I've observed a strange behavior of the java compiler may be it is programmed for so.
    As we all know that java.lang.System.arraycopy(Object,int,Object,int,int) method can be used to copy the objects & primitive type arrays, how come? for instance
        String s[] = new String[]{"1", "2"};
        String c[] = new String[s.length];
        System.arraycopy(s, 0, c, 0, s.length); // compiles for objects "and"
        byte b[] = new byte[]{1,1,1};
        byte e[] = new byte[b.length];
        System.arraycopy(b, 0, e, 0, b.length); // compiles for primitive as wellI'm not pin-pointing or arguing just wondering & curious. May be the above is an exception to the Compiler.
    Can any one of you clear my curosity?
    regards,
    Afroze.

    All arrays are Objects, even arrays of primitive data types. They are treated specially, in terms of syntax and by the compiler, but they are still objects with fields (like "length") and methods (like "clone()").
    So in the method arraycopy(Object,int,Object,int,int), the Object arguments can be primitive or Object arrays. Does that help?

Maybe you are looking for

  • Using animated gif...

    I've encountered a problem in displaying animated gif using java Swing. For my program, I need to display 6 animated gif images. Sometimes I would get all those displayed, but sometimes only 1 or few are displayed. This problem troubles me until I fo

  • HP laserjet 1536dnf - Automatic answer mode stopped answering

    When my printer was installed and I set up incoming faxes for automatic answer mode at 5 rings, it worked great for about 2 weeks then stopped answering. Now the only way for me to receive faxes is manually. Does anyone have any suggestions? I am cur

  • How to Install XSQL On Apache 1.3.12 Tomcat 3.1 ?

    We are trying to install the XSQL 1.0.0 Servlet to the Apache 1.3.12 With Tomcat 3.1 (production verion) on Solaris 2.6 platform. We followed the instructions on the XSQL Release Note. However, it does not work. More specifically, we modified the tom

  • Where can I find the "Profiles" in Thunderbird?

    I am moving from one operating system to another and would like to transfer all my Thunderbirtd settings.

  • Local administrator name(language) on remote computer

    I have a big number of computers around, which I would like to have inventoried. Issue is that some of those have native US-US locale and some of them RU-RU, so the local administrator account could be named 'Administrator' or 'Администратор'. These